Class: Ardb::Runner::GenerateCommand
- Inherits:
-
Object
- Object
- Ardb::Runner::GenerateCommand
- Defined in:
- lib/ardb/runner/generate_command.rb
Defined Under Namespace
Classes: MigrationCommand
Instance Method Summary collapse
-
#initialize(args) ⇒ GenerateCommand
constructor
A new instance of GenerateCommand.
- #migration_cmd ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(args) ⇒ GenerateCommand
Returns a new instance of GenerateCommand.
7 8 9 10 |
# File 'lib/ardb/runner/generate_command.rb', line 7 def initialize(args) @item = args.shift @args = args end |
Instance Method Details
#migration_cmd ⇒ Object
31 32 33 |
# File 'lib/ardb/runner/generate_command.rb', line 31 def migration_cmd MigrationCommand.new(@args.first).run end |
#run ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/ardb/runner/generate_command.rb', line 12 def run if @item.nil? raise Ardb::Runner::CmdError, "specify an item to generate" end if !self.respond_to?("#{@item}_cmd") raise Ardb::Runner::CmdError, "can't generate #{@item}" end begin self.send("#{@item}_cmd") rescue Ardb::Runner::CmdError => e raise e rescue Exception => e $stderr.puts e $stderr.puts "error generating #{@item}." raise Ardb::Runner::CmdFail end end |