-
Notifications
You must be signed in to change notification settings - Fork 14
/
Rakefile
157 lines (138 loc) · 3.91 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
Encoding.default_internal = Encoding.default_external = Encoding::UTF_8 if defined?(Encoding)
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'spontaneous/version'
require 'rubygems'
require 'rake'
def name
"spontaneous"
end
def version
Spontaneous::VERSION
end
#############################################################################
#
# Standard tasks
#
#############################################################################
task :default => :test
require 'rake/testtask'
Rake::TestTask.new(:test) do |test|
test.libs << 'test'
test.ruby_opts << '-rubygems'
test.pattern = 'test/{unit,functional,experimental}/**/test_*.rb'
test.verbose = false
end
namespace :test do
Rake::TestTask.new(:units) do |test|
test.libs << 'test'
test.ruby_opts << '-rubygems'
test.pattern = 'test/unit/**/test_*.rb'
test.verbose = true
end
Rake::TestTask.new(:slow) do |test|
test.libs << 'test'
test.ruby_opts << '-rubygems'
test.pattern = 'test/slow/**/test_*.rb'
test.verbose = true
end
Rake::TestTask.new(:functionals) do |test|
test.libs << 'test'
test.ruby_opts << '-rubygems'
test.pattern = 'test/functional/**/test_*.rb'
test.verbose = true
end
Rake::TestTask.new(:experimental) do |test|
test.libs << 'test'
test.ruby_opts << '-rubygems'
test.pattern = 'test/experimental/**/test_*.rb'
test.verbose = true
end
Rake::TestTask.new(:javascript) do |test|
test.libs << 'test'
test.ruby_opts << '-rubygems'
test.pattern = 'test/javascript/**/test_*.rb'
test.verbose = true
end
Rake::TestTask.new(:ui) do |test|
test.libs << 'test'
test.ruby_opts << '-rubygems'
test.pattern = 'test/ui/**/test_*.rb'
test.verbose = true
end
Rake::TestTask.new(:js) do |test|
test.libs << 'test'
test.ruby_opts << '-rubygems'
test.pattern = 'test/javascript/**/test_*.rb'
test.verbose = true
end
Rake::TestTask.new(:integration) do |test|
test.libs << 'test'
test.ruby_opts << '-rubygems'
test.pattern = 'test/integration/**/test_*.rb'
test.verbose = true
end
end
desc "Generate RCov test coverage and open in your browser"
task :coverage do
require 'rcov'
sh "rm -fr coverage"
sh "rcov test/test_*.rb"
sh "open coverage/index.html"
end
#############################################################################
#
# Packaging tasks
#
#############################################################################
def gemspec_file
"#{name}.gemspec"
end
def gem_file
"#{name}-#{version}.gem"
end
namespace :gem do
desc "Create tag v#{version} and build and push #{gem_file} to Rubygems"
task :release => :build do
unless `git branch` =~ /^\* master$/
puts "You must be on the master branch to release!"
exit!
end
sh "git commit --allow-empty -a -m 'Release #{version}'"
sh "git tag v#{version}"
sh "git push origin master"
sh "git push origin v#{version}"
sh "gem push pkg/#{gem_file}"
end
desc "Build #{gem_file} into the pkg directory"
task :build do
sh "gem build #{gemspec_file}"
sh "mkdir -p pkg"
sh "mv #{gem_file} pkg"
end
end
namespace :asset do
desc "Fingerprints a file"
task :fingerprint do
require 'digest/md5'
unless file = (ENV["file"] || ENV["FILE"])
puts "Usage rake asset:fingerprint file=path/to/file.ext"
exit 1
end
unless File.file?(file)
puts "File #{file.inspect} does not exist or is a directory"
exit 1
end
fingerprint = Digest::MD5.file(file).hexdigest
*name_parts, ext = File.basename(file).split(".")
name = name_parts.join(".")
if name =~ /-([0-9a-fA-F]{32})$/
puts "Removing existing fingerprint '#{$1}'"
name = name.gsub(/-#{$1}/, "")
end
name = "%s-%s.%s" % [name, fingerprint, ext]
path = File.join File.dirname(file), name
system "git mv #{file} #{path}"
p path
end
end