Class: Rails::Generators::PluginGenerator

Inherits:
AppBase
  • Object
show all
Defined in:
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, strict_args_position

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, #after_bundle, #capify!, #environment, #gem, #gem_group, #generate, #git, #initializer, #lib, #rails_command, #rake, #rakefile, #readme, #route, #vendor

Constructor Details

#initialize(*args) ⇒ PluginGenerator

Returns a new instance of PluginGenerator.



201
202
203
204
# File 'lib/rails/generators/rails/plugin/plugin_generator.rb', line 201

def initialize(*args)
  @dummy_path = nil
  super
end

Instance Method Details

#create_app_filesObject



218
219
220
# File 'lib/rails/generators/rails/plugin/plugin_generator.rb', line 218

def create_app_files
  build(:app)
end

#create_assets_manifest_fileObject



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

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

#create_bin_filesObject



242
243
244
# File 'lib/rails/generators/rails/plugin/plugin_generator.rb', line 242

def create_bin_files
  build(:bin)
end

#create_config_filesObject



222
223
224
# File 'lib/rails/generators/rails/plugin/plugin_generator.rb', line 222

def create_config_files
  build(:config)
end

#create_javascript_filesObject



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

def create_javascript_files
  build(:javascripts) unless api?
end

#create_lib_filesObject



226
227
228
# File 'lib/rails/generators/rails/plugin/plugin_generator.rb', line 226

def create_lib_files
  build(:lib)
end

#create_public_stylesheets_filesObject



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

def create_public_stylesheets_files
  build(:stylesheets) unless api?
end

#create_root_filesObject



209
210
211
212
213
214
215
216
# File 'lib/rails/generators/rails/plugin/plugin_generator.rb', line 209

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



250
251
252
253
# File 'lib/rails/generators/rails/plugin/plugin_generator.rb', line 250

def create_test_dummy_files
  return unless with_dummy_app?
  create_dummy_app
end

#create_test_filesObject



246
247
248
# File 'lib/rails/generators/rails/plugin/plugin_generator.rb', line 246

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

#finish_templateObject



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

def finish_template
  build(:leftovers)
end

#nameObject



275
276
277
278
279
280
281
282
283
284
285
# File 'lib/rails/generators/rails/plugin/plugin_generator.rb', line 275

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



291
292
293
# File 'lib/rails/generators/rails/plugin/plugin_generator.rb', line 291

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

#run_after_bundle_callbacksObject



265
266
267
268
269
270
271
272
273
# File 'lib/rails/generators/rails/plugin/plugin_generator.rb', line 265

def run_after_bundle_callbacks
  unless @after_bundle_callbacks.empty?
    ActiveSupport::Deprecation.warn("`after_bundle` is deprecated and will be removed in the next version of Rails. ")
  end

  @after_bundle_callbacks.each do |callback|
    callback.call
  end
end

#underscored_nameObject



287
288
289
# File 'lib/rails/generators/rails/plugin/plugin_generator.rb', line 287

def underscored_name
  @underscored_name ||= original_name.underscore
end

#update_gemfileObject



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

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