Class: WpGenerate
- Inherits:
-
Object
- Object
- WpGenerate
- Defined in:
- lib/wp_generate.rb,
lib/wp_generate.rb
Defined Under Namespace
Classes: Generator
Class Method Summary collapse
Class Method Details
.generate(args) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/wp_generate.rb', line 17 def self.generate args = [] while generator = args.shift break unless generator.start_with? '-' << generator end base_path = 'wp_generate/generator' if generator.nil? STDERR.puts 'Usage: wp-generate [GLOBAL OPT...] [generator] [PATH|OPT]' STDERR.puts 'Generators:' $:.map{|path|File.join(path,base_path,'*.rb')}.each do |path| Dir.glob(path).map{|generator| generator.match(%r&/([^/]+)\.rb$&)[1]}.each do |generator| STDERR.puts ' '+generator end end exit 1 end generator_path = File.join(base_path,generator) begin require generator_path rescue LoadError true # This is for rcov end generator_path.camelize.constantize.new(args, ).generate end |