Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 180 lines (152 sloc) 5.585 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'
5aa20ae Rakefile
Blake Mizerany authored
5
f4b11b9 @rtomayko Remove 0.9.x compatibility specs :)
rtomayko authored
6 task :default => :test
045f93b @sr Convert tests to custom test/spec/mini [#87]
sr authored
7 task :spec => :test
5aa20ae Rakefile
Blake Mizerany authored
8
3975bcf @rkh also clean up rbc files
rkh authored
9 CLEAN.include "**/*.rbc"
10
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
11 def source_version
9de4278 @rkh Rakefile love
rkh authored
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
16 end
17
60ab617 @rkh let rake thanks figure out commit ranges on its own
rkh authored
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
27 # SPECS ===============================================================
9de4278 @rkh Rakefile love
rkh authored
28
30de338 @rkh Reset LANG and LC_CTYPE before running tests (thus avoiding that ever…
rkh authored
29 task :test do
30 ENV['LANG'] = 'C'
31 ENV.delete 'LC_CTYPE'
32 end
e31941d @rtomayko add .gemspec; remove echoe
rtomayko authored
33
e801b5a @rkh remove special treatment for 1.9.2-p0 from Rakefile
rkh authored
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
38 end
9de4278 @rkh Rakefile love
rkh authored
39
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
40 # Rcov ================================================================
9de4278 @rkh Rakefile love
rkh authored
41
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
42 namespace :test do
43 desc 'Mesures test coverage'
44 task :coverage do
45 rm_f "coverage"
9de4278 @rkh Rakefile love
rkh authored
46 sh "rcov -Ilib test/*_test.rb"
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
47 end
ca9ac7b Sinatra 0.2.0 released
Blake Mizerany authored
48 end
0e367a5 @rtomayko rake task for generating rdoc with hanna template
rtomayko authored
49
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
50 # Website =============================================================
69293f6 @rtomayko doc/website cleanup
rtomayko authored
51
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
52 desc 'Generate RDoc under doc/api'
926f10b @bmizerany remove defunct doc stuff
bmizerany authored
53 task 'doc' => ['doc:api']
a220329 @rkh Switch from Hanna to YARD.
rkh authored
54 task('doc:api') { sh "yardoc -o doc/api" }
69293f6 @rtomayko doc/website cleanup
rtomayko authored
55 CLEAN.include 'doc/api'
56
8753c60 @rkh Add task for adding template languages to all READMEs.
rkh authored
57 # README ===============================================================
9de4278 @rkh Rakefile love
rkh authored
58
8753c60 @rkh Add task for adding template languages to all READMEs.
rkh authored
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
63 puts "Already covered in #{file}"
8753c60 @rkh Add task for adding template languages to all READMEs.
rkh authored
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
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
71 code.gsub! /^(\s*===.*CoffeeScript)/, "\n" << template << "\n\\1"
8753c60 @rkh Add task for adding template languages to all READMEs.
rkh authored
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
78 # Thanks in announcement ===============================================
79
80 team = ["Ryan Tomayko", "Blake Mizerany", "Simon Rozet", "Konstantin Haase"]
60ab617 @rkh let rake thanks figure out commit ranges on its own
rkh authored
81 desc "list of contributors"
39351ff @rkh add rake task for generating release specific contributor list
rkh authored
82 task :thanks, [:release,:backports] do |t, a|
60ab617 @rkh let rake thanks figure out commit ranges on its own
rkh authored
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
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
60ab617 @rkh let rake thanks figure out commit ranges on its own
rkh authored
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
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
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
108 # PACKAGING ============================================================
8c412cf @rtomayko rake task for updating sinatra.gemspec files manifest
rtomayko authored
109
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
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
116
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
117 def package(ext='')
118 "pkg/sinatra-#{spec.version}" + ext
119 end
77aa857 added rake task for rcov
Homer Simpson authored
120
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
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
166 end
d3ef930 @rkh Add release task.
rkh authored
167
20c4a11 @rkh do not allow release if tests don't pass
rkh authored
168 task 'release' => ['test', package('.gem')] do
d3ef930 @rkh Add release task.
rkh authored
169 sh <<-SH
170 gem install #{package('.gem')} --local &&
171 gem push #{package('.gem')} &&
06ebbd9 @rkh improve rake release
rkh authored
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
174 git tag -s #{source_version} -m '#{source_version} release' &&
d3ef930 @rkh Add release task.
rkh authored
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
179 end
Something went wrong with that request. Please try again.