class Cybertron::Generate
CLI
class
Public Class Methods
source_root()
click to toggle source
# File lib/cybertron/generate_command.rb, line 11 def self.source_root File.expand_path('../templates', __dir__) end
subcommand_prefix()
click to toggle source
# 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
Public Instance Methods
fixture(codemod, name)
click to toggle source
# 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)
click to toggle source
# 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