Sha256: 08f90c0f837664e5f112bc5b3a9d45ea9c9b12175b81fec3d52b58c48cebb99d
Contents?: true
Size: 1.48 KB
Versions: 3
Compression:
Stored size: 1.48 KB
Contents
require "godmin/generators/base" class Godmin::InstallGenerator < Godmin::Generators::Base def create_initializer create_file "config/initializers/godmin.rb" do <<-END.strip_heredoc Godmin.configure do |config| config.namespace = #{namespace ? "\"#{namespaced_path.join("/")}\"" : "nil"} end END end end def create_routes inject_into_file "config/routes.rb", before: /^end/ do <<-END.strip_heredoc.indent(2) godmin do end END end end 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 def modify_application_js inject_into_file File.join("app/assets/javascripts", namespaced_path, "application.js"), before: "//= require_tree ." do "//= require godmin\n" end end 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 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 def remove_layouts remove_dir "app/views/layouts" end end
Version data entries
3 entries across 3 versions & 1 rubygems