Class: Testcloud::Generator::Commands::UseCase

Inherits:
Base
  • Object
show all
Defined in:
lib/testcloud/generator/commands/use_case.rb

Instance Attribute Summary

Attributes inherited from Base

#options, #parsed_options, #template_options, #thor

Instance Method Summary collapse

Methods inherited from Base

#abort_command, #confirmation_prompt, #initialize, #readline, #run

Constructor Details

This class inherits a constructor from Testcloud::Generator::Commands::Base

Instance Method Details

#execute_commandObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/testcloud/generator/commands/use_case.rb', line 5

def execute_command
  spec = find_gemspec_for(Dir.pwd)
  spec_options = extract_options_from_gemspec(spec)
  use_case_options = build_options_for_use_case(options)
  target = File.join(Dir.pwd, 'lib', spec_options[:path_name])
  puts target

  @template_options = {
    spec: spec_options,
    use_case: use_case_options
  }

  options = @template_options

  templates = {
    'use_cases/new_use_case.rb.tt' => "use_cases/#{use_case_options[:underscore_name]}.rb",
    'use_cases/new_params.rb.tt' => "params/#{use_case_options[:params_underscore_name]}.rb"
  }

  thor.template('use_case/new_use_case.rb.tt', File.join(target, templates['use_cases/new_use_case.rb.tt']), options)
  thor.template('use_case/new_params.rb.tt', File.join(target, templates['use_cases/new_params.rb.tt']), options)
end