Class: BootstrapAdmin::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/bootstrap_admin/install/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#append_to_assetsObject



20
21
22
23
# File 'lib/generators/bootstrap_admin/install/install_generator.rb', line 20

def append_to_assets
  append_file "config/initializers/assets.rb",
              "Rails.application.config.assets.precompile += %w( admin.css admin.js )"
end

#asset_configurationObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/generators/bootstrap_admin/install/install_generator.rb', line 25

def asset_configuration
  empty_directory "app/assets/javascripts/#{namespace_parsed}"
  create_file "app/assets/javascripts/#{namespace_parsed}.js" do
    <<-JS_INFO.strip_heredoc
      // Loads all bootstrap_admin javascripts
      //= require bootstrap_admin
      //= require_tree ./#{namespace_parsed}
    JS_INFO
  end

  empty_directory "app/assets/stylesheets/#{namespace_parsed}"
  create_file "app/assets/stylesheets/#{namespace_parsed}.css" do
    <<-CSS_INFO.strip_heredoc
      /*
       *= require bootstrap_admin.css
       *= require_self
       *= require_tree ./#{namespace_parsed}
       */
    CSS_INFO
  end
end

#copy_bootstrap_admin_menuObject



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

def copy_bootstrap_admin_menu
  copy_file "bootstrap_admin_menu.yml", "config/bootstrap_admin_menu.yml"
end

#copy_initializerObject



8
9
10
# File 'lib/generators/bootstrap_admin/install/install_generator.rb', line 8

def copy_initializer
  template "bootstrap_admin.rb", "config/initializers/bootstrap_admin.rb"
end

#copy_locale_fileObject



16
17
18
# File 'lib/generators/bootstrap_admin/install/install_generator.rb', line 16

def copy_locale_file
  copy_file "en_bootstrap_admin.yml", "config/locales/en_bootstrap_admin.yml"
end

#create_admin_controllerObject



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/generators/bootstrap_admin/install/install_generator.rb', line 47

def create_admin_controller
  create_file "app/controllers/#{namespace_parsed}_controller.rb" do
    <<-RUBY.strip_heredoc
      class #{options.namespace.classify}Controller < ApplicationController
        layout "bootstrap_admin"
        helper "bootstrap_admin"
        helper "bootstrap_admin/menu"
        helper "bootstrap_admin/paginator"
      end
    RUBY
  end

  create_file "app/views/#{namespace_parsed}/show.html.haml" do
    <<-HAML.strip_heredoc
      %p Hello!
      %p Find me @ app/views/#{namespace_parsed}/show.html.haml
    HAML
  end
end