Class: Awe::Generators::UpdateGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/awe/update/update_generator.rb

Constant Summary collapse

@@github =
"https://raw.github.com/sambaker/awe-core/master"

Instance Method Summary collapse

Instance Method Details

#download_and_copy_aweObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/generators/awe/update/update_generator.rb', line 14

def download_and_copy_awe
  files = []
  javascripts_path = ::Rails.application.config.assets.enabled ? "vendor/assets/javascripts" : "public/javascripts"
  
  say_status("getting", "The AWE file list from #{@@github}/ ...", :green)
  open("#{@@github}/files") { |f|
    f.each_line { |line| files.push(line.strip) unless line.starts_with?("#") }
  }

  # fetch files
  files.each { |file| 
    say_status("fetching", "#{@@github}/#{file} into #{javascripts_path} ...", :green)
    get "#{@@github}/#{file}", "#{javascripts_path}/#{file}"
  }

rescue OpenURI::HTTPError
  say_status("error", "error fetching files", :red)
end