Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 129 lines (110 sloc) 3.621 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
a873480 @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
19 files = Dir.glob('test/*_test.rb')
20 files.delete 'test/settings_test.rb'
21 sh "testrb #{files.join ' '}"
22 sh "testrb test/settings_test.rb"
23 end
24 else
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.'
29 end
a734cf3 @rtomayko I knew I shoulda taken that left turn at Hoboken
rtomayko authored
30 end
e31941d @rtomayko add .gemspec; remove echoe
rtomayko authored
31
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
32 # Rcov ================================================================
33 namespace :test do
34 desc 'Mesures test coverage'
35 task :coverage do
36 rm_f "coverage"
c4313d1 @tdawe removed deprecated --test-unit-only from rcov rake task
tdawe authored
37 rcov = "rcov --text-summary -Ilib"
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
38 system("#{rcov} --no-html --no-color test/*_test.rb")
39 end
ca9ac7b Sinatra 0.2.0 released
Blake Mizerany authored
40 end
0e367a5 @rtomayko rake task for generating rdoc with hanna template
rtomayko authored
41
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
42 # Website =============================================================
69293f6 @rtomayko doc/website cleanup
rtomayko authored
43 # Building docs requires HAML and the hanna gem:
44 # gem install mislav-hanna --source=http://gems.github.com
45
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
46 desc 'Generate RDoc under doc/api'
926f10b @bmizerany remove defunct doc stuff
bmizerany authored
47 task 'doc' => ['doc:api']
69293f6 @rtomayko doc/website cleanup
rtomayko authored
48
49 task 'doc:api' => ['doc/api/index.html']
50
51 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
52 require 'rbconfig'
53 hanna = RbConfig::CONFIG['ruby_install_name'].sub('ruby', 'hanna')
69293f6 @rtomayko doc/website cleanup
rtomayko authored
54 rb_files = f.prerequisites
55 sh((<<-end).gsub(/\s+/, ' '))
3ea36c9 @kch more robust 'rake doc:api' under different ruby environments
kch authored
56 #{hanna}
57 --charset utf8
58 --fmt html
59 --inline-source
60 --line-numbers
61 --main README.rdoc
62 --op doc/api
63 --title 'Sinatra API Documentation'
64 #{rb_files.join(' ')}
69293f6 @rtomayko doc/website cleanup
rtomayko authored
65 end
66 end
67 CLEAN.include 'doc/api'
68
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
69 # PACKAGING ============================================================
8c412cf @rtomayko rake task for updating sinatra.gemspec files manifest
rtomayko authored
70
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
71 if defined?(Gem)
72 # Load the gemspec using the same limitations as github
73 def spec
74 require 'rubygems' unless defined? Gem::Specification
75 @spec ||= eval(File.read('sinatra.gemspec'))
76 end
50999bf @rtomayko update sinatra.gemspec
rtomayko authored
77
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
78 def package(ext='')
79 "pkg/sinatra-#{spec.version}" + ext
80 end
77aa857 added rake task for rcov
Homer Simpson authored
81
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
82 desc 'Build packages'
83 task :package => %w[.gem .tar.gz].map {|e| package(e)}
84
85 desc 'Build and install as local gem'
86 task :install => package('.gem') do
87 sh "gem install #{package('.gem')}"
88 end
89
90 directory 'pkg/'
91 CLOBBER.include('pkg')
92
93 file package('.gem') => %w[pkg/ sinatra.gemspec] + spec.files do |f|
94 sh "gem build sinatra.gemspec"
95 mv File.basename(f.name), f.name
96 end
97
98 file package('.tar.gz') => %w[pkg/] + spec.files do |f|
99 sh <<-SH
100 git archive \
101 --prefix=sinatra-#{source_version}/ \
102 --format=tar \
103 HEAD | gzip > #{f.name}
104 SH
105 end
106
107 task 'sinatra.gemspec' => FileList['{lib,test,compat}/**','Rakefile','CHANGES','*.rdoc'] do |f|
108 # read spec file and split out manifest section
109 spec = File.read(f.name)
110 head, manifest, tail = spec.split(" # = MANIFEST =\n")
111 # replace version and date
112 head.sub!(/\.version = '.*'/, ".version = '#{source_version}'")
113 head.sub!(/\.date = '.*'/, ".date = '#{Date.today.to_s}'")
114 # determine file list from git ls-files
115 files = `git ls-files`.
116 split("\n").
117 sort.
118 reject{ |file| file =~ /^\./ }.
119 reject { |file| file =~ /^doc/ }.
120 map{ |file| " #{file}" }.
121 join("\n")
122 # piece file back together and write...
123 manifest = " s.files = %w[\n#{files}\n ]\n"
124 spec = [head,manifest,tail].join(" # = MANIFEST =\n")
125 File.open(f.name, 'w') { |io| io.write(spec) }
126 puts "updated #{f.name}"
77aa857 added rake task for rcov
Homer Simpson authored
127 end
128 end
Something went wrong with that request. Please try again.