Class: Livequery::Generators::InstallGenerator

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

Instance Method Summary collapse

Instance Method Details

#add_assetsObject



26
27
28
# File 'lib/generators/livequery/install/install_generator.rb', line 26

def add_assets
  insert_into_file "app/assets/javascripts/application#{detect_js_format[0]}", "#{detect_js_format[1]} require livequery\n", :after => "jquery_ujs\n"
end

#copy_livequeryObject



12
13
14
15
16
# File 'lib/generators/livequery/install/install_generator.rb', line 12

def copy_livequery
  say_status("copying", "livequery (#{Livequery::Rails::LIVEQUERY_VERSION})", :green)
  copy_file "livequery.js", "public/javascripts/Livequery.js"
  copy_file "livequery.min.js", "public/javascripts/Livequery.min.js"
end

#detect_js_formatObject



30
31
32
33
# File 'lib/generators/livequery/install/install_generator.rb', line 30

def detect_js_format
  return ['.js.coffee', '#='] if File.exist?('app/assets/javascripts/application.js.coffee')
  return ['.js', '//='] if File.exist?('app/assets/javascripts/application.js')
end