Class: Rails::Generators::PluginGenerator

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

Overview

:nodoc:

Constant Summary

Constants included from AppName

AppName::RESERVED_NAMES

Constants included from Database

Database::DATABASES, Database::JDBC_DATABASES

Instance Attribute Summary

Attributes inherited from AppBase

#rails_template

Instance Method Summary collapse

Methods inherited from AppBase

add_shared_options_for, strict_args_position

Methods included from Database

#convert_database_option_for_jruby, #gem_for_database

Methods inherited from Base

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

Methods included from Actions

#add_source, #environment, #gem, #gem_group, #generate, #git, #github, #initializer, #lib, #rails_command, #rake, #rakefile, #readme, #route, #vendor

Constructor Details

#initialize(*args) ⇒ PluginGenerator

Returns a new instance of PluginGenerator.


218
219
220
221
222
223
224
225
# File 'railties/lib/rails/generators/rails/plugin/plugin_generator.rb', line 218

def initialize(*args)
  @dummy_path = nil
  super

  if !engine? || !with_dummy_app?
    self.options = options.merge(skip_asset_pipeline: true).freeze
  end
end

Instance Method Details

#create_app_filesObject


244
245
246
# File 'railties/lib/rails/generators/rails/plugin/plugin_generator.rb', line 244

def create_app_files
  build(:app)
end

#create_assets_manifest_fileObject


256
257
258
# File 'railties/lib/rails/generators/rails/plugin/plugin_generator.rb', line 256

def create_assets_manifest_file
  build(:assets_manifest) if !api? && engine?
end

#create_bin_filesObject


264
265
266
# File 'railties/lib/rails/generators/rails/plugin/plugin_generator.rb', line 264

def create_bin_files
  build(:bin)
end

#create_config_filesObject


248
249
250
# File 'railties/lib/rails/generators/rails/plugin/plugin_generator.rb', line 248

def create_config_files
  build(:config)
end

#create_lib_filesObject


252
253
254
# File 'railties/lib/rails/generators/rails/plugin/plugin_generator.rb', line 252

def create_lib_files
  build(:lib)
end

#create_public_stylesheets_filesObject


260
261
262
# File 'railties/lib/rails/generators/rails/plugin/plugin_generator.rb', line 260

def create_public_stylesheets_files
  build(:stylesheets) unless api?
end

#create_root_filesObject


234
235
236
237
238
239
240
241
242
# File 'railties/lib/rails/generators/rails/plugin/plugin_generator.rb', line 234

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

#create_test_dummy_filesObject


272
273
274
275
# File 'railties/lib/rails/generators/rails/plugin/plugin_generator.rb', line 272

def create_test_dummy_files
  return unless with_dummy_app?
  create_dummy_app
end

#create_test_filesObject


268
269
270
# File 'railties/lib/rails/generators/rails/plugin/plugin_generator.rb', line 268

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

#finish_templateObject


281
282
283
# File 'railties/lib/rails/generators/rails/plugin/plugin_generator.rb', line 281

def finish_template
  build(:leftovers)
end

#nameObject


287
288
289
290
291
292
293
294
295
296
297
# File 'railties/lib/rails/generators/rails/plugin/plugin_generator.rb', line 287

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

#namespaced_nameObject


303
304
305
# File 'railties/lib/rails/generators/rails/plugin/plugin_generator.rb', line 303

def namespaced_name
  @namespaced_name ||= name.tr("-", "/")
end

#target_rails_prereleaseObject


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

def target_rails_prerelease
  super("plugin new")
end

#underscored_nameObject


299
300
301
# File 'railties/lib/rails/generators/rails/plugin/plugin_generator.rb', line 299

def underscored_name
  @underscored_name ||= original_name.underscore
end

#update_gemfileObject


277
278
279
# File 'railties/lib/rails/generators/rails/plugin/plugin_generator.rb', line 277

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