Class: Operations::CreateGenerator

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/operations/create_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/operations/create_generator.rb', line 20

def exit_on_failure?
  true
end

Instance Method Details

#class_nameObject



43
44
45
# File 'lib/operations/create_generator.rb', line 43

def class_name
  singular_name.capitalize
end

#copy_generator_filesObject



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/operations/create_generator.rb', line 47

def copy_generator_files
  return if options[:dry_run]

  template "templates/template_generator.rb.erb", "lib/operations/generators/#{name}_generator.rb"
  template "templates/template_generator_spec.rb.erb",
           "spec/operations/generators/#{name}_generator_spec.rb"

  create_file "lib/operations/generators/#{name}/templates/#{name}.rb.erb" do
    "This is #{name}.rb.erb"
  end
end

#plural_nameObject



35
36
37
# File 'lib/operations/create_generator.rb', line 35

def plural_name
  name.pluralize
end

#singular_nameObject



39
40
41
# File 'lib/operations/create_generator.rb', line 39

def singular_name
  name.singularize
end