Skip to content

Instantly share code, notes, and snippets.

@op-ct
Last active August 28, 2015 14:33
Show Gist options
  • Save op-ct/fcb58c042e1b6c07e6a1 to your computer and use it in GitHub Desktop.
Save op-ct/fcb58c042e1b6c07e6a1 to your computer and use it in GitHub Desktop.
Simple ERB templater
require 'erb'
require 'ostruct'
desc 'Generate a README.md using the module name'
task 'generate', [:name] do |t, args|
metadata = OpenStruct.new( args.to_hash )
erb_file = File.expand_path('README.md.erb', File.dirname(__FILE__))
template = File.open( erb_file, 'r').readlines.join("\n")
content = ERB.new template
File.open( 'README.md', 'w' ){ |f| f.puts content.result(binding) }
end
@op-ct
Copy link
Author

op-ct commented Aug 27, 2015

Usage
# generate README.md for module 'awesomesauce'
rake -f /path/to/Rakefile generate[awesomesauce]
Notes
  • README.md.erb has to be in the same directory as Rakefile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment