Class: Ratchet::Generators::InstallGenerator

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

Instance Method Summary collapse

Instance Method Details

#add_assetsObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/generators/ratchet/install/install_generator.rb', line 30

def add_assets
  if File.exist?('app/assets/javascripts/application.js')
    insert_into_file "app/assets/javascripts/application.js", "//= require ratchet\n", :after => "//= require jquery_ujs\n"
  else
    copy_file "application.js", "app/assets/javascripts/application.js"
  end

  if File.exist?('app/assets/stylesheets/application.css')
    # Add our own require:
    content = File.read("app/assets/stylesheets/application.css")
    if content.match(/require_tree\s+\.\s*$/)
      # Good enough - that'll include our ratchet.css.less
    else
      style_require_block = " *= require ratchet\n"
      insert_into_file "app/assets/stylesheets/application.css", style_require_block, :after => "require_self\n"
    end
  else
    copy_file "application.css", "app/assets/stylesheets/application.css"
  end
end

#add_ratchetObject



51
52
53
54
# File 'lib/generators/ratchet/install/install_generator.rb', line 51

def add_ratchet
  copy_file "ratchet.js",  "app/assets/javascripts/ratchet.js"
  copy_file "ratchet.css", "app/assets/stylesheets/ratchet.css"
end

#copy_ratchet_javascriptsObject



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

def copy_ratchet_javascripts
  say_status("copying", "Ratchet javascript (#{Ratchet::Rails::RATCHET_VERSION})", :green)
  copy_file "ratchet.js", "public/javascripts/ratchet.js"
end

#copy_ratchet_stylesheetsObject



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

def copy_ratchet_stylesheets
  say_status("copying", "Ratchet stylesheet (#{Ratchet::Rails::RATCHET_VERSION})", :green)
  copy_file "ratchet.css", "public/stylesheets/ratchet.css"
end