Bootstrap download the yui plugin for the examples.
This commit is contained in:
parent
d4971fcfaa
commit
3b7637f1e5
9
Rakefile
9
Rakefile
@ -108,8 +108,10 @@ task :examples do
|
||||
next unless File.directory?(example)
|
||||
puts "\nCompiling #{example}"
|
||||
puts "=" * "Compiling #{example}".length
|
||||
bootstrap_file = File.join(example, "bootstrap.rb")
|
||||
load bootstrap_file if File.exists?(bootstrap_file)
|
||||
Dir.chdir example do
|
||||
load "bootstrap.rb" if File.exists?("bootstrap.rb")
|
||||
Compass::Exec::Compass.new(["--force"]).run!
|
||||
end
|
||||
# compile any haml templates to html
|
||||
FileList["#{example}/**/*.haml"].each do |haml_file|
|
||||
basename = haml_file[0..-6]
|
||||
@ -119,9 +121,6 @@ task :examples do
|
||||
output.write(engine.render)
|
||||
output.close
|
||||
end
|
||||
Dir.chdir example do
|
||||
Compass::Exec::Compass.new(["--force"]).run!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
57
examples/downloader.rb
Normal file
57
examples/downloader.rb
Normal file
@ -0,0 +1,57 @@
|
||||
require 'net/http'
|
||||
require 'fileutils'
|
||||
require 'rubygems'
|
||||
require 'zip/zip'
|
||||
|
||||
|
||||
def fetch(uri_str, limit = 10)
|
||||
raise ArgumentError, 'HTTP redirect too deep' if limit == 0
|
||||
|
||||
url = URI.parse(uri_str)
|
||||
http = Net::HTTP.new(url.host, url.port)
|
||||
http.open_timeout = 2
|
||||
http.read_timeout = 30
|
||||
response = http.start do |http|
|
||||
puts "getting #{url.path}"
|
||||
http.request_get(url.path)
|
||||
end
|
||||
|
||||
case response
|
||||
when Net::HTTPSuccess then response
|
||||
when Net::HTTPRedirection then fetch(response['location'], limit - 1)
|
||||
else
|
||||
response.error!
|
||||
end
|
||||
end
|
||||
|
||||
def install_from_github(user, project, ext_name, working_directory = Dir.pwd)
|
||||
download_link = "http://github.com/#{user}/#{project}/zipball/master"
|
||||
extdir = File.join(working_directory,'extensions')
|
||||
|
||||
if !File.exists?(extdir)
|
||||
begin
|
||||
puts "Downloading the #{ext_name} plugin into #{extdir}."
|
||||
FileUtils.mkdir(extdir)
|
||||
zipfile = File.join(extdir, "#{ext_name}.zip")
|
||||
open(zipfile, "wb") do |tgz|
|
||||
tgz << fetch(download_link).body
|
||||
end
|
||||
puts "Unzipping the #{ext_name} plugin."
|
||||
Zip::ZipFile::open(zipfile) { |zf|
|
||||
zf.each { |e|
|
||||
fpath = File.join(extdir, e.name)
|
||||
FileUtils.mkdir_p(File.dirname(fpath))
|
||||
zf.extract(e, fpath)
|
||||
}
|
||||
}
|
||||
File.unlink(zipfile)
|
||||
funky_directory = Dir.glob(File.join(extdir,"#{user}-#{project}-*"))[0]
|
||||
FileUtils.mv(funky_directory, File.join(extdir, ext_name))
|
||||
puts "#{ext_name} installed."
|
||||
rescue Exception => e
|
||||
FileUtils.rm_rf(extdir)
|
||||
raise
|
||||
end
|
||||
end
|
||||
|
||||
end
|
@ -1,45 +1,4 @@
|
||||
require 'net/http'
|
||||
require 'fileutils'
|
||||
require 'rubygems'
|
||||
require 'zip/zip'
|
||||
require File.join(File.dirname(__FILE__), '..', 'downloader')
|
||||
|
||||
extdir = File.join(File.dirname(__FILE__),'extensions')
|
||||
download_link = "http://github.com/chriseppstein/compass-960-plugin/zipball/master"
|
||||
install_from_github('chriseppstein', 'compass-960-plugin', 'ninesixty')
|
||||
|
||||
def fetch(uri_str, limit = 10)
|
||||
raise ArgumentError, 'HTTP redirect too deep' if limit == 0
|
||||
|
||||
response = Net::HTTP.get_response(URI.parse(uri_str))
|
||||
case response
|
||||
when Net::HTTPSuccess then response
|
||||
when Net::HTTPRedirection then fetch(response['location'], limit - 1)
|
||||
else
|
||||
response.error!
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if !File.exists?(extdir)
|
||||
begin
|
||||
puts "Downloading the ninesixty plugin."
|
||||
FileUtils.mkdir(extdir)
|
||||
zipfile = File.join(extdir, "ninesixty.zip")
|
||||
open(zipfile, "wb") do |tgz|
|
||||
tgz << fetch(download_link).body
|
||||
end
|
||||
puts "Unzipping the ninesixty plugin."
|
||||
Zip::ZipFile::open(zipfile) { |zf|
|
||||
zf.each { |e|
|
||||
fpath = File.join(extdir, e.name)
|
||||
FileUtils.mkdir_p(File.dirname(fpath))
|
||||
zf.extract(e, fpath)
|
||||
}
|
||||
}
|
||||
File.unlink(zipfile)
|
||||
funky_directory = Dir.glob(File.join(extdir,'chriseppstein-compass-960-plugin-*'))[0]
|
||||
FileUtils.mv(funky_directory, File.join(extdir,'ninesixty'))
|
||||
rescue Exception => e
|
||||
FileUtils.rmdir(extdir)
|
||||
raise
|
||||
end
|
||||
end
|
||||
|
3
examples/yui/bootstrap.rb
Normal file
3
examples/yui/bootstrap.rb
Normal file
@ -0,0 +1,3 @@
|
||||
require File.join(File.dirname(__FILE__), '..', 'downloader')
|
||||
|
||||
install_from_github('chriseppstein', 'yui-compass-plugin', 'yui')
|
Loading…
Reference in New Issue
Block a user