Class: Aloha::InstallGenerator

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

Instance Method Summary collapse

Instance Method Details

#copy_assetObject



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

def copy_asset
  if options[:js]
    template "aloha-config.js", File.join("app", "assets", "javascripts", "aloha-config.js")
  else
    template "aloha-config.coffee", File.join("app", "assets", "javascripts", "aloha-config.coffee")
  end
end

#copy_initializerObject



13
14
15
# File 'lib/generators/aloha/install/install_generator.rb', line 13

def copy_initializer
  template "aloha.rb", File.join("config", "initializers", "aloha.rb")
end

#load_javascriptObject



17
18
19
20
21
22
23
24
# File 'lib/generators/aloha/install/install_generator.rb', line 17

def load_javascript
  appjs = File.join "app", "assets", "javascripts", "application.js"
  if File.exist? appjs
    insert_into_file appjs, "//= require aloha-config\n", :after => "jquery_ujs\n"
  else
    copy_file "application.js", appjs
  end
end

#load_stylesheetObject



26
27
28
29
30
31
32
33
# File 'lib/generators/aloha/install/install_generator.rb', line 26

def load_stylesheet
  appcss = File.join "app", "assets", "stylesheets", "application.css"
  if File.exist? appcss
    insert_into_file appcss, " *= require aloha-config\n", :after => "require_self\n"
  else
    copy_file "application.css", appcss
  end
end