forked from iain/formalize-rails
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
65 lines (54 loc) · 1.7 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
require 'bundler/gem_tasks'
desc "Get the newest version of formalize from github"
task :update do
Thread.abort_on_exception = true
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)
threads = []
threads += js.map do |file|
Thread.new do
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
end
threads += images.map do |file|
Thread.new do
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
end
threads += css.map do |file|
Thread.new do
url = File.join(base_url, "css", file)
path = File.join(target, "stylesheets", "#{file}.scss")
File.open(path, 'w') do |t|
open url do |f|
f.each_line do |line|
t << line.gsub(%r|url\(.+/([^/]+)\)|) { |m| "image-url('formalize/#{$1.split("?",2).first}')" }
end
end
end
puts "Saved #{path}"
end
end
threads.each(&:join)
puts "Done!"
end