Class: Adhearsion::Generators::ControllerGenerator

Inherits:
Generator show all
Defined in:
lib/adhearsion/generators/controller/controller_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Generator

base_root, default_source_root, desc, namespace, source_root

Class Method Details

.short_descObject



9
10
11
# File 'lib/adhearsion/generators/controller/controller_generator.rb', line 9

def self.short_desc
  "A call controller template. 'controller_name' should be the disired class name, either CamelCase or under_scored."
end

Instance Method Details

#create_controllerObject

Raises:

  • (Exception)


13
14
15
16
17
18
19
20
# File 'lib/adhearsion/generators/controller/controller_generator.rb', line 13

def create_controller
  raise Exception, "Generator commands need to be run in an Adhearsion app directory" unless ScriptAhnLoader.in_ahn_application?('.')
  self.destination_root = '.'
  empty_directory 'lib'
  empty_directory 'spec'
  template 'lib/controller.rb.erb', "lib/#{@controller_name.underscore}.rb"
  template 'spec/controller_spec.rb.erb', "spec/#{@controller_name.underscore}_spec.rb"
end