Class: Rails::Generators::PluginGenerator

Inherits:
AppBase show all
Defined in:
railties/lib/rails/generators/rails/plugin/plugin_generator.rb

Overview

:nodoc:

Constant Summary

Constants inherited from AppBase

AppBase::DATABASES, AppBase::JDBC_DATABASES

Instance Attribute Summary

Attributes inherited from AppBase

#rails_template

Instance Method Summary collapse

Methods inherited from AppBase

add_shared_options_for

Methods inherited from Base

base_root, class_option, default_source_root, desc, hide!, hook_for, inherited, namespace, remove_hook_for, source_root

Methods included from Actions

#add_source, #capify!, #environment, #gem, #gem_group, #generate, #git, #initializer, #lib, #rake, #rakefile, #readme, #route, #vendor

Constructor Details

#initialize(*args) ⇒ PluginGenerator

Returns a new instance of PluginGenerator

Raises:


178
179
180
181
182
183
# File 'railties/lib/rails/generators/rails/plugin/plugin_generator.rb', line 178

def initialize(*args)
  raise Error, "Options should be given after the plugin name. For details run: rails plugin new --help" if args[0].blank?

  @dummy_path = nil
  super
end

Instance Method Details

#create_app_filesObject


196
197
198
# File 'railties/lib/rails/generators/rails/plugin/plugin_generator.rb', line 196

def create_app_files
  build(:app)
end

#create_bin_filesObject


220
221
222
# File 'railties/lib/rails/generators/rails/plugin/plugin_generator.rb', line 220

def create_bin_files
  build(:bin)
end

#create_config_filesObject


200
201
202
# File 'railties/lib/rails/generators/rails/plugin/plugin_generator.rb', line 200

def create_config_files
  build(:config)
end

#create_images_directoryObject


216
217
218
# File 'railties/lib/rails/generators/rails/plugin/plugin_generator.rb', line 216

def create_images_directory
  build(:images)
end

#create_javascript_filesObject


212
213
214
# File 'railties/lib/rails/generators/rails/plugin/plugin_generator.rb', line 212

def create_javascript_files
  build(:javascripts)
end

#create_lib_filesObject


204
205
206
# File 'railties/lib/rails/generators/rails/plugin/plugin_generator.rb', line 204

def create_lib_files
  build(:lib)
end

#create_public_stylesheets_filesObject


208
209
210
# File 'railties/lib/rails/generators/rails/plugin/plugin_generator.rb', line 208

def create_public_stylesheets_files
  build(:stylesheets)
end

#create_root_filesObject


187
188
189
190
191
192
193
194
# File 'railties/lib/rails/generators/rails/plugin/plugin_generator.rb', line 187

def create_root_files
  build(:readme)
  build(:rakefile)
  build(:gemspec)   unless options[:skip_gemspec]
  build(:license)
  build(:gitignore) unless options[:skip_git]
  build(:gemfile)   unless options[:skip_gemfile]
end

#create_test_dummy_filesObject


228
229
230
231
# File 'railties/lib/rails/generators/rails/plugin/plugin_generator.rb', line 228

def create_test_dummy_files
  return unless with_dummy_app?
  create_dummy_app
end

#create_test_filesObject


224
225
226
# File 'railties/lib/rails/generators/rails/plugin/plugin_generator.rb', line 224

def create_test_files
  build(:test) unless options[:skip_test_unit]
end

#finish_templateObject


237
238
239
# File 'railties/lib/rails/generators/rails/plugin/plugin_generator.rb', line 237

def finish_template
  build(:leftovers)
end

#nameObject


243
244
245
246
247
248
249
250
251
252
253
# File 'railties/lib/rails/generators/rails/plugin/plugin_generator.rb', line 243

def name
  @name ||= begin
    # same as ActiveSupport::Inflector#underscore except not replacing '-'
    underscored = original_name.dup
    underscored.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
    underscored.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
    underscored.downcase!

    underscored
  end
end

#update_gemfileObject


233
234
235
# File 'railties/lib/rails/generators/rails/plugin/plugin_generator.rb', line 233

def update_gemfile
  build(:gemfile_entry) unless options[:skip_gemfile_entry]
end