Class: Cybertron::Generate
- Inherits:
-
Thor
- Object
- Thor
- Cybertron::Generate
- Includes:
- Thor::Actions
- Defined in:
- lib/cybertron/generate_command.rb
Overview
CLI class
Class Method Summary collapse
- .banner(command, namespace = nil, subcommand = false) ⇒ Object
- .source_root ⇒ Object
- .subcommand_prefix ⇒ Object
Instance Method Summary collapse
Class Method Details
.banner(command, namespace = nil, subcommand = false) ⇒ Object
15 16 17 |
# File 'lib/cybertron/generate_command.rb', line 15 def self.(command, namespace = nil, subcommand = false) "#{basename} #{subcommand_prefix} #{command.usage}" end |
.source_root ⇒ Object
11 12 13 |
# File 'lib/cybertron/generate_command.rb', line 11 def self.source_root File.('../templates', __dir__) end |
.subcommand_prefix ⇒ Object
19 20 21 |
# File 'lib/cybertron/generate_command.rb', line 19 def self.subcommand_prefix self.name.gsub(%r{.*::}, '').gsub(%r{^[A-Z]}) { |match| match[0].downcase }.gsub(%r{[A-Z]}) { |match| "-#{match[0].downcase}" } end |
Instance Method Details
#fixture(codemod, name) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/cybertron/generate_command.rb', line 37 def fixture(codemod, name) @codemod = codemod @name = name puts "Creating new fixture: #{name} for #{codemod}" template 'transforms/fixture_input.tt', File.absolute_path("transforms/#{codemod}/fixtures/#{name}_input.rb") template 'transforms/fixture_output.tt', File.absolute_path("transforms/#{codemod}/fixtures/#{name}_output.rb") end |
#transform(name) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/cybertron/generate_command.rb', line 24 def transform(name) @name = name puts "Creating new transform: #{name}" FileUtils.mkdir_p "transforms/#{name}" FileUtils.mkdir_p "transforms/#{name}/fixtures" template 'transforms/transform.tt', File.absolute_path("transforms/#{name}/transform.rb") template 'transforms/spec.tt', File.absolute_path("spec/#{name}_spec.rb") template 'transforms/fixture_input.tt', File.absolute_path("transforms/#{name}/fixtures/basic_input.rb") template 'transforms/fixture_output.tt', File.absolute_path("transforms/#{name}/fixtures/basic_output.rb") template 'transforms/README.tt', File.absolute_path("transforms/#{name}/README.md") end |