Module: Vocco
- Defined in:
- lib/vocco.rb
Defined Under Namespace
Modules: CLI Classes: Generator
Constant Summary collapse
- OPTIONS =
These are the available options. They can be given on the command line, the linux way, or as a hash to Vocco.run(…), the Rubygem way. The format is:
[name, description,
default_value ]
[ [: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 =
{}
Class Method Summary collapse
-
.gemspec(prop) ⇒ Object
Tries to read a property from the gemspec with the same name as the working dir, in the working dir.
-
.run(opts) ⇒ Object
(also: run!, start)
Vocco::run is the interface for using Vocco as a gem.
- .validate(opts) ⇒ Object
Class Method Details
.gemspec(prop) ⇒ Object
Tries to read a property from the gemspec with the same name as the working dir, in the working dir.
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/vocco.rb', line 38 def gemspec(prop) begin require 'rubygems' @gemspec ||= Gem::Specification.load( Dir['**/*.gemspec'].first ) @gemspec.send prop rescue nil end end |
.run(opts) ⇒ Object Also known as: run!, start
Vocco::run is the interface for using Vocco as a gem.
18 19 20 21 22 23 |
# File 'lib/vocco.rb', line 18 def run(opts) validate(opts) Generator.new( DEFAULTS.merge(opts) ).run end |
.validate(opts) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/vocco.rb', line 28 def validate(opts) bad_opts = opts.keys - OPTION_NAMES if bad_opts.any? raise "Invalid options: #{bad_opts}" end end |