Class: Adhearsion::Generators::PluginGenerator

Inherits:
Generator show all
Defined in:
lib/adhearsion/generators/plugin/plugin_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/plugin/plugin_generator.rb', line 9

def self.short_desc
  "A plugin template. 'plugin_name' should be the disired plugin module name, either CamelCase or under_scored."
end

Instance Method Details

#create_pluginObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/adhearsion/generators/plugin/plugin_generator.rb', line 13

def create_plugin
  @plugin_file = @plugin_name.underscore
  @plugin_name = @plugin_name.camelize
  self.destination_root = @plugin_file

  empty_directory "lib"
  empty_directory "lib/#{@plugin_file}"
  empty_directory "spec"

  copy_file "gitignore", ".gitignore"

  template 'plugin-template.gemspec.tt', "#{@plugin_file}.gemspec"
  template 'Rakefile.tt', "Rakefile"
  template 'README.md.tt', "README.md"
  template 'Gemfile.tt', "Gemfile"

  template 'lib/plugin-template.rb.tt', "lib/#{@plugin_file}.rb"
  template 'lib/plugin-template/version.rb.tt', "lib/#{@plugin_file}/version.rb"
  template 'lib/plugin-template/plugin.rb.tt', "lib/#{@plugin_file}/plugin.rb"
  template 'lib/plugin-template/controller_methods.rb.tt', "lib/#{@plugin_file}/controller_methods.rb"

  template 'spec/spec_helper.rb.tt', "spec/spec_helper.rb"
  template 'spec/plugin-template/controller_methods_spec.rb.tt', "spec/#{@plugin_file}/controller_methods_spec.rb"
end