Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 155 lines (130 sloc) 4.756 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
e31941d @rtomayko add .gemspec; remove echoe
rtomayko authored
18 # SPECS ===============================================================
9de4278 @rkh Rakefile love
rkh authored
19
30de338 @rkh Reset LANG and LC_CTYPE before running tests (thus avoiding that ever…
rkh authored
20 task :test do
21 ENV['LANG'] = 'C'
22 ENV.delete 'LC_CTYPE'
23 end
e31941d @rtomayko add .gemspec; remove echoe
rtomayko authored
24
e801b5a @rkh remove special treatment for 1.9.2-p0 from Rakefile
rkh authored
25 Rake::TestTask.new(:test) do |t|
26 t.test_files = FileList['test/*_test.rb']
27 t.ruby_opts = ['-rubygems'] if defined? Gem
28 t.ruby_opts << '-I.'
a734cf3 @rtomayko I knew I shoulda taken that left turn at Hoboken
rtomayko authored
29 end
9de4278 @rkh Rakefile love
rkh authored
30
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
31 # Rcov ================================================================
9de4278 @rkh Rakefile love
rkh authored
32
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
33 namespace :test do
34 desc 'Mesures test coverage'
35 task :coverage do
36 rm_f "coverage"
9de4278 @rkh Rakefile love
rkh authored
37 sh "rcov -Ilib test/*_test.rb"
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
38 end
ca9ac7b Sinatra 0.2.0 released
Blake Mizerany authored
39 end
0e367a5 @rtomayko rake task for generating rdoc with hanna template
rtomayko authored
40
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
41 # Website =============================================================
69293f6 @rtomayko doc/website cleanup
rtomayko authored
42
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
43 desc 'Generate RDoc under doc/api'
926f10b @bmizerany remove defunct doc stuff
bmizerany authored
44 task 'doc' => ['doc:api']
a220329 @rkh Switch from Hanna to YARD.
rkh authored
45 task('doc:api') { sh "yardoc -o doc/api" }
69293f6 @rtomayko doc/website cleanup
rtomayko authored
46 CLEAN.include 'doc/api'
47
8753c60 @rkh Add task for adding template languages to all READMEs.
rkh authored
48 # README ===============================================================
9de4278 @rkh Rakefile love
rkh authored
49
8753c60 @rkh Add task for adding template languages to all READMEs.
rkh authored
50 task :add_template, [:name] do |t, args|
51 Dir.glob('README.*') do |file|
52 code = File.read(file)
53 if code =~ /^===.*#{args.name.capitalize}/
1cf11cb @rkh Fix add_template rake task.
rkh authored
54 puts "Already covered in #{file}"
8753c60 @rkh Add task for adding template languages to all READMEs.
rkh authored
55 else
56 template = code[/===[^\n]*Liquid.*index\.liquid<\/tt>[^\n]*/m]
57 if !template
58 puts "Liquid not found in #{file}"
59 else
1cf11cb @rkh Fix add_template rake task.
rkh authored
60 puts "Adding section to #{file}"
61 template = template.gsub(/Liquid/, args.name.capitalize).gsub(/liquid/, args.name.downcase)
ca7fbe5 @rkh Add documentation for Slim templates.
rkh authored
62 code.gsub! /^(\s*===.*CoffeeScript)/, "\n" << template << "\n\\1"
8753c60 @rkh Add task for adding template languages to all READMEs.
rkh authored
63 File.open(file, "w") { |f| f << code }
64 end
65 end
66 end
67 end
68
39351ff @rkh add rake task for generating release specific contributor list
rkh authored
69 # Thanks in announcement ===============================================
70
71 team = ["Ryan Tomayko", "Blake Mizerany", "Simon Rozet", "Konstantin Haase"]
72 desc "list of contributors: rake thanks[1.1.0..master,1.1.0..1.1.x]"
73 task :thanks, [:release,:backports] do |t, a|
74 a.with_defaults :release => "1.1.0..master", :backports => "1.1.0..1.1.x"
75 included = `git log --format=format:"%aN\t%s" #{a.release}`.lines.to_a
76 excluded = `git log --format=format:"%aN\t%s" #{a.backports}`.lines.to_a
77 commits = (included - excluded).group_by { |c| c[/^[^\t]+/] }
78 authors = commits.keys.sort_by { |n| - commits[n].size } - team
79 puts authors[0..-2].join(', ') << " and " << authors.last,
80 "(based on commits included in #{a.release}, but not in #{a.backports})"
81 end
82
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
83 # PACKAGING ============================================================
8c412cf @rtomayko rake task for updating sinatra.gemspec files manifest
rtomayko authored
84
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
85 if defined?(Gem)
86 # Load the gemspec using the same limitations as github
87 def spec
88 require 'rubygems' unless defined? Gem::Specification
89 @spec ||= eval(File.read('sinatra.gemspec'))
90 end
50999bf @rtomayko update sinatra.gemspec
rtomayko authored
91
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
92 def package(ext='')
93 "pkg/sinatra-#{spec.version}" + ext
94 end
77aa857 added rake task for rcov
Homer Simpson authored
95
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
96 desc 'Build packages'
97 task :package => %w[.gem .tar.gz].map {|e| package(e)}
98
99 desc 'Build and install as local gem'
100 task :install => package('.gem') do
101 sh "gem install #{package('.gem')}"
102 end
103
104 directory 'pkg/'
105 CLOBBER.include('pkg')
106
107 file package('.gem') => %w[pkg/ sinatra.gemspec] + spec.files do |f|
108 sh "gem build sinatra.gemspec"
109 mv File.basename(f.name), f.name
110 end
111
112 file package('.tar.gz') => %w[pkg/] + spec.files do |f|
113 sh <<-SH
114 git archive \
115 --prefix=sinatra-#{source_version}/ \
116 --format=tar \
117 HEAD | gzip > #{f.name}
118 SH
119 end
120
121 task 'sinatra.gemspec' => FileList['{lib,test,compat}/**','Rakefile','CHANGES','*.rdoc'] do |f|
122 # read spec file and split out manifest section
123 spec = File.read(f.name)
124 head, manifest, tail = spec.split(" # = MANIFEST =\n")
125 # replace version and date
126 head.sub!(/\.version = '.*'/, ".version = '#{source_version}'")
127 head.sub!(/\.date = '.*'/, ".date = '#{Date.today.to_s}'")
128 # determine file list from git ls-files
129 files = `git ls-files`.
130 split("\n").
131 sort.
132 reject{ |file| file =~ /^\./ }.
133 reject { |file| file =~ /^doc/ }.
134 map{ |file| " #{file}" }.
135 join("\n")
136 # piece file back together and write...
137 manifest = " s.files = %w[\n#{files}\n ]\n"
138 spec = [head,manifest,tail].join(" # = MANIFEST =\n")
139 File.open(f.name, 'w') { |io| io.write(spec) }
140 puts "updated #{f.name}"
77aa857 added rake task for rcov
Homer Simpson authored
141 end
d3ef930 @rkh Add release task.
rkh authored
142
20c4a11 @rkh do not allow release if tests don't pass
rkh authored
143 task 'release' => ['test', package('.gem')] do
d3ef930 @rkh Add release task.
rkh authored
144 sh <<-SH
145 gem install #{package('.gem')} --local &&
146 gem push #{package('.gem')} &&
147 git add sinatra.gemspec &&
ad648be @rkh 1.1.0 release
rkh authored
148 git commit --allow-empty -m '#{source_version} release' &&
149 git tag -s #{source_version} -m '#{source_version} release' &&
d3ef930 @rkh Add release task.
rkh authored
150 git push && (git push sinatra || true) &&
151 git push --tags && (git push sinatra --tags || true)
152 SH
153 end
77aa857 added rake task for rcov
Homer Simpson authored
154 end
Something went wrong with that request. Please try again.