Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added `rake update` to automatically update assets

  • Loading branch information...
commit 5e247d7441e3b3738e69ad4ff173552c8191d48e 1 parent 208f0d9
@iain authored
Showing with 53 additions and 0 deletions.
  1. +53 −0 Rakefile
View
53 Rakefile
@@ -1 +1,54 @@
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
Please sign in to comment.
Something went wrong with that request. Please try again.