Skip to content

Instantly share code, notes, and snippets.

@stengland
Created August 11, 2011 11:35
Show Gist options
  • Save stengland/1139443 to your computer and use it in GitHub Desktop.
Save stengland/1139443 to your computer and use it in GitHub Desktop.
test_template
puts "\n========================================================="
puts " Noodall TEMPLATE"
puts "\n========================================================="
require "rails"
require "net/http"
require "net/https"
# Copy a static file from the template into the new application
def copy_static_file(path)
# puts "Installing #{path}..."
remove_file path
file path, File.read(File.join(@static_files, path))
# puts "\n"
end
# From "Suspenders" by thoughtbot
def download_file(uri_string, destination)
uri = URI.parse(uri_string)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true if uri_string =~ /^https/
request = Net::HTTP::Get.new(uri.path)
contents = http.request(request).body
path = File.join(destination_root, destination)
File.open(path, "w") { |file| file.write(contents) }
end
download_file('https://raw.github.com/stengland/beefplate/noodallplate/Site/javascripts/application.js','public/javascripts/applications.js')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment