By having a
gemspec which parses the yaml frontmatter of it’s own
you can drive a
gemspec from a really simple template, and get a nice small
footprint gem, hostable as a gist.
Basically, I found out that since YAML frontmatter in a markdown file uses the
same separators as YAML itself for document separation (which I’m certain was
on purpose), using
YAML.load_file on a markdown file will return the frontmatter!
SO, define important parts of the gem in front matter, and take
development to the next level!
require "yaml" header = YAML.safe_load_file("readme.md") Gem::Specification.new do |spec| spec.name = header["name"] spec.version = header["version"] spec.authors = ["Jon Raphaelson"] spec.email = ["firstname.lastname@example.org"] spec.summary = header["summary"] spec.license = "MIT" spec.files = Dir.glob("**/*.rb", base: __dir__) spec.require_paths = ["."] end