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