Class: Godmin::InstallGenerator

Inherits:
Generators::Base show all
Defined in:
lib/generators/godmin/install/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_initializerObject



4
5
6
7
8
9
10
11
12
# File 'lib/generators/godmin/install/install_generator.rb', line 4

def create_initializer
  create_file "config/initializers/godmin.rb" do
    "      Godmin.configure do |config|\n        config.namespace = \#{namespace ? \"\\\"\#{namespace}\\\"\" : \"nil\"}\n      end\n    END\n  end\nend\n".strip_heredoc

#create_routesObject



14
15
16
17
18
19
20
21
# File 'lib/generators/godmin/install/install_generator.rb', line 14

def create_routes
  inject_into_file "config/routes.rb", before: /^end/ do
    "      godmin do\n      end\n    END\n  end\nend\n".strip_heredoc.indent(2)

#modify_application_controllerObject



23
24
25
26
27
28
29
# File 'lib/generators/godmin/install/install_generator.rb', line 23

def modify_application_controller
  inject_into_file ["app/controllers", namespace, "application_controller.rb"].compact.join("/"), after: "ActionController::Base\n" do
    "      include Godmin::Application\n    END\n  end\nend\n".strip_heredoc.indent(namespace == nil ? 2 : 4)

#remove_layoutsObject



41
42
43
# File 'lib/generators/godmin/install/install_generator.rb', line 41

def remove_layouts
  remove_dir "app/views/layouts"
end

#require_library_if_namespacedObject



31
32
33
34
35
36
37
38
39
# File 'lib/generators/godmin/install/install_generator.rb', line 31

def require_library_if_namespaced
  return unless namespace

  inject_into_file "lib/#{namespace}.rb", before: "require" do
    "      require \"godmin\"\n    END\n  end\nend\n".strip_heredoc