Class: Godmin::InstallGenerator

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

Instance Method Summary collapse

Methods inherited from Generators::Base

source_paths

Instance Method Details

#create_navigationObject



12
13
14
# File 'lib/generators/godmin/install/install_generator.rb', line 12

def create_navigation
  create_file File.join("app/views", namespaced_path, "shared/_navigation.html.erb")
end

#create_routesObject



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_controllerObject



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_cssObject



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_jsObject



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_layoutsObject



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_namespacedObject



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