20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/generators/voltron/js/install_generator.rb', line 20
def install_modules
if modules.empty?
puts "Please specify one or more modules to install, e.g. - `rails g voltron:js:install dialog [--version=0.1.0]`"
return false
end
FileUtils.mkdir_p(TEMP_DIR) unless File.directory?(TEMP_DIR)
modules.each do |mod|
library = "voltron-#{mod.downcase}.js"
version = options.version == "master" ? "master" : "v" + options.version.gsub(/[^0-9\.]/, "")
asset = ASSET_URL % { version: version, library: library }
begin
download = open(asset)
tmp = TEMP_DIR.join(library)
IO.copy_stream(download, tmp)
copy_file tmp, Rails.root.join("app", "assets", "javascripts", library)
rescue OpenURI::HTTPError => e
puts "Module '#{mod}' not found. Are you sure the version exists and that you typed the name correctly? (Lookup URL: #{asset})"
end
end
end
|