Class: Godmin::InstallGenerator
- Inherits:
-
Generators::Base
- Object
- Rails::Generators::Base
- Generators::Base
- Godmin::InstallGenerator
- Defined in:
- lib/generators/godmin/install/install_generator.rb
Instance Method Summary collapse
- #create_navigation ⇒ Object
- #create_routes ⇒ Object
- #modify_application_controller ⇒ Object
- #modify_application_css ⇒ Object
- #modify_application_js ⇒ Object
- #remove_layouts ⇒ Object
- #require_library_if_namespaced ⇒ Object
Methods inherited from Generators::Base
Instance Method Details
#create_navigation ⇒ Object
12 13 14 |
# File 'lib/generators/godmin/install/install_generator.rb', line 12 def create_file File.join("app/views", namespaced_path, "shared/_navigation.html.erb") end |
#create_routes ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/generators/godmin/install/install_generator.rb', line 4 def create_routes inject_into_file "config/routes.rb", before: /^end/ do <<-END.strip_heredoc.indent(2) root to: "application#welcome" END end end |
#modify_application_controller ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/generators/godmin/install/install_generator.rb', line 16 def modify_application_controller inject_into_file File.join("app/controllers", namespaced_path, "application_controller.rb"), after: "ActionController::Base\n" do <<-END.strip_heredoc.indent(namespace ? 4 : 2) include Godmin::ApplicationController END end end |
#modify_application_css ⇒ Object
38 39 40 41 42 |
# File 'lib/generators/godmin/install/install_generator.rb', line 38 def modify_application_css inject_into_file File.join("app/assets/stylesheets", namespaced_path, "application.css"), before: " *= require_tree ." do " *= require godmin\n" end end |
#modify_application_js ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/generators/godmin/install/install_generator.rb', line 24 def modify_application_js application_js = File.join("app/assets/javascripts", namespaced_path, "application.js") inject_into_file application_js, before: "//= require_tree ." do <<-END.strip_heredoc //= require moment //= require moment/en-gb //= require godmin END end gsub_file application_js, /\/\/= require turbolinks\n/, "" end |
#remove_layouts ⇒ Object
54 55 56 |
# File 'lib/generators/godmin/install/install_generator.rb', line 54 def remove_layouts remove_dir "app/views/layouts" end |
#require_library_if_namespaced ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/generators/godmin/install/install_generator.rb', line 44 def require_library_if_namespaced return unless namespaced? inject_into_file File.join("lib", namespaced_path) + ".rb", before: "require" do <<-END.strip_heredoc require "godmin" END end end |