Class: Kaui::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Kaui::InstallGenerator
- Defined in:
- lib/generators/kaui/install/install_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add_files ⇒ Object
- #additional_tweaks ⇒ Object
- #complete ⇒ Object
- #config_kaui_yml ⇒ Object
- #setup_assets ⇒ Object
- #update_routes ⇒ Object
Class Method Details
.source_paths ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/generators/kaui/install/install_generator.rb', line 8 def self.source_paths paths = self.superclass.source_paths paths << File.('../templates', "../../#{__FILE__}") paths << File.('../templates', "../#{__FILE__}") paths << File.('../templates', __FILE__) paths.flatten end |
Instance Method Details
#add_files ⇒ Object
16 17 18 |
# File 'lib/generators/kaui/install/install_generator.rb', line 16 def add_files template 'config/initializers/kaui.rb', 'config/initializers/kaui.rb' end |
#additional_tweaks ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/generators/kaui/install/install_generator.rb', line 28 def additional_tweaks return unless File.exists? 'public/robots.txt' append_file "public/robots.txt", <<-ROBOTS User-agent: * Disallow: /kaui ROBOTS end |
#complete ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'lib/generators/kaui/install/install_generator.rb', line 59 def complete unless [:quiet] puts "*" * 50 puts "Kaui has been installed successfully. You're all ready to go!" puts " " puts "Enjoy!" end end |
#config_kaui_yml ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/generators/kaui/install/install_generator.rb', line 20 def config_kaui_yml create_file "config/kaui.yml" do settings = { 'version' => Kaui::VERSION } settings.to_yaml end end |
#setup_assets ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/generators/kaui/install/install_generator.rb', line 36 def setup_assets @lib_name = 'kaui' %w{javascripts stylesheets images}.each do |path| empty_directory "app/assets/#{path}/kaui" end template "app/assets/javascripts/kaui/all.js" template "app/assets/stylesheets/kaui/all.css" end |
#update_routes ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/generators/kaui/install/install_generator.rb', line 46 def update_routes insert_into_file File.join('config', 'routes.rb'), :after => "Application.routes.draw do\n" do %Q{ # This line mounts Kaui's routes at the root of your application. # If you're mounting this engine into an existing application, change it to e.g. # mount Kaui::Engine, :at => '/kaui', :as => "kaui_engine" # # Don't modify the :as => "kaui_engine" option though. mount Kaui::Engine, :at => '/', :as => "kaui_engine" } end end |