Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 139 lines (115 sloc) 3.905 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'
5aa20ae Rakefile
Blake Mizerany authored
4
c76a68e @rtomayko Run normal and compat specs with default rake task
rtomayko authored
5 task :default => [:test, :compat]
045f93b @sr Convert tests to custom test/spec/mini [#87]
sr authored
6 task :spec => :test
5aa20ae Rakefile
Blake Mizerany authored
7
e31941d @rtomayko add .gemspec; remove echoe
rtomayko authored
8 # SPECS ===============================================================
9
caca9ab @sr Try to run compat tests with Rake::TestTask
sr authored
10 task(:test) { puts "==> Running main test suite" }
11
045f93b @sr Convert tests to custom test/spec/mini [#87]
sr authored
12 Rake::TestTask.new(:test) do |t|
13 t.test_files = FileList['test/*_test.rb']
9d32965 @rtomayko Don't require rubygems in tests; do fall back if necessary
rtomayko authored
14 t.ruby_opts = ['-rubygems'] if defined? Gem
a734cf3 @rtomayko I knew I shoulda taken that left turn at Hoboken
rtomayko authored
15 end
16
0ceb73c @rtomayko Fix specrb detection in rake compat task
rtomayko authored
17 desc "Run < 0.9.x compatibility specs"
8df2d63 @sr Update compat test task so that it works on Heroku
sr authored
18 task :compat do
19 begin
20 require 'mocha'
caca9ab @sr Try to run compat tests with Rake::TestTask
sr authored
21 require 'test/spec'
22 at_exit { exit 0 } # disable test-spec at_exit runner
8df2d63 @sr Update compat test task so that it works on Heroku
sr authored
23
caca9ab @sr Try to run compat tests with Rake::TestTask
sr authored
24 puts "==> Running compat test suite"
25 Rake::TestTask.new(:compat) do |t|
26 t.test_files = FileList['compat/*_test.rb']
27 t.ruby_opts = ['-rubygems'] if defined? Gem
28 end
29 rescue LoadError
30 warn 'Skipping compat tests. mocha and/or test-spec gems not installed.'
c76a68e @rtomayko Run normal and compat specs with default rake task
rtomayko authored
31 end
e31941d @rtomayko add .gemspec; remove echoe
rtomayko authored
32 end
33
34 # PACKAGING ============================================================
35
0663451 @rtomayko read gemspec in simulated github environment
rtomayko authored
36 # Load the gemspec using the same limitations as github
e31941d @rtomayko add .gemspec; remove echoe
rtomayko authored
37 def spec
38 @spec ||=
0663451 @rtomayko read gemspec in simulated github environment
rtomayko authored
39 begin
40 require 'rubygems/specification'
41 data = File.read('sinatra.gemspec')
42 spec = nil
43 Thread.new { spec = eval("$SAFE = 3\n#{data}") }.join
44 spec
45 end
e31941d @rtomayko add .gemspec; remove echoe
rtomayko authored
46 end
47
48 def package(ext='')
230f1ea @rtomayko Build distributables under pkg/ instead of dist/ (per blake's request)
rtomayko authored
49 "pkg/sinatra-#{spec.version}" + ext
e31941d @rtomayko add .gemspec; remove echoe
rtomayko authored
50 end
51
52 desc 'Build packages'
53 task :package => %w[.gem .tar.gz].map {|e| package(e)}
54
55 desc 'Build and install as local gem'
56 task :install => package('.gem') do
57 sh "gem install #{package('.gem')}"
58 end
59
230f1ea @rtomayko Build distributables under pkg/ instead of dist/ (per blake's request)
rtomayko authored
60 directory 'pkg/'
61 CLOBBER.include('pkg')
e31941d @rtomayko add .gemspec; remove echoe
rtomayko authored
62
230f1ea @rtomayko Build distributables under pkg/ instead of dist/ (per blake's request)
rtomayko authored
63 file package('.gem') => %w[pkg/ sinatra.gemspec] + spec.files do |f|
e31941d @rtomayko add .gemspec; remove echoe
rtomayko authored
64 sh "gem build sinatra.gemspec"
65 mv File.basename(f.name), f.name
66 end
67
230f1ea @rtomayko Build distributables under pkg/ instead of dist/ (per blake's request)
rtomayko authored
68 file package('.tar.gz') => %w[pkg/] + spec.files do |f|
968194d @rtomayko 0.9.0 release
rtomayko authored
69 sh <<-SH
70 git archive \
71 --prefix=sinatra-#{source_version}/ \
72 --format=tar \
73 HEAD | gzip > #{f.name}
74 SH
ca9ac7b Sinatra 0.2.0 released
Blake Mizerany authored
75 end
0e367a5 @rtomayko rake task for generating rdoc with hanna template
rtomayko authored
76
ff85aaf @rtomayko rake tasks for publishing API and gems to rubyforge
rtomayko authored
77 # Rubyforge Release / Publish Tasks ==================================
78
611442f @rtomayko 0.9.0.1 "that was quick" release
rtomayko authored
79 desc 'Publish gem and tarball to rubyforge'
230f1ea @rtomayko Build distributables under pkg/ instead of dist/ (per blake's request)
rtomayko authored
80 task 'release' => [package('.gem'), package('.tar.gz')] do |t|
ff85aaf @rtomayko rake tasks for publishing API and gems to rubyforge
rtomayko authored
81 sh <<-end
82 rubyforge add_release sinatra sinatra #{spec.version} #{package('.gem')} &&
83 rubyforge add_file sinatra sinatra #{spec.version} #{package('.tar.gz')}
84 end
85 end
86
fe1ed27 @sr rake tasks to build a simple website
sr authored
87 # Website ============================================================
69293f6 @rtomayko doc/website cleanup
rtomayko authored
88 # Building docs requires HAML and the hanna gem:
89 # gem install mislav-hanna --source=http://gems.github.com
90
926f10b @bmizerany remove defunct doc stuff
bmizerany authored
91 task 'doc' => ['doc:api']
69293f6 @rtomayko doc/website cleanup
rtomayko authored
92
93 desc 'Generate Hanna RDoc under doc/api'
94 task 'doc:api' => ['doc/api/index.html']
95
96 file 'doc/api/index.html' => FileList['lib/**/*.rb','README.rdoc'] do |f|
97 rb_files = f.prerequisites
98 sh((<<-end).gsub(/\s+/, ' '))
99 hanna --charset utf8 \
100 --fmt html \
101 --inline-source \
102 --line-numbers \
103 --main README.rdoc \
104 --op doc/api \
105 --title 'Sinatra API Documentation' \
106 #{rb_files.join(' ')}
107 end
108 end
109 CLEAN.include 'doc/api'
110
8c412cf @rtomayko rake task for updating sinatra.gemspec files manifest
rtomayko authored
111 # Gemspec Helpers ====================================================
112
50999bf @rtomayko update sinatra.gemspec
rtomayko authored
113 def source_version
114 line = File.read('lib/sinatra/base.rb')[/^\s*VERSION = .*/]
115 line.match(/.*VERSION = '(.*)'/)[1]
116 end
117
230f1ea @rtomayko Build distributables under pkg/ instead of dist/ (per blake's request)
rtomayko authored
118 task 'sinatra.gemspec' => FileList['{lib,test,compat}/**','Rakefile','CHANGES','*.rdoc'] do |f|
8c412cf @rtomayko rake task for updating sinatra.gemspec files manifest
rtomayko authored
119 # read spec file and split out manifest section
120 spec = File.read(f.name)
50999bf @rtomayko update sinatra.gemspec
rtomayko authored
121 head, manifest, tail = spec.split(" # = MANIFEST =\n")
122 # replace version and date
123 head.sub!(/\.version = '.*'/, ".version = '#{source_version}'")
124 head.sub!(/\.date = '.*'/, ".date = '#{Date.today.to_s}'")
8c412cf @rtomayko rake task for updating sinatra.gemspec files manifest
rtomayko authored
125 # determine file list from git ls-files
126 files = `git ls-files`.
127 split("\n").
128 sort.
129 reject{ |file| file =~ /^\./ }.
fe1ed27 @sr rake tasks to build a simple website
sr authored
130 reject { |file| file =~ /^doc/ }.
8c412cf @rtomayko rake task for updating sinatra.gemspec files manifest
rtomayko authored
131 map{ |file| " #{file}" }.
132 join("\n")
133 # piece file back together and write...
50999bf @rtomayko update sinatra.gemspec
rtomayko authored
134 manifest = " s.files = %w[\n#{files}\n ]\n"
135 spec = [head,manifest,tail].join(" # = MANIFEST =\n")
8c412cf @rtomayko rake task for updating sinatra.gemspec files manifest
rtomayko authored
136 File.open(f.name, 'w') { |io| io.write(spec) }
137 puts "updated #{f.name}"
138 end
Something went wrong with that request. Please try again.