Class: Batman::Generators::AppGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Batman::Generators::AppGenerator
- Includes:
- Common
- Defined in:
- lib/generators/batman/app_generator.rb
Instance Method Summary collapse
- #app_requires ⇒ Object
- #batman_requires ⇒ Object
- #create_app ⇒ Object
- #create_default_controllers ⇒ Object
- #create_directories ⇒ Object
- #es5_requires ⇒ Object
- #inject_batman ⇒ Object
- #jquery_requires ⇒ Object
- #route_catchall ⇒ Object
- #setup_rails ⇒ Object
Methods included from Common
Instance Method Details
#app_requires ⇒ Object
94 95 96 97 98 99 100 101 102 103 |
# File 'lib/generators/batman/app_generator.rb', line 94 def app_requires "#= require_self\n\n#= require_tree ./lib\n#= require_tree ./controllers\n#= require_tree ./models\n#= require_tree ./views\\n\n" end |
#batman_requires ⇒ Object
80 81 82 83 84 85 |
# File 'lib/generators/batman/app_generator.rb', line 80 def batman_requires "#= require batman/batman\n#= require batman/batman.rails\\n\n" end |
#create_app ⇒ Object
34 35 36 37 38 |
# File 'lib/generators/batman/app_generator.rb', line 34 def create_app with_app_name do template "batman/batman_app.coffee", "#{app_path}/#{application_name}.js.coffee" end end |
#create_default_controllers ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/generators/batman/app_generator.rb', line 47 def create_default_controllers with_app_name do empty_directory "#{app_path}/html/main" template "batman/application_controller.coffee", "#{app_path}/controllers/application_controller.js.coffee" template "batman/main_controller.coffee", "#{app_path}/controllers/main_controller.js.coffee" template "batman/html/main_index.html", "#{app_path}/html/main/index.html" end end |
#create_directories ⇒ Object
40 41 42 43 44 45 |
# File 'lib/generators/batman/app_generator.rb', line 40 def create_directories %w(models views controllers html lib).each do |dir| empty_directory "#{app_path}/#{dir}" create_file "#{app_path}/#{dir}/.gitkeep" unless [:skip_git] end end |
#es5_requires ⇒ Object
74 75 76 77 78 |
# File 'lib/generators/batman/app_generator.rb', line 74 def es5_requires "#= require batman/es5-shim\\n\n" end |
#inject_batman ⇒ Object
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/generators/batman/app_generator.rb', line 57 def inject_batman with_app_name do application_file = File.join(app_path, "#{application_name}.js.coffee") prepend_file application_file, app_requires prepend_file application_file, jquery_requires unless [:skip_jquery] prepend_file application_file, batman_requires prepend_file application_file, es5_requires unless [:skip_es5] end end |
#jquery_requires ⇒ Object
87 88 89 90 91 92 |
# File 'lib/generators/batman/app_generator.rb', line 87 def jquery_requires "#= require jquery\n#= require batman/batman.jquery\\n\n" end |
#route_catchall ⇒ Object
68 69 70 71 72 |
# File 'lib/generators/batman/app_generator.rb', line 68 def route_catchall "\\n get \"(*redirect_path)\", to: \"\#{app_name}\\#index\", constraints: lambda { |request| request.format == \"text/html\" }\\n\n" end |
#setup_rails ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/generators/batman/app_generator.rb', line 20 def setup_rails with_app_name do template "rails/controller.rb", "app/controllers/#{app_name}_controller.rb" template "rails/layout.html", "app/views/layouts/#{app_name}.html.erb" unless ENV["RAILS_ENV"] == "test" inject_into_file "config/routes.rb", :after => "#{js_application_name}::Application.routes.draw do\n" do route_catchall end end end end |