Skip to content
This repository
Newer
Older
100644 182 lines (153 sloc) 5.523 kb
e31941dd » rtomayko
2008-08-31 add .gemspec; remove echoe
1 require 'rake/clean'
045f93be » sr
2009-01-20 Convert tests to custom test/spec/mini [#87]
2 require 'rake/testtask'
d8a02423 » karmi
2008-11-02 rake task for generating rubyforge website; assets (logo, CSS)
3 require 'fileutils'
3ed62249 » drichardson
2010-04-01 Add require 'date' to Rakefile; closes #341
4 require 'date'
e187ec85 » timfel
2011-06-09 Make CI Reporter optional
5
6 # CI Reporter is only needed for the CI
7 begin
8 require 'ci/reporter/rake/test_unit'
9 rescue LoadError
10 end
5aa20ae8 » Blake Mizerany
2007-11-21 Rakefile
11
f4b11b96 » rtomayko
2009-06-05 Remove 0.9.x compatibility specs :)
12 task :default => :test
045f93be » sr
2009-01-20 Convert tests to custom test/spec/mini [#87]
13 task :spec => :test
5aa20ae8 » Blake Mizerany
2007-11-21 Rakefile
14
3975bcf9 » rkh
2011-02-19 also clean up rbc files
15 CLEAN.include "**/*.rbc"
16
0781c28f » rtomayko
2010-01-28 only define gem packaging tasks if rubygems is already loaded
17 def source_version
9de42785 » rkh
2011-02-26 Rakefile love
18 @source_version ||= begin
67b09227 » rkh
2011-06-05 use Sinatra::VERSION
19 load './lib/sinatra/version.rb'
20 Sinatra::VERSION
9de42785 » rkh
2011-02-26 Rakefile love
21 end
0781c28f » rtomayko
2010-01-28 only define gem packaging tasks if rubygems is already loaded
22 end
23
60ab6178 » rkh
2011-03-20 let rake thanks figure out commit ranges on its own
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
e31941dd » rtomayko
2008-08-31 add .gemspec; remove echoe
33 # SPECS ===============================================================
9de42785 » rkh
2011-02-26 Rakefile love
34
30de3386 » rkh
2010-12-13 Reset LANG and LC_CTYPE before running tests (thus avoiding that ever…
35 task :test do
36 ENV['LANG'] = 'C'
37 ENV.delete 'LC_CTYPE'
38 end
e31941dd » rtomayko
2008-08-31 add .gemspec; remove echoe
39
e801b5aa » rkh
2010-12-26 remove special treatment for 1.9.2-p0 from Rakefile
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.'
a734cf38 » rtomayko
2008-12-13 I knew I shoulda taken that left turn at Hoboken
44 end
9de42785 » rkh
2011-02-26 Rakefile love
45
34b48ea3 » timfel
2011-05-28 add a test:core task to quickly run core tests (e.g non-template-engi…
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
0781c28f » rtomayko
2010-01-28 only define gem packaging tasks if rubygems is already loaded
56 # Rcov ================================================================
9de42785 » rkh
2011-02-26 Rakefile love
57
0781c28f » rtomayko
2010-01-28 only define gem packaging tasks if rubygems is already loaded
58 namespace :test do
61c93966 » SaberUK
2012-05-22 Fix typo in Rakefile.
59 desc 'Measures test coverage'
0781c28f » rtomayko
2010-01-28 only define gem packaging tasks if rubygems is already loaded
60 task :coverage do
61 rm_f "coverage"
9de42785 » rkh
2011-02-26 Rakefile love
62 sh "rcov -Ilib test/*_test.rb"
0781c28f » rtomayko
2010-01-28 only define gem packaging tasks if rubygems is already loaded
63 end
ca9ac7b5 » Blake Mizerany
2008-04-11 Sinatra 0.2.0 released
64 end
0e367a52 » rtomayko
2008-05-27 rake task for generating rdoc with hanna template
65
0781c28f » rtomayko
2010-01-28 only define gem packaging tasks if rubygems is already loaded
66 # Website =============================================================
69293f6c » rtomayko
2008-11-02 doc/website cleanup
67
0781c28f » rtomayko
2010-01-28 only define gem packaging tasks if rubygems is already loaded
68 desc 'Generate RDoc under doc/api'
926f10b0 »
2009-01-18 remove defunct doc stuff
69 task 'doc' => ['doc:api']
a2203290 » rkh
2010-12-23 Switch from Hanna to YARD.
70 task('doc:api') { sh "yardoc -o doc/api" }
69293f6c » rtomayko
2008-11-02 doc/website cleanup
71 CLEAN.include 'doc/api'
72
8753c604 » rkh
2010-11-05 Add task for adding template languages to all READMEs.
73 # README ===============================================================
9de42785 » rkh
2011-02-26 Rakefile love
74
8753c604 » rkh
2010-11-05 Add task for adding template languages to all READMEs.
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}/
1cf11cb4 » rkh
2010-11-05 Fix add_template rake task.
79 puts "Already covered in #{file}"
8753c604 » rkh
2010-11-05 Add task for adding template languages to all READMEs.
80 else
81 template = code[/===[^\n]*Liquid.*index\.liquid<\/tt>[^\n]*/m]
82 if !template
83 puts "Liquid not found in #{file}"
84 else
1cf11cb4 » rkh
2010-11-05 Fix add_template rake task.
85 puts "Adding section to #{file}"
e187ec85 » timfel
2011-06-09 Make CI Reporter optional
86 template = template.gsub(/Liquid/, args.name.capitalize).gsub(/liquid/, args.name.downcase)
ca7fbe54 » rkh
2010-11-05 Add documentation for Slim templates.
87 code.gsub! /^(\s*===.*CoffeeScript)/, "\n" << template << "\n\\1"
8753c604 » rkh
2010-11-05 Add task for adding template languages to all READMEs.
88 File.open(file, "w") { |f| f << code }
89 end
90 end
91 end
92 end
93
39351ff8 » rkh
2011-02-28 add rake task for generating release specific contributor list
94 # Thanks in announcement ===============================================
95
96 team = ["Ryan Tomayko", "Blake Mizerany", "Simon Rozet", "Konstantin Haase"]
60ab6178 » rkh
2011-03-20 let rake thanks figure out commit ranges on its own
97 desc "list of contributors"
39351ff8 » rkh
2011-02-28 add rake task for generating release specific contributor list
98 task :thanks, [:release,:backports] do |t, a|
60ab6178 » rkh
2011-03-20 let rake thanks figure out commit ranges on its own
99 a.with_defaults :release => "#{prev_version}..HEAD",
100 :backports => "#{prev_feature}.0..#{prev_feature}.x"
39351ff8 » rkh
2011-02-28 add rake task for generating release specific contributor list
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
60ab6178 » rkh
2011-03-20 let rake thanks figure out commit ranges on its own
103 commits = (included - excluded).group_by { |c| c[/^[^\t]+/] }
104 authors = commits.keys.sort_by { |n| - commits[n].size } - team
39351ff8 » rkh
2011-02-28 add rake task for generating release specific contributor list
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
e014871d » rkh
2011-06-05 improve rake authors
109 desc "list of authors"
110 task :authors, [:commit_range, :format, :sep] do |t, a|
2c5403aa » rkh
2011-06-16 set default commit range for rack authors
111 a.with_defaults :format => "%s (%d)", :sep => ", ", :commit_range => '--all'
cbd32dae » rkh
2011-03-15 add rake authors
112 authors = Hash.new { |h,k| h[k] = 0 }
113 blake = "Blake Mizerany"
e014871d » rkh
2011-06-05 improve rake authors
114 overall = 0
cbd32dae » rkh
2011-03-15 add rake authors
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" }
e014871d » rkh
2011-06-05 improve rake authors
119 `git shortlog -s #{a.commit_range}`.lines.map do |line|
4e3487cf » rkh
2012-03-11 don't trust git encoding
120 line = line.force_encoding 'binary' if line.respond_to? :force_encoding
cbd32dae » rkh
2011-03-15 add rake authors
121 num, name = line.split("\t", 2).map(&:strip)
122 authors[mapping[name] || name] += num.to_i
e014871d » rkh
2011-06-05 improve rake authors
123 overall += num.to_i
cbd32dae » rkh
2011-03-15 add rake authors
124 end
e014871d » rkh
2011-06-05 improve rake authors
125 puts "#{overall} commits by #{authors.count} authors:"
cbd32dae » rkh
2011-03-15 add rake authors
126 puts authors.sort_by { |n,c| -c }.map { |e| a.format % e }.join(a.sep)
127 end
128
0781c28f » rtomayko
2010-01-28 only define gem packaging tasks if rubygems is already loaded
129 # PACKAGING ============================================================
8c412cf5 » rtomayko
2008-09-07 rake task for updating sinatra.gemspec files manifest
130
0781c28f » rtomayko
2010-01-28 only define gem packaging tasks if rubygems is already loaded
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
50999bf3 » rtomayko
2008-12-20 update sinatra.gemspec
137
0781c28f » rtomayko
2010-01-28 only define gem packaging tasks if rubygems is already loaded
138 def package(ext='')
139 "pkg/sinatra-#{spec.version}" + ext
140 end
77aa857c » Homer Simpson
2009-09-26 added rake task for rcov
141
0781c28f » rtomayko
2010-01-28 only define gem packaging tasks if rubygems is already loaded
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
20c4a115 » rkh
2011-02-19 do not allow release if tests don't pass
167 task 'release' => ['test', package('.gem')] do
855e5671 » rkh
2011-10-14 fix CHANGES check
168 if File.read("CHANGES") =~ /= \d\.\d\.\d . not yet released$/i
bf097d6d » rkh
2011-10-05 add CHANGES check to release task
169 fail 'please update changes first'
170 end
171
d3ef9301 » rkh
2010-10-23 Add release task.
172 sh <<-SH
173 gem install #{package('.gem')} --local &&
174 gem push #{package('.gem')} &&
06ebbd97 » rkh
2011-03-06 improve rake release
175 git commit --allow-empty -a -m '#{source_version} release' &&
176 git tag -s v#{source_version} -m '#{source_version} release' &&
ad648be0 » rkh
2010-10-24 1.1.0 release
177 git tag -s #{source_version} -m '#{source_version} release' &&
d3ef9301 » rkh
2010-10-23 Add release task.
178 git push && (git push sinatra || true) &&
179 git push --tags && (git push sinatra --tags || true)
180 SH
181 end
77aa857c » Homer Simpson
2009-09-26 added rake task for rcov
182 end
Something went wrong with that request. Please try again.