Class: Padrino::Generators::Cli
- Includes:
- Thor::Actions
- Defined in:
- padrino-gen/lib/padrino-gen/generators/cli.rb
Overview
This class bootstrap config/boot
and perform Padrino::Generators.load_components!
for handle 3rd party generators.
Instance Method Summary collapse
-
#load_boot ⇒ Object
We need to try to load boot because some of our app dependencies maybe have custom generators, so is necessary know who are.
-
#setup ⇒ Object
Loads the components available for all generators.
Instance Method Details
#load_boot ⇒ Object
We need to try to load boot because some of our app dependencies maybe have custom generators, so is necessary know who are.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'padrino-gen/lib/padrino-gen/generators/cli.rb', line 20 def load_boot begin ENV['PADRINO_LOG_LEVEL'] ||= 'test' ENV['BUNDLE_GEMFILE'] = File.join([:root], 'Gemfile') if [:root] boot = [:root] ? File.join([:root], 'config/boot.rb') : 'config/boot.rb' if File.exist?(boot) require File.(boot) else require 'padrino-support' end rescue StandardError => e puts "=> Problem loading #{boot}" puts ["=> #{e.}", *e.backtrace].join("\n ") ensure ENV.delete('BUNDLE_GEMFILE') ENV.delete('PADRINO_LOG_LEVEL') end end |
#setup ⇒ Object
Loads the components available for all generators.
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'padrino-gen/lib/padrino-gen/generators/cli.rb', line 42 def setup Padrino::Generators.load_components! generator_kind = ARGV.delete_at(0).to_s.downcase.to_sym if ARGV[0] && !ARGV[0].empty? generator_class = Padrino::Generators.mappings[generator_kind] if generator_class args = ARGV.empty? && generator_class.require_arguments? ? ['-h'] : ARGV generator_class.start(args) else puts "Please specify generator to use (#{Padrino::Generators.mappings.keys.join(", ")})" end end |