Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 128 lines (109 sloc) 3.67 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
8ce74b3 @rkh Add markaby helper method. Tilt supports Markaby for quite some time …
rkh authored
19 second_run = %w[settings rdoc markaby].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
50 file 'doc/api/index.html' => FileList['lib/**/*.rb','README.rdoc'] 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
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
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
68 # PACKAGING ============================================================
8c412cf @rtomayko rake task for updating sinatra.gemspec files manifest
rtomayko authored
69
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
70 if defined?(Gem)
71 # Load the gemspec using the same limitations as github
72 def spec
73 require 'rubygems' unless defined? Gem::Specification
74 @spec ||= eval(File.read('sinatra.gemspec'))
75 end
50999bf @rtomayko update sinatra.gemspec
rtomayko authored
76
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
77 def package(ext='')
78 "pkg/sinatra-#{spec.version}" + ext
79 end
77aa857 added rake task for rcov
Homer Simpson authored
80
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
81 desc 'Build packages'
82 task :package => %w[.gem .tar.gz].map {|e| package(e)}
83
84 desc 'Build and install as local gem'
85 task :install => package('.gem') do
86 sh "gem install #{package('.gem')}"
87 end
88
89 directory 'pkg/'
90 CLOBBER.include('pkg')
91
92 file package('.gem') => %w[pkg/ sinatra.gemspec] + spec.files do |f|
93 sh "gem build sinatra.gemspec"
94 mv File.basename(f.name), f.name
95 end
96
97 file package('.tar.gz') => %w[pkg/] + spec.files do |f|
98 sh <<-SH
99 git archive \
100 --prefix=sinatra-#{source_version}/ \
101 --format=tar \
102 HEAD | gzip > #{f.name}
103 SH
104 end
105
106 task 'sinatra.gemspec' => FileList['{lib,test,compat}/**','Rakefile','CHANGES','*.rdoc'] do |f|
107 # read spec file and split out manifest section
108 spec = File.read(f.name)
109 head, manifest, tail = spec.split(" # = MANIFEST =\n")
110 # replace version and date
111 head.sub!(/\.version = '.*'/, ".version = '#{source_version}'")
112 head.sub!(/\.date = '.*'/, ".date = '#{Date.today.to_s}'")
113 # determine file list from git ls-files
114 files = `git ls-files`.
115 split("\n").
116 sort.
117 reject{ |file| file =~ /^\./ }.
118 reject { |file| file =~ /^doc/ }.
119 map{ |file| " #{file}" }.
120 join("\n")
121 # piece file back together and write...
122 manifest = " s.files = %w[\n#{files}\n ]\n"
123 spec = [head,manifest,tail].join(" # = MANIFEST =\n")
124 File.open(f.name, 'w') { |io| io.write(spec) }
125 puts "updated #{f.name}"
77aa857 added rake task for rcov
Homer Simpson authored
126 end
127 end
Something went wrong with that request. Please try again.