Methods
- A
- B
- C
- D
- F
- G
- M
- N
- O
- R
- S
- V
Class Public methods
# File railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb, line 157 157: def initialize(*args) 158: raise Error, "Options should be given after the plugin name. For details run: rails plugin --help" if args[0].blank? 159: 160: @dummy_path = nil 161: super 162: end
Class Protected methods
Instance Public methods
# File railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb, line 166 166: def create_root_files 167: build(:readme) 168: build(:rakefile) 169: build(:gemspec) unless options[:skip_gemspec] 170: build(:license) 171: build(:gitignore) unless options[:skip_git] 172: build(:gemfile) unless options[:skip_gemfile] 173: end
Instance Protected methods
This method is also aliased as
store_application_definition!
# File railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb, line 280 280: def application_definition 281: @application_definition ||= begin 282: 283: dummy_application_path = File.expand_path("#{dummy_path}/config/application.rb", destination_root) 284: unless options[:pretend] || !File.exists?(dummy_application_path) 285: contents = File.read(dummy_application_path) 286: contents[(contents.index("module Dummy"))..-1] 287: end 288: end 289: end
# File railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb, line 224 224: def create_dummy_app(path = nil) 225: dummy_path(path) if path 226: 227: say_status :vendor_app, dummy_path 228: mute do 229: build(:generate_test_dummy) 230: store_application_definition! 231: build(:test_dummy_config) 232: build(:test_dummy_clean) 233: # ensure that script/rails has proper dummy_path 234: build(:script, true) 235: end 236: end
# File railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb, line 254 254: def name 255: @name ||= begin 256: # same as ActiveSupport::Inflector#underscore except not replacing '-' 257: underscored = original_name.dup 258: underscored.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2') 259: underscored.gsub!(/([a-z\d])([A-Z])/,'\1_\2') 260: underscored.downcase! 261: 262: underscored 263: end 264: end
# File railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb, line 296 296: def rakefile_test_tasks 297: "require 'rake/testtask'\n\nRake::TestTask.new(:test) do |t|\nt.libs << 'lib'\nt.libs << 'test'\nt.pattern = 'test/**/*_test.rb'\nt.verbose = false\nend\n" 298: end
Alias for application_definition
# File railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb, line 270 270: def valid_const? 271: if camelized =~ /^\d/ 272: raise Error, "Invalid plugin name #{original_name}. Please give a name which does not start with numbers." 273: elsif RESERVED_NAMES.include?(name) 274: raise Error, "Invalid plugin name #{original_name}. Please give a name which does not match one of the reserved rails words." 275: elsif Object.const_defined?(camelized) 276: raise Error, "Invalid plugin name #{original_name}, constant #{camelized} is already in use. Please choose another plugin name." 277: end 278: end