require 'hpricot'
require 'tilt'
require 'tempfile'
module Vocco
require 'vocco/generator'
require 'vocco/cli'
class << self
def run(opts)
validate(opts)
Generator.new(
DEFAULTS.merge(opts)
).run
end
alias :run! :run
alias :start :run
def validate(opts)
bad_opts = opts.keys - OPTION_NAMES
if bad_opts.any?
raise "Invalid options: #{bad_opts}"
end
end
def gemspec(prop)
begin
require 'rubygems'
@gemspec ||= Gem::Specification.load(
Dir['**/*.gemspec'].first
)
@gemspec.send prop
rescue
nil
end
end
end
OPTIONS = [
[:files, "File match globs",
%w{**/*.rb README LICENSE}
],
[:out, "Output directory",
'./docs'
],
[:notes, "Note directories",
['./notes']
],
[:name, "Project name",
gemspec(:name) || File.basename(Dir.pwd)
],
[:site, "Project url",
gemspec(:homepage)
],
[:vim, "Vim command", %w{macvim gvim vim}
]
]
OPTION_NAMES = OPTIONS.map {|opt| opt.first }
DEFAULTS = {}
OPTIONS.each do |opt|
DEFAULTS[opt[0]] = opt[2]
end
end
Generated: | Mon Mar 14 01:26:25 +0100 2011 |
---|