Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

33 lines (27 sloc) 1.0 kB
require 'net/http'
require 'uri'
module Bristle
module Generators
class DependencyGenerator < Rails::Generators::Base
source_root File.expand_path('../templates', __FILE__)
desc "Dependency installs Dependencies!"
def download_and_inject
urls = {
'backbone' => 'http://documentcloud.github.com/backbone/backbone.js',
'underscore' => 'http://documentcloud.github.com/underscore/underscore.js'
}
urls.each do |file_name, file_url|
new_file = "app/assets/javascripts/#{file_name}.js"
say_status('download', file_url, :green)
url = URI.parse(file_url)
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true if url.scheme == 'https'
request = Net::HTTP::Get.new(url.request_uri)
response = http.request(request)
create_file new_file
append_to_file new_file, response.body
end
end
end
end
end
Jump to Line
Something went wrong with that request. Please try again.