Class: Kaui::InstallGenerator

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_pathsObject



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.expand_path('../templates', "../../#{__FILE__}")
  paths << File.expand_path('../templates', "../#{__FILE__}")
  paths << File.expand_path('../templates', __FILE__)
  paths.flatten
end

Instance Method Details

#add_filesObject



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_tweaksObject



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

#completeObject



59
60
61
62
63
64
65
66
# File 'lib/generators/kaui/install/install_generator.rb', line 59

def complete
  unless options[:quiet]
    puts "*" * 50
    puts "Kaui has been installed successfully. You're all ready to go!"
    puts " "
    puts "Enjoy!"
  end
end

#config_kaui_ymlObject



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_assetsObject



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_routesObject



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