This repository has been archived by the owner on Nov 30, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Rakefile
59 lines (50 loc) · 1.76 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
namespace :coffee do
desc "Compile"
task :compile do
require 'coffee-script'
puts "Compiling Coffeescript"
js = CoffeeScript.compile File.read("#{Dir.pwd}/src/form.authy.coffee")
File.open("#{Dir.pwd}/src/form.authy.js", 'w') { |file| file.write(js) }
end
end
namespace :css do
desc "Build countries flags css"
task :countries do
File.open("src/flags.authy.css", "w") do |f|
f.puts "/* THIS FILE IS AUTOGENERATED. PLEASE DO NOT MODIFIED IT */"
Dir["src/images/flags/*.gif"].each do |flag|
name = File.basename(flag, ".gif")
f.puts ".flag_#{name} { background: url('images/flags/#{name}.gif') no-repeat 0px center; }"
end
f.puts ".aflag { width: 16px; height: 12px; display: inline-block;}"
end
end
desc "Compile"
task :compress => ["css:countries"] do
puts "Compressing css"
require "yui/compressor"
css = File.read("#{Dir.pwd}/src/flags.authy.css")
css += "\n"
css += File.read("#{Dir.pwd}/src/form.authy.css")
compressor = YUI::CssCompressor.new
min_css = compressor.compress(css)
File.open("#{Dir.pwd}/src/form.authy.min.css", 'w') { |file| file.write(min_css) }
end
end
namespace :js do
desc "Compile"
task :compress do
puts "Compressing javascript"
js = File.read("#{Dir.pwd}/src/form.authy.js")
compressor = YUI::JavaScriptCompressor.new
min_js = compressor.compress(js)
File.open("#{Dir.pwd}/src/form.authy.min.js", 'w') { |file| file.write(min_js) }
end
end
task :compile => ["coffee:compile","css:compress", "js:compress"] do
end
task :package => ["compile"] do
puts "Generating form.authy.zip ..."
system "cd src; zip form.authy.zip form.authy.min.js form.authy.min.css images/**/*; mv form.authy.zip .."
end
task :default => :compile