Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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