Class: ExtensionGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/extension/extension_generator.rb

Instance Method Summary collapse

Instance Method Details

#directoriesObject



6
7
8
9
10
11
12
13
14
# File 'lib/generators/extension/extension_generator.rb', line 6

def directories
  empty_directory "#{extension_path}/app/controllers"
  empty_directory "#{extension_path}/app/helpers"
  empty_directory "#{extension_path}/app/models"
  empty_directory "#{extension_path}/app/views"
  empty_directory "#{extension_path}/config/locales"
  empty_directory "#{extension_path}/db/migrate"
  empty_directory "#{extension_path}/lib/tasks"
end

#rspecObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/generators/extension/extension_generator.rb', line 25

def rspec
  unless options.with_test_unit?
    empty_directory "#{extension_path}/spec/controllers"
    empty_directory "#{extension_path}/spec/models"        
    empty_directory "#{extension_path}/spec/views"
    empty_directory "#{extension_path}/spec/helpers"
    empty_directory "#{extension_path}/features/support"
    empty_directory "#{extension_path}/features/step_definitions/admin"
    
    template  'rspec/Rakefile',          "#{extension_path}/Rakefile"
    template  'rspec/spec_helper.rb',    "#{extension_path}/spec/spec_helper.rb"
    copy_file 'rspec/_.rspec',           "#{extension_path}/spec/.rspec"
    copy_file 'rspec/cucumber.yml',      "#{extension_path}/cucumber.yml"
    template  'rspec/cucumber_env.rb',   "#{extension_path}/features/support/env.rb"
    template  'rspec/cucumber_paths.rb', "#{extension_path}/features/support/paths.rb"
  end
end

#templatesObject



16
17
18
19
20
21
22
23
# File 'lib/generators/extension/extension_generator.rb', line 16

def templates
  template 'README.md',     "#{extension_path}/README.md"
  template 'VERSION',       "#{extension_path}/VERSION"
  template 'extension.rb',  "#{extension_path}/#{file_name}.rb"
  template 'tasks.rake',    "#{extension_path}/lib/tasks/#{file_name}_tasks.rake"
  template 'en.yml',        "#{extension_path}/config/locales/en.yml"
  template 'routes.rb',     "#{extension_path}/config/routes.rb"
end

#testunitObject



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/generators/extension/extension_generator.rb', line 43

def testunit
  if options.with_test_unit?
    empty_directory "#{extension_path}/test/fixtures"
    empty_directory "#{extension_path}/test/functional"
    empty_directory "#{extension_path}/test/unit"
    
    template 'test/Rakefile',            "#{extension_path}/Rakefile"
    template 'test/test_helper.rb',      "#{extension_path}/test/test_helper.rb"
    template 'test/functional_test.rb',  "#{extension_path}/test/functional/#{extension_file_name}_test.rb"
  end
end