-
Notifications
You must be signed in to change notification settings - Fork 2
/
Rakefile
62 lines (44 loc) · 1.36 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
require 'rubygems'
require 'fileutils'
desc 'Build the library and readme'
task :build => [:readme, :minified] do
end
desc 'Build the minified version'
task :minified do
require 'closure-compiler'
source = File.read('jquery.quinn.js')
min = Closure::Compiler.new.compress(source)
File.open('jquery.quinn.min.js', 'w') { |f| f.puts min }
end
desc 'Build the index.html readme'
task :readme do
require 'kramdown'
markdown = Kramdown::Document.new(File.read('README.md'))
index = File.read('index.html')
index.gsub!(/^ <!-- begin README -->.*<!-- end README -->\n/m, <<-HTML)
<!-- begin README -->
#{markdown.to_html}
<!-- end README -->
HTML
File.open('index.html', 'w') { |f| f.puts index }
end
desc 'Show the library filesize, including when Gzipped'
task :filesizes do
require 'zlib'
require 'stringio'
development = File.size('jquery.quinn.js')
minified = File.size('jquery.quinn.min.js')
output = StringIO.new
output.set_encoding 'BINARY'
gz = Zlib::GzipWriter.new(output)
gz.write(File.read('jquery.quinn.min.js'))
gz.close
gzipped = output.string.bytesize
puts <<-INFO
Quinn library filesizes
-----------------------
Development: #{(development.to_f / 1024).round(1)}kb
Minified: #{(minified.to_f / 1024).round(1)}kb
Gzipped: #{(gzipped.to_f / 1024).round(1)}kb
INFO
end