Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 160 lines (139 sloc) 4.83 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
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
9 def source_version
10 line = File.read('lib/sinatra/base.rb')[/^\s*VERSION = .*/]
11 line.match(/.*VERSION = '(.*)'/)[1]
12 end
13
e31941d @rtomayko add .gemspec; remove echoe
rtomayko authored
14 # SPECS ===============================================================
15
0dd5749 @rkh Avoid segfault on 1.9.2p0 when running all tests together. Fixes GH #52.
rkh authored
16 if !ENV['NO_TEST_FIX'] and RUBY_VERSION == '1.9.2' and RUBY_PATCHLEVEL == 0
17 # Avoids seg fault
18 task(:test) do
be53ce7 @rkh Avoid setting Encoding.default_external and default_internal.
rkh authored
19 second_run = %w[settings rdoc markaby templates static textile].map { |l| "test/#{l}_test.rb" }
8718419 @rkh Avoid another segfault on 1.9.2 when running `rake test`.
rkh authored
20 first_run = Dir.glob('test/*_test.rb') - second_run
8ce74b3 @rkh Add markaby helper method. Tilt supports Markaby for quite some time …
rkh authored
21 [first_run, second_run].each { |f| sh "testrb #{f.join ' '}" }
0dd5749 @rkh Avoid segfault on 1.9.2p0 when running all tests together. Fixes GH #52.
rkh authored
22 end
23 else
24 Rake::TestTask.new(:test) do |t|
25 t.test_files = FileList['test/*_test.rb']
26 t.ruby_opts = ['-rubygems'] if defined? Gem
27 t.ruby_opts << '-I.'
28 end
a734cf3 @rtomayko I knew I shoulda taken that left turn at Hoboken
rtomayko authored
29 end
e31941d @rtomayko add .gemspec; remove echoe
rtomayko authored
30
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
31 # Rcov ================================================================
32 namespace :test do
33 desc 'Mesures test coverage'
34 task :coverage do
35 rm_f "coverage"
d3a401e @tdawe removed deprecated --test-unit-only from rcov rake task
tdawe authored
36 rcov = "rcov --text-summary -Ilib"
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
37 system("#{rcov} --no-html --no-color test/*_test.rb")
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 # Building docs requires HAML and the hanna gem:
43 # gem install mislav-hanna --source=http://gems.github.com
44
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
45 desc 'Generate RDoc under doc/api'
926f10b @bmizerany remove defunct doc stuff
bmizerany authored
46 task 'doc' => ['doc:api']
69293f6 @rtomayko doc/website cleanup
rtomayko authored
47
48 task 'doc:api' => ['doc/api/index.html']
49
c2705a9 @rkh Include all READMEs in documentation generated by rake task.
rkh authored
50 file 'doc/api/index.html' => FileList['lib/**/*.rb', 'README.*'] do |f|
3ea36c9 @kch more robust 'rake doc:api' under different ruby environments
kch authored
51 require 'rbconfig'
52 hanna = RbConfig::CONFIG['ruby_install_name'].sub('ruby', 'hanna')
69293f6 @rtomayko doc/website cleanup
rtomayko authored
53 rb_files = f.prerequisites
c2705a9 @rkh Include all READMEs in documentation generated by rake task.
rkh authored
54 sh(<<-end.gsub(/\s+/, ' '))
3ea36c9 @kch more robust 'rake doc:api' under different ruby environments
kch authored
55 #{hanna}
56 --charset utf8
57 --fmt html
58 --inline-source
59 --line-numbers
60 --main README.rdoc
61 --op doc/api
62 --title 'Sinatra API Documentation'
63 #{rb_files.join(' ')}
69293f6 @rtomayko doc/website cleanup
rtomayko authored
64 end
65 end
66 CLEAN.include 'doc/api'
67
8753c60 @rkh Add task for adding template languages to all READMEs.
rkh authored
68 # README ===============================================================
69 task :add_template, [:name] do |t, args|
70 Dir.glob('README.*') do |file|
71 code = File.read(file)
72 if code =~ /^===.*#{args.name.capitalize}/
1cf11cb @rkh Fix add_template rake task.
rkh authored
73 puts "Already covered in #{file}"
8753c60 @rkh Add task for adding template languages to all READMEs.
rkh authored
74 else
75 template = code[/===[^\n]*Liquid.*index\.liquid<\/tt>[^\n]*/m]
76 if !template
77 puts "Liquid not found in #{file}"
78 else
1cf11cb @rkh Fix add_template rake task.
rkh authored
79 puts "Adding section to #{file}"
80 template = template.gsub(/Liquid/, args.name.capitalize).gsub(/liquid/, args.name.downcase)
81 code.gsub! /^(\s*===.*CoffeeScript)/, template << "\n\\1"
8753c60 @rkh Add task for adding template languages to all READMEs.
rkh authored
82 File.open(file, "w") { |f| f << code }
83 end
84 end
85 end
86 end
87
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
88 # PACKAGING ============================================================
8c412cf @rtomayko rake task for updating sinatra.gemspec files manifest
rtomayko authored
89
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
90 if defined?(Gem)
91 # Load the gemspec using the same limitations as github
92 def spec
93 require 'rubygems' unless defined? Gem::Specification
94 @spec ||= eval(File.read('sinatra.gemspec'))
95 end
50999bf @rtomayko update sinatra.gemspec
rtomayko authored
96
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
97 def package(ext='')
98 "pkg/sinatra-#{spec.version}" + ext
99 end
77aa857 added rake task for rcov
Homer Simpson authored
100
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
101 desc 'Build packages'
102 task :package => %w[.gem .tar.gz].map {|e| package(e)}
103
104 desc 'Build and install as local gem'
105 task :install => package('.gem') do
106 sh "gem install #{package('.gem')}"
107 end
108
109 directory 'pkg/'
110 CLOBBER.include('pkg')
111
112 file package('.gem') => %w[pkg/ sinatra.gemspec] + spec.files do |f|
113 sh "gem build sinatra.gemspec"
114 mv File.basename(f.name), f.name
115 end
116
117 file package('.tar.gz') => %w[pkg/] + spec.files do |f|
118 sh <<-SH
119 git archive \
120 --prefix=sinatra-#{source_version}/ \
121 --format=tar \
122 HEAD | gzip > #{f.name}
123 SH
124 end
125
126 task 'sinatra.gemspec' => FileList['{lib,test,compat}/**','Rakefile','CHANGES','*.rdoc'] do |f|
127 # read spec file and split out manifest section
128 spec = File.read(f.name)
129 head, manifest, tail = spec.split(" # = MANIFEST =\n")
130 # replace version and date
131 head.sub!(/\.version = '.*'/, ".version = '#{source_version}'")
132 head.sub!(/\.date = '.*'/, ".date = '#{Date.today.to_s}'")
133 # determine file list from git ls-files
134 files = `git ls-files`.
135 split("\n").
136 sort.
137 reject{ |file| file =~ /^\./ }.
138 reject { |file| file =~ /^doc/ }.
139 map{ |file| " #{file}" }.
140 join("\n")
141 # piece file back together and write...
142 manifest = " s.files = %w[\n#{files}\n ]\n"
143 spec = [head,manifest,tail].join(" # = MANIFEST =\n")
144 File.open(f.name, 'w') { |io| io.write(spec) }
145 puts "updated #{f.name}"
77aa857 added rake task for rcov
Homer Simpson authored
146 end
d3ef930 @rkh Add release task.
rkh authored
147
148 task 'release' => package('.gem') do
149 sh <<-SH
150 gem install #{package('.gem')} --local &&
151 gem push #{package('.gem')} &&
152 git add sinatra.gemspec &&
ad648be @rkh 1.1.0 release
rkh authored
153 git commit --allow-empty -m '#{source_version} release' &&
154 git tag -s #{source_version} -m '#{source_version} release' &&
d3ef930 @rkh Add release task.
rkh authored
155 git push && (git push sinatra || true) &&
156 git push --tags && (git push sinatra --tags || true)
157 SH
158 end
77aa857 added rake task for rcov
Homer Simpson authored
159 end
Something went wrong with that request. Please try again.