Skip to content

Instantly share code, notes, and snippets.

@matiskay
Created December 30, 2011 18:20
Show Gist options
  • Save matiskay/1540896 to your computer and use it in GitHub Desktop.
Save matiskay/1540896 to your computer and use it in GitHub Desktop.
Download jquery using Ruby

Download jquery using Ruby

There must be another way to do this, but this works for me.

I should use a gem. :)

Todo

  • Let's make a function with this. [DONE] I don't know how to cross text on markdown.
  • Let's make a class <-- A nice wrapper.

Info

def download_file(uri, file_name)
require 'net/http'
#Net::HTTP.get('http://code.jquery.com', "/jquery-1.7.1.js")
uri = URI(uri)
dwn_file = Net::HTTP.get(uri) # => String
file = File.new(file_name, "w")
file.write(dwn_file)
file.close
end
download_file('http://code.jquery.com/jquery-1.7.1.js', 'jquery.js')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment