Skip to content

Commit

Permalink
Added rake update to automatically update assets
Browse files Browse the repository at this point in the history
  • Loading branch information
iain committed Aug 18, 2011
1 parent 208f0d9 commit 5e247d7
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions Rakefile
@@ -1 +1,54 @@
require 'bundler/gem_tasks' require 'bundler/gem_tasks'

desc "Get the newest version of formalize from github"
task :update do
require 'open-uri'

base_url = "https://raw.github.com/nathansmith/formalize/master/assets"
target = "vendor/assets"

js = %w(dojo.formalize.js dojo.formalize.min.js extjs.formalize.js extjs.formalize.min.js jquery.formalize.js jquery.formalize.min.js mootools.formalize.js mootools.formalize.min.js prototype.formalize.js prototype.formalize.min.js yui.formalize.js yui.formalize.min.js)
css = %w(formalize.css)
images = %w(button.png select_arrow.gif)

js.each do |file|
url = File.join(base_url, "js", file)
path = File.join(target, "javascripts", file)
File.open(path, 'w') do |t|
open url do |f|
f.each_line do |line|
t << line
end
end
end
puts "Saved #{path}"
end

images.each do |file|
url = File.join(base_url, "images", file)
path = File.join(target, "images/formalize", file)
File.open(path, 'wb') do |t|
open url do |f|
t << f.read
end
end
puts "Saved #{path}"
end


css.each do |file|
url = File.join(base_url, "css", file)
path = File.join(target, "stylesheets", file)
File.open(path, 'w') do |t|
open url do |f|
f.each_line do |line|
t << line.gsub(%r|url\(.+/([^/]+)\)|, "url(/assets/formalize/\\1)")
end
end
end
puts "Saved #{path}"
end

puts "Done"

end

0 comments on commit 5e247d7

Please sign in to comment.