Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 203 lines (172 sloc) 6.295 kb
e31941d @rtomayko add .gemspec; remove echoe
rtomayko authored
1 require 'rake/clean'
045f93b @sr Convert tests to custom test/spec/mini [#87]
sr authored
2 require 'rake/testtask'
d8a0242 @karmi rake task for generating rubyforge website; assets (logo, CSS)
karmi authored
3 require 'fileutils'
3ed6224 @drichardson Add require 'date' to Rakefile; closes #341
drichardson authored
4 require 'date'
b727870 @timfel Make CI Reporter optional
timfel authored
5
6 # CI Reporter is only needed for the CI
7 begin
8 require 'ci/reporter/rake/test_unit'
9 rescue LoadError
10 end
5aa20ae Rakefile
Blake Mizerany authored
11
f4b11b9 @rtomayko Remove 0.9.x compatibility specs :)
rtomayko authored
12 task :default => :test
045f93b @sr Convert tests to custom test/spec/mini [#87]
sr authored
13 task :spec => :test
5aa20ae Rakefile
Blake Mizerany authored
14
3975bcf @rkh also clean up rbc files
rkh authored
15 CLEAN.include "**/*.rbc"
16
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
17 def source_version
9de4278 @rkh Rakefile love
rkh authored
18 @source_version ||= begin
19 line = File.read('lib/sinatra/base.rb')[/^\s*VERSION = .*/]
20 line.match(/.*VERSION = '(.*)'/)[1]
21 end
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
22 end
23
47dacdd @rkh let rake thanks figure out commit ranges on its own
rkh authored
24 def prev_feature
25 source_version.gsub(/^(\d\.)(\d+)\..*$/) { $1 + ($2.to_i - 1).to_s }
26 end
27
28 def prev_version
29 return prev_feature + '.0' if source_version.end_with? '.0'
30 source_version.gsub(/\d+$/) { |s| s.to_i - 1 }
31 end
32
e31941d @rtomayko add .gemspec; remove echoe
rtomayko authored
33 # SPECS ===============================================================
9de4278 @rkh Rakefile love
rkh authored
34
30de338 @rkh Reset LANG and LC_CTYPE before running tests (thus avoiding that ever…
rkh authored
35 task :test do
36 ENV['LANG'] = 'C'
37 ENV.delete 'LC_CTYPE'
38 end
e31941d @rtomayko add .gemspec; remove echoe
rtomayko authored
39
e801b5a @rkh remove special treatment for 1.9.2-p0 from Rakefile
rkh authored
40 Rake::TestTask.new(:test) do |t|
41 t.test_files = FileList['test/*_test.rb']
42 t.ruby_opts = ['-rubygems'] if defined? Gem
43 t.ruby_opts << '-I.'
a734cf3 @rtomayko I knew I shoulda taken that left turn at Hoboken
rtomayko authored
44 end
9de4278 @rkh Rakefile love
rkh authored
45
6b4501e @timfel add a test:core task to quickly run core tests (e.g non-template-engi…
timfel authored
46 Rake::TestTask.new(:"test:core") do |t|
47 core_tests = %w[base delegator encoding extensions filter
48 helpers mapped_error middleware radius rdoc
49 readme request response result route_added_hook
50 routing server settings sinatra static templates]
51 t.test_files = core_tests.map {|n| "test/#{n}_test.rb"}
52 t.ruby_opts = ["-rubygems"] if defined? Gem
53 t.ruby_opts << "-I."
54 end
55
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
56 # Rcov ================================================================
9de4278 @rkh Rakefile love
rkh authored
57
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
58 namespace :test do
59 desc 'Mesures test coverage'
60 task :coverage do
61 rm_f "coverage"
9de4278 @rkh Rakefile love
rkh authored
62 sh "rcov -Ilib test/*_test.rb"
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
63 end
ca9ac7b Sinatra 0.2.0 released
Blake Mizerany authored
64 end
0e367a5 @rtomayko rake task for generating rdoc with hanna template
rtomayko authored
65
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
66 # Website =============================================================
69293f6 @rtomayko doc/website cleanup
rtomayko authored
67
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
68 desc 'Generate RDoc under doc/api'
926f10b @bmizerany remove defunct doc stuff
bmizerany authored
69 task 'doc' => ['doc:api']
a220329 @rkh Switch from Hanna to YARD.
rkh authored
70 task('doc:api') { sh "yardoc -o doc/api" }
69293f6 @rtomayko doc/website cleanup
rtomayko authored
71 CLEAN.include 'doc/api'
72
8753c60 @rkh Add task for adding template languages to all READMEs.
rkh authored
73 # README ===============================================================
9de4278 @rkh Rakefile love
rkh authored
74
8753c60 @rkh Add task for adding template languages to all READMEs.
rkh authored
75 task :add_template, [:name] do |t, args|
76 Dir.glob('README.*') do |file|
77 code = File.read(file)
78 if code =~ /^===.*#{args.name.capitalize}/
1cf11cb @rkh Fix add_template rake task.
rkh authored
79 puts "Already covered in #{file}"
8753c60 @rkh Add task for adding template languages to all READMEs.
rkh authored
80 else
81 template = code[/===[^\n]*Liquid.*index\.liquid<\/tt>[^\n]*/m]
82 if !template
83 puts "Liquid not found in #{file}"
84 else
1cf11cb @rkh Fix add_template rake task.
rkh authored
85 puts "Adding section to #{file}"
b727870 @timfel Make CI Reporter optional
timfel authored
86 template = template.gsub(/Liquid/, args.name.capitalize).gsub(/liquid/, args.name.downcase)
ca7fbe5 @rkh Add documentation for Slim templates.
rkh authored
87 code.gsub! /^(\s*===.*CoffeeScript)/, "\n" << template << "\n\\1"
8753c60 @rkh Add task for adding template languages to all READMEs.
rkh authored
88 File.open(file, "w") { |f| f << code }
89 end
90 end
91 end
92 end
93
39351ff @rkh add rake task for generating release specific contributor list
rkh authored
94 # Thanks in announcement ===============================================
95
96 team = ["Ryan Tomayko", "Blake Mizerany", "Simon Rozet", "Konstantin Haase"]
47dacdd @rkh let rake thanks figure out commit ranges on its own
rkh authored
97 desc "list of contributors"
39351ff @rkh add rake task for generating release specific contributor list
rkh authored
98 task :thanks, [:release,:backports] do |t, a|
47dacdd @rkh let rake thanks figure out commit ranges on its own
rkh authored
99 a.with_defaults :release => "#{prev_version}..HEAD",
100 :backports => "#{prev_feature}.0..#{prev_feature}.x"
39351ff @rkh add rake task for generating release specific contributor list
rkh authored
101 included = `git log --format=format:"%aN\t%s" #{a.release}`.lines.to_a
102 excluded = `git log --format=format:"%aN\t%s" #{a.backports}`.lines.to_a
47dacdd @rkh let rake thanks figure out commit ranges on its own
rkh authored
103 commits = (included - excluded).group_by { |c| c[/^[^\t]+/] }
104 authors = commits.keys.sort_by { |n| - commits[n].size } - team
39351ff @rkh add rake task for generating release specific contributor list
rkh authored
105 puts authors[0..-2].join(', ') << " and " << authors.last,
106 "(based on commits included in #{a.release}, but not in #{a.backports})"
107 end
108
e3f7485 @rkh improve rake authors
rkh authored
109 desc "list of authors"
110 task :authors, [:commit_range, :format, :sep] do |t, a|
11993a7 @rkh set default commit range for rack authors
rkh authored
111 a.with_defaults :format => "%s (%d)", :sep => ", ", :commit_range => '--all'
cbd32da @rkh add rake authors
rkh authored
112 authors = Hash.new { |h,k| h[k] = 0 }
113 blake = "Blake Mizerany"
e3f7485 @rkh improve rake authors
rkh authored
114 overall = 0
cbd32da @rkh add rake authors
rkh authored
115 mapping = {
116 "blake.mizerany@gmail.com" => blake, "bmizerany" => blake,
117 "a_user@mac.com" => blake, "ichverstehe" => "Harry Vangberg",
118 "Wu Jiang (nouse)" => "Wu Jiang" }
e3f7485 @rkh improve rake authors
rkh authored
119 `git shortlog -s #{a.commit_range}`.lines.map do |line|
cbd32da @rkh add rake authors
rkh authored
120 num, name = line.split("\t", 2).map(&:strip)
121 authors[mapping[name] || name] += num.to_i
e3f7485 @rkh improve rake authors
rkh authored
122 overall += num.to_i
cbd32da @rkh add rake authors
rkh authored
123 end
e3f7485 @rkh improve rake authors
rkh authored
124 puts "#{overall} commits by #{authors.count} authors:"
cbd32da @rkh add rake authors
rkh authored
125 puts authors.sort_by { |n,c| -c }.map { |e| a.format % e }.join(a.sep)
126 end
127
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
128 # PACKAGING ============================================================
8c412cf @rtomayko rake task for updating sinatra.gemspec files manifest
rtomayko authored
129
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
130 if defined?(Gem)
131 # Load the gemspec using the same limitations as github
132 def spec
133 require 'rubygems' unless defined? Gem::Specification
134 @spec ||= eval(File.read('sinatra.gemspec'))
135 end
50999bf @rtomayko update sinatra.gemspec
rtomayko authored
136
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
137 def package(ext='')
138 "pkg/sinatra-#{spec.version}" + ext
139 end
77aa857 added rake task for rcov
Homer Simpson authored
140
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
141 desc 'Build packages'
142 task :package => %w[.gem .tar.gz].map {|e| package(e)}
143
144 desc 'Build and install as local gem'
145 task :install => package('.gem') do
146 sh "gem install #{package('.gem')}"
147 end
148
149 directory 'pkg/'
150 CLOBBER.include('pkg')
151
152 file package('.gem') => %w[pkg/ sinatra.gemspec] + spec.files do |f|
153 sh "gem build sinatra.gemspec"
154 mv File.basename(f.name), f.name
155 end
156
157 file package('.tar.gz') => %w[pkg/] + spec.files do |f|
158 sh <<-SH
159 git archive \
160 --prefix=sinatra-#{source_version}/ \
161 --format=tar \
162 HEAD | gzip > #{f.name}
163 SH
164 end
165
166 task 'sinatra.gemspec' => FileList['{lib,test,compat}/**','Rakefile','CHANGES','*.rdoc'] do |f|
167 # read spec file and split out manifest section
168 spec = File.read(f.name)
169 head, manifest, tail = spec.split(" # = MANIFEST =\n")
7d2eacc @rkh don't store date in gemspec, that way regenerating doesn't necessaril…
rkh authored
170 # replace version
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
171 head.sub!(/\.version = '.*'/, ".version = '#{source_version}'")
172 # determine file list from git ls-files
173 files = `git ls-files`.
174 split("\n").
175 sort.
176 reject{ |file| file =~ /^\./ }.
177 reject { |file| file =~ /^doc/ }.
178 map{ |file| " #{file}" }.
179 join("\n")
180 # piece file back together and write...
181 manifest = " s.files = %w[\n#{files}\n ]\n"
182 spec = [head,manifest,tail].join(" # = MANIFEST =\n")
183 File.open(f.name, 'w') { |io| io.write(spec) }
184 puts "updated #{f.name}"
77aa857 added rake task for rcov
Homer Simpson authored
185 end
d3ef930 @rkh Add release task.
rkh authored
186
20c4a11 @rkh do not allow release if tests don't pass
rkh authored
187 task 'release' => ['test', package('.gem')] do
2b8dc06 @rkh fix CHANGES check
rkh authored
188 if File.read("CHANGES") =~ /= \d\.\d\.\d . not yet released$/i
a6395a8 @rkh add CHANGES check to release task
rkh authored
189 fail 'please update changes first'
190 end
191
d3ef930 @rkh Add release task.
rkh authored
192 sh <<-SH
193 gem install #{package('.gem')} --local &&
194 gem push #{package('.gem')} &&
06ebbd9 @rkh improve rake release
rkh authored
195 git commit --allow-empty -a -m '#{source_version} release' &&
196 git tag -s v#{source_version} -m '#{source_version} release' &&
ad648be @rkh 1.1.0 release
rkh authored
197 git tag -s #{source_version} -m '#{source_version} release' &&
d3ef930 @rkh Add release task.
rkh authored
198 git push && (git push sinatra || true) &&
199 git push --tags && (git push sinatra --tags || true)
200 SH
201 end
77aa857 added rake task for rcov
Homer Simpson authored
202 end
Something went wrong with that request. Please try again.