-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
38 lines (32 loc) · 1.13 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
desc "Release a new SeatHolder version"
task :release, :version do |task, args|
if (args[:version] || "").strip.empty?
puts "usage: rake release[version]"
exit
end
timestamp = Time.now
javascript = File.open("src/seat_holder.js").readlines.collect{ |line|
line.gsub(/\{(version|year|date)\}/) do |matched|
case matched
when "{version}"
args[:version]
when "{year}"
timestamp.year.to_s
when "{date}"
timestamp.strftime("%Y-%m-%d %H:%M:%S +0100 (%a, %d %B %Y)")
end
end
}
# Define variables
releases_dir = "releases"
release_dir = "#{releases_dir}/#{args[:version]}"
# Create directories
FileUtils.rm_r(release_dir) if File.exists?(release_dir)
FileUtils.mkdir_p("#{release_dir}/jquery")
# Create files
File.open("#{release_dir}/seat_holder.js", "w").puts(javascript)
FileUtils.cp("src/jquery/core.js", "#{release_dir}/jquery")
File.open("VERSION", "w").puts(args[:version])
# Compress release using YUI compressor
IO.popen "java -jar lib/yuicompressor-2.4.2.jar -v #{release_dir}/seat_holder.js -o #{release_dir}/seat_holder-min.js"
end