Class: Apimaster::Generators::ControllerGenerator

Inherits:
Create show all
Defined in:
lib/apimaster/generators/controller_generator.rb

Constant Summary

Constants inherited from Base

Base::DEFAULT_SHEBANG

Instance Attribute Summary collapse

Attributes inherited from Base

#active, #args, #destination_root, #logger, #source_root, #spec, #stdout

Attributes included from Options

#options

Instance Method Summary collapse

Methods inherited from Create

#class_collisions, #complex_template, #directory, #file, #file_copy_each, #folder, #identical?, #migration_template, #readme, #route_resources, #template, #template_copy_each, #write_manifest

Methods inherited from Command

#class_collisions, #dependency, #destination_path, #invoke!, #readme, #source_path, #write_manifest

Methods inherited from Base

#after_generate, #base_name, #camelize, #destination_path, #pluralize, #run, #source_path

Methods included from Options

included

Constructor Details

#initialize(runtime_args, runtime_options = {}) ⇒ ControllerGenerator

Returns a new instance of ControllerGenerator.



6
7
8
9
10
11
12
13
# File 'lib/apimaster/generators/controller_generator.rb', line 6

def initialize(runtime_args, runtime_options = {})
  super
  raise 'Unknown app directory.' unless File.exists?('./Gemfile')
  @app_name     = File.basename(File.expand_path('./'))
  @module_name  = camelize(app_name)
  @name     = args[0]
  raise 'Undefined app name.' unless @app_name
end

Instance Attribute Details

#app_nameObject (readonly)

Returns the value of attribute app_name.



4
5
6
# File 'lib/apimaster/generators/controller_generator.rb', line 4

def app_name
  @app_name
end

#module_nameObject (readonly)

Returns the value of attribute module_name.



4
5
6
# File 'lib/apimaster/generators/controller_generator.rb', line 4

def module_name
  @module_name
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/apimaster/generators/controller_generator.rb', line 4

def name
  @name
end

Instance Method Details

#manifestObject



15
16
17
18
19
20
# File 'lib/apimaster/generators/controller_generator.rb', line 15

def manifest
  record do |m|
    m.template "app/controllers/examples_controller.rb.erb", "app/controllers/#{pluralize name}_controller.rb"
    m.template "test/functional/examples_controller_test.rb.erb", "test/functional/#{pluralize name}_controller_test.rb"
  end
end