Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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