Class: Rails::PluginBuilder
- Defined in:
- railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb
Constant Summary collapse
- PASSTHROUGH_OPTIONS =
[ :skip_active_record, :skip_javascript, :database, :javascript, :quiet, :pretend, :force, :skip ]
Instance Method Summary collapse
- #app ⇒ Object
- #config ⇒ Object
- #gemfile ⇒ Object
- #gemspec ⇒ Object
- #generate_test_dummy(force = false) ⇒ Object
- #gitignore ⇒ Object
- #javascripts ⇒ Object
- #lib ⇒ Object
- #license ⇒ Object
- #rakefile ⇒ Object
- #readme ⇒ Object
- #script(force = false) ⇒ Object
- #stylesheets ⇒ Object
- #test ⇒ Object
- #test_dummy_clean ⇒ Object
- #test_dummy_config ⇒ Object
Instance Method Details
#app ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb', line 11 def app if mountable? directory "app" empty_directory_with_gitkeep "app/assets/images/#{name}" elsif full? empty_directory_with_gitkeep "app/models" empty_directory_with_gitkeep "app/controllers" empty_directory_with_gitkeep "app/views" empty_directory_with_gitkeep "app/helpers" empty_directory_with_gitkeep "app/mailers" empty_directory_with_gitkeep "app/assets/images/#{name}" end end |
#config ⇒ Object
54 55 56 |
# File 'railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb', line 54 def config template "config/routes.rb" if full? end |
#gemfile ⇒ Object
29 30 31 |
# File 'railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb', line 29 def gemfile template "Gemfile" end |
#gemspec ⇒ Object
37 38 39 |
# File 'railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb', line 37 def gemspec template "%name%.gemspec" end |
#generate_test_dummy(force = false) ⇒ Object
75 76 77 78 79 80 81 82 |
# File 'railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb', line 75 def generate_test_dummy(force = false) opts = ( || {}).slice(*PASSTHROUGH_OPTIONS) opts[:force] = force opts[:skip_bundle] = true invoke Rails::Generators::AppGenerator, [ File.(dummy_path, destination_root) ], opts end |
#gitignore ⇒ Object
41 42 43 |
# File 'railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb', line 41 def gitignore copy_file "gitignore", ".gitignore" end |
#javascripts ⇒ Object
117 118 119 120 121 122 123 124 125 126 |
# File 'railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb', line 117 def javascripts return if .skip_javascript? if mountable? template "#{app_templates_dir}/app/assets/javascripts/application.js.tt", "app/assets/javascripts/#{name}/application.js" elsif full? empty_directory_with_gitkeep "app/assets/javascripts/#{name}" end end |
#lib ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb', line 45 def lib template "lib/%name%.rb" template "lib/tasks/%name%_tasks.rake" template "lib/%name%/version.rb" if full? template "lib/%name%/engine.rb" end end |
#license ⇒ Object
33 34 35 |
# File 'railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb', line 33 def license template "MIT-LICENSE" end |
#rakefile ⇒ Object
7 8 9 |
# File 'railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb', line 7 def rakefile template "Rakefile" end |
#readme ⇒ Object
25 26 27 |
# File 'railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb', line 25 def readme template "README.rdoc" end |
#script(force = false) ⇒ Object
128 129 130 131 132 133 134 135 |
# File 'railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb', line 128 def script(force = false) return unless full? directory "script", :force => force do |content| "#{shebang}\n" + content end chmod "script", 0755, :verbose => false end |
#stylesheets ⇒ Object
108 109 110 111 112 113 114 115 |
# File 'railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb', line 108 def stylesheets if mountable? copy_file "#{app_templates_dir}/app/assets/stylesheets/application.css", "app/assets/stylesheets/#{name}/application.css" elsif full? empty_directory_with_gitkeep "app/assets/stylesheets/#{name}" end end |
#test ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb', line 58 def test template "test/test_helper.rb" template "test/%name%_test.rb" append_file "Rakefile", <<-EOF #{rakefile_test_tasks} task :default => :test EOF if full? template "test/integration/navigation_test.rb" end end |
#test_dummy_clean ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb', line 92 def test_dummy_clean inside dummy_path do remove_file ".gitignore" remove_file "db/seeds.rb" remove_file "doc" remove_file "Gemfile" remove_file "lib/tasks" remove_file "app/assets/images/rails.png" remove_file "public/index.html" remove_file "public/robots.txt" remove_file "README" remove_file "test" remove_file "vendor" end end |
#test_dummy_config ⇒ Object
84 85 86 87 88 89 90 |
# File 'railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb', line 84 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 |