The plugin builder allows you to override elements of the plugin generator without being forced to reverse the operations of the default generator.
This allows you to override entire operations, like the creation of the Gemfile, README, or JavaScript files, without needing to know exactly what those operations do so you can create another template action.
Methods
- A
- B
- C
- G
- J
- L
- R
- S
- T
Constants
PASSTHROUGH_OPTIONS | = | [ :skip_active_record, :skip_action_mailer, :skip_javascript, :skip_sprockets, :database, :javascript, :quiet, :pretend, :force, :skip ] |
Instance Public methods
app()
Link
# File railties/lib/rails/generators/rails/plugin/plugin_generator.rb, line 18 def app if mountable? if api? directory "app", exclude_pattern: %r{app/(views|helpers)} else directory "app" empty_directory_with_keep_file "app/assets/images/#{namespaced_name}" end elsif full? empty_directory_with_keep_file "app/models" empty_directory_with_keep_file "app/controllers" empty_directory_with_keep_file "app/mailers" unless api? empty_directory_with_keep_file "app/assets/images/#{namespaced_name}" empty_directory_with_keep_file "app/helpers" empty_directory_with_keep_file "app/views" end end end
assets_manifest()
Link
bin(force = false)
Link
config()
Link
gemfile()
Link
gemfile_entry()
Link
# File railties/lib/rails/generators/rails/plugin/plugin_generator.rb, line 160 def gemfile_entry return unless inside_application? gemfile_in_app_path = File.join(rails_app_path, "Gemfile") if File.exist? gemfile_in_app_path entry = "gem '#{name}', path: '#{relative_path}'" append_file gemfile_in_app_path, entry end end
gemspec()
Link
generate_test_dummy(force = false)
Link
# File railties/lib/rails/generators/rails/plugin/plugin_generator.rb, line 88 def generate_test_dummy(force = false) opts = (options || {}).slice(*PASSTHROUGH_OPTIONS) opts[:force] = force opts[:skip_bundle] = true opts[:api] = options.api? opts[:skip_listen] = true opts[:skip_git] = true opts[:skip_turbolinks] = true invoke Rails::Generators::AppGenerator, [ File.expand_path(dummy_path, destination_root) ], opts end
gitignore()
Link
javascripts()
Link
# File railties/lib/rails/generators/rails/plugin/plugin_generator.rb, line 141 def javascripts return if options.skip_javascript? if mountable? template "rails/javascripts.js", "app/assets/javascripts/#{namespaced_name}/application.js" elsif full? empty_directory_with_keep_file "app/assets/javascripts/#{namespaced_name}" end end
lib()
Link
license()
Link
rakefile()
Link
readme()
Link
stylesheets()
Link
# File railties/lib/rails/generators/rails/plugin/plugin_generator.rb, line 132 def stylesheets if mountable? copy_file "rails/stylesheets.css", "app/assets/stylesheets/#{namespaced_name}/application.css" elsif full? empty_directory_with_keep_file "app/assets/stylesheets/#{namespaced_name}" end end
test()
Link
# File railties/lib/rails/generators/rails/plugin/plugin_generator.rb, line 70 def test template "test/test_helper.rb" template "test/%namespaced_name%_test.rb" append_file "Rakefile", <<-EOF #{rakefile_test_tasks} task default: :test EOF if engine? template "test/integration/navigation_test.rb" end end
test_dummy_assets()
Link
# File railties/lib/rails/generators/rails/plugin/plugin_generator.rb, line 109 def test_dummy_assets template "rails/javascripts.js", "#{dummy_path}/app/assets/javascripts/application.js", force: true template "rails/stylesheets.css", "#{dummy_path}/app/assets/stylesheets/application.css", force: true template "rails/dummy_manifest.js", "#{dummy_path}/app/assets/config/manifest.js", force: true end
test_dummy_clean()
Link
# File railties/lib/rails/generators/rails/plugin/plugin_generator.rb, line 115 def test_dummy_clean inside dummy_path do remove_file "db/seeds.rb" remove_file "doc" remove_file "Gemfile" remove_file "lib/tasks" remove_file "public/robots.txt" remove_file "README.md" remove_file "test" remove_file "vendor" end end
test_dummy_config()
Link
# File railties/lib/rails/generators/rails/plugin/plugin_generator.rb, line 101 def test_dummy_config template "rails/boot.rb", "#{dummy_path}/config/boot.rb", force: true template "rails/application.rb", "#{dummy_path}/config/application.rb", force: true if mountable? template "rails/routes.rb", "#{dummy_path}/config/routes.rb", force: true end end