Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 183 lines (153 sloc) 5.523 kb
e31941d Ryan Tomayko add .gemspec; remove echoe
rtomayko authored
1 require 'rake/clean'
045f93b Simon Rozet Convert tests to custom test/spec/mini [#87]
sr authored
2 require 'rake/testtask'
d8a0242 Karel Minarik rake task for generating rubyforge website; assets (logo, CSS)
karmi authored
3 require 'fileutils'
3ed6224 Doug Richardson Add require 'date' to Rakefile; closes #341
drichardson authored
4 require 'date'
e187ec8 Tim Felgentreff 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 Ryan Tomayko Remove 0.9.x compatibility specs :)
rtomayko authored
12 task :default => :test
045f93b Simon Rozet Convert tests to custom test/spec/mini [#87]
sr authored
13 task :spec => :test
5aa20ae Rakefile
Blake Mizerany authored
14
3975bcf Konstantin Haase also clean up rbc files
rkh authored
15 CLEAN.include "**/*.rbc"
16
0781c28 Ryan Tomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
17 def source_version
9de4278 Konstantin Haase Rakefile love
rkh authored
18 @source_version ||= begin
67b0922 Konstantin Haase use Sinatra::VERSION
rkh authored
19 load './lib/sinatra/version.rb'
20 Sinatra::VERSION
9de4278 Konstantin Haase Rakefile love
rkh authored
21 end
0781c28 Ryan Tomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
22 end
23
60ab617 Konstantin Haase 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 Ryan Tomayko add .gemspec; remove echoe
rtomayko authored
33 # SPECS ===============================================================
9de4278 Konstantin Haase Rakefile love
rkh authored
34
30de338 Konstantin Haase Reset LANG and LC_CTYPE before running tests (thus avoiding that everyth...
rkh authored
35 task :test do
36 ENV['LANG'] = 'C'
37 ENV.delete 'LC_CTYPE'
38 end
e31941d Ryan Tomayko add .gemspec; remove echoe
rtomayko authored
39
e801b5a Konstantin Haase 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 Ryan Tomayko I knew I shoulda taken that left turn at Hoboken
rtomayko authored
44 end
9de4278 Konstantin Haase Rakefile love
rkh authored
45
34b48ea Tim Felgentreff add a test:core task to quickly run core tests (e.g non-template-engine ...
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 Ryan Tomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
56 # Rcov ================================================================
9de4278 Konstantin Haase Rakefile love
rkh authored
57
0781c28 Ryan Tomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
58 namespace :test do
61c9396 Peter Powell Fix typo in Rakefile.
SaberUK authored
59 desc 'Measures test coverage'
0781c28 Ryan Tomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
60 task :coverage do
61 rm_f "coverage"
9de4278 Konstantin Haase Rakefile love
rkh authored
62 sh "rcov -Ilib test/*_test.rb"
0781c28 Ryan Tomayko 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 Ryan Tomayko rake task for generating rdoc with hanna template
rtomayko authored
65
0781c28 Ryan Tomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
66 # Website =============================================================
69293f6 Ryan Tomayko doc/website cleanup
rtomayko authored
67
0781c28 Ryan Tomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
68 desc 'Generate RDoc under doc/api'
926f10b Blake Mizerany remove defunct doc stuff
bmizerany authored
69 task 'doc' => ['doc:api']
a220329 Konstantin Haase Switch from Hanna to YARD.
rkh authored
70 task('doc:api') { sh "yardoc -o doc/api" }
69293f6 Ryan Tomayko doc/website cleanup
rtomayko authored
71 CLEAN.include 'doc/api'
72
8753c60 Konstantin Haase Add task for adding template languages to all READMEs.
rkh authored
73 # README ===============================================================
9de4278 Konstantin Haase Rakefile love
rkh authored
74
8753c60 Konstantin Haase 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 Konstantin Haase Fix add_template rake task.
rkh authored
79 puts "Already covered in #{file}"
8753c60 Konstantin Haase 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 Konstantin Haase Fix add_template rake task.
rkh authored
85 puts "Adding section to #{file}"
e187ec8 Tim Felgentreff Make CI Reporter optional
timfel authored
86 template = template.gsub(/Liquid/, args.name.capitalize).gsub(/liquid/, args.name.downcase)
ca7fbe5 Konstantin Haase Add documentation for Slim templates.
rkh authored
87 code.gsub! /^(\s*===.*CoffeeScript)/, "\n" << template << "\n\\1"
8753c60 Konstantin Haase 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 Konstantin Haase 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"]
60ab617 Konstantin Haase let rake thanks figure out commit ranges on its own
rkh authored
97 desc "list of contributors"
39351ff Konstantin Haase add rake task for generating release specific contributor list
rkh authored
98 task :thanks, [:release,:backports] do |t, a|
60ab617 Konstantin Haase 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 Konstantin Haase 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
60ab617 Konstantin Haase 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 Konstantin Haase 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
e014871 Konstantin Haase improve rake authors
rkh authored
109 desc "list of authors"
110 task :authors, [:commit_range, :format, :sep] do |t, a|
2c5403a Konstantin Haase set default commit range for rack authors
rkh authored
111 a.with_defaults :format => "%s (%d)", :sep => ", ", :commit_range => '--all'
cbd32da Konstantin Haase add rake authors
rkh authored
112 authors = Hash.new { |h,k| h[k] = 0 }
113 blake = "Blake Mizerany"
e014871 Konstantin Haase improve rake authors
rkh authored
114 overall = 0
cbd32da Konstantin Haase 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" }
e014871 Konstantin Haase improve rake authors
rkh authored
119 `git shortlog -s #{a.commit_range}`.lines.map do |line|
4e3487c Konstantin Haase don't trust git encoding
rkh authored
120 line = line.force_encoding 'binary' if line.respond_to? :force_encoding
cbd32da Konstantin Haase add rake authors
rkh authored
121 num, name = line.split("\t", 2).map(&:strip)
122 authors[mapping[name] || name] += num.to_i
e014871 Konstantin Haase improve rake authors
rkh authored
123 overall += num.to_i
cbd32da Konstantin Haase add rake authors
rkh authored
124 end
e014871 Konstantin Haase improve rake authors
rkh authored
125 puts "#{overall} commits by #{authors.count} authors:"
cbd32da Konstantin Haase add rake authors
rkh authored
126 puts authors.sort_by { |n,c| -c }.map { |e| a.format % e }.join(a.sep)
127 end
128
0781c28 Ryan Tomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
129 # PACKAGING ============================================================
8c412cf Ryan Tomayko rake task for updating sinatra.gemspec files manifest
rtomayko authored
130
0781c28 Ryan Tomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
131 if defined?(Gem)
132 # Load the gemspec using the same limitations as github
133 def spec
134 require 'rubygems' unless defined? Gem::Specification
135 @spec ||= eval(File.read('sinatra.gemspec'))
136 end
50999bf Ryan Tomayko update sinatra.gemspec
rtomayko authored
137
0781c28 Ryan Tomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
138 def package(ext='')
139 "pkg/sinatra-#{spec.version}" + ext
140 end
77aa857 added rake task for rcov
Homer Simpson authored
141
0781c28 Ryan Tomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
142 desc 'Build packages'
143 task :package => %w[.gem .tar.gz].map {|e| package(e)}
144
145 desc 'Build and install as local gem'
146 task :install => package('.gem') do
147 sh "gem install #{package('.gem')}"
148 end
149
150 directory 'pkg/'
151 CLOBBER.include('pkg')
152
153 file package('.gem') => %w[pkg/ sinatra.gemspec] + spec.files do |f|
154 sh "gem build sinatra.gemspec"
155 mv File.basename(f.name), f.name
156 end
157
158 file package('.tar.gz') => %w[pkg/] + spec.files do |f|
159 sh <<-SH
160 git archive \
161 --prefix=sinatra-#{source_version}/ \
162 --format=tar \
163 HEAD | gzip > #{f.name}
164 SH
165 end
166
20c4a11 Konstantin Haase do not allow release if tests don't pass
rkh authored
167 task 'release' => ['test', package('.gem')] do
855e567 Konstantin Haase fix CHANGES check
rkh authored
168 if File.read("CHANGES") =~ /= \d\.\d\.\d . not yet released$/i
bf097d6 Konstantin Haase add CHANGES check to release task
rkh authored
169 fail 'please update changes first'
170 end
171
d3ef930 Konstantin Haase Add release task.
rkh authored
172 sh <<-SH
173 gem install #{package('.gem')} --local &&
174 gem push #{package('.gem')} &&
06ebbd9 Konstantin Haase improve rake release
rkh authored
175 git commit --allow-empty -a -m '#{source_version} release' &&
176 git tag -s v#{source_version} -m '#{source_version} release' &&
ad648be Konstantin Haase 1.1.0 release
rkh authored
177 git tag -s #{source_version} -m '#{source_version} release' &&
d3ef930 Konstantin Haase Add release task.
rkh authored
178 git push && (git push sinatra || true) &&
179 git push --tags && (git push sinatra --tags || true)
180 SH
181 end
77aa857 added rake task for rcov
Homer Simpson authored
182 end
Something went wrong with that request. Please try again.