Skip to content
This repository
Newer
Older
100644 113 lines (95 sloc) 3.256 kb
e31941dd » rtomayko
2008-08-31 add .gemspec; remove echoe
1 require 'rake/clean'
045f93be » sr
2009-01-20 Convert tests to custom test/spec/mini [#87]
2 require 'rake/testtask'
d8a02423 » karmi
2008-11-02 rake task for generating rubyforge website; assets (logo, CSS)
3 require 'fileutils'
5aa20ae8 » Blake Mizerany
2007-11-21 Rakefile
4
f4b11b96 » rtomayko
2009-06-05 Remove 0.9.x compatibility specs :)
5 task :default => :test
045f93be » sr
2009-01-20 Convert tests to custom test/spec/mini [#87]
6 task :spec => :test
5aa20ae8 » Blake Mizerany
2007-11-21 Rakefile
7
0781c28f » rtomayko
2010-01-28 only define gem packaging tasks if rubygems is already loaded
8 def source_version
9 line = File.read('lib/sinatra/base.rb')[/^\s*VERSION = .*/]
10 line.match(/.*VERSION = '(.*)'/)[1]
11 end
12
e31941dd » rtomayko
2008-08-31 add .gemspec; remove echoe
13 # SPECS ===============================================================
14
045f93be » sr
2009-01-20 Convert tests to custom test/spec/mini [#87]
15 Rake::TestTask.new(:test) do |t|
16 t.test_files = FileList['test/*_test.rb']
574226fd » rtomayko
2010-01-15 rake test puts work dir on explicitly for 1.9
17 t.ruby_opts = ['-rubygems -I.'] if defined? Gem
a734cf38 » rtomayko
2008-12-13 I knew I shoulda taken that left turn at Hoboken
18 end
e31941dd » rtomayko
2008-08-31 add .gemspec; remove echoe
19
0781c28f » rtomayko
2010-01-28 only define gem packaging tasks if rubygems is already loaded
20 # Rcov ================================================================
21 namespace :test do
22 desc 'Mesures test coverage'
23 task :coverage do
24 rm_f "coverage"
25 rcov = "rcov --text-summary --test-unit-only -Ilib"
26 system("#{rcov} --no-html --no-color test/*_test.rb")
27 end
ca9ac7b5 » Blake Mizerany
2008-04-11 Sinatra 0.2.0 released
28 end
0e367a52 » rtomayko
2008-05-27 rake task for generating rdoc with hanna template
29
0781c28f » rtomayko
2010-01-28 only define gem packaging tasks if rubygems is already loaded
30 # Website =============================================================
69293f6c » rtomayko
2008-11-02 doc/website cleanup
31 # Building docs requires HAML and the hanna gem:
32 # gem install mislav-hanna --source=http://gems.github.com
33
0781c28f » rtomayko
2010-01-28 only define gem packaging tasks if rubygems is already loaded
34 desc 'Generate RDoc under doc/api'
926f10b0 » bmizerany
2009-01-18 remove defunct doc stuff
35 task 'doc' => ['doc:api']
69293f6c » rtomayko
2008-11-02 doc/website cleanup
36
37 task 'doc:api' => ['doc/api/index.html']
38
39 file 'doc/api/index.html' => FileList['lib/**/*.rb','README.rdoc'] do |f|
40 rb_files = f.prerequisites
41 sh((<<-end).gsub(/\s+/, ' '))
42 hanna --charset utf8 \
43 --fmt html \
44 --inline-source \
45 --line-numbers \
46 --main README.rdoc \
47 --op doc/api \
48 --title 'Sinatra API Documentation' \
49 #{rb_files.join(' ')}
50 end
51 end
52 CLEAN.include 'doc/api'
53
0781c28f » rtomayko
2010-01-28 only define gem packaging tasks if rubygems is already loaded
54 # PACKAGING ============================================================
8c412cf5 » rtomayko
2008-09-07 rake task for updating sinatra.gemspec files manifest
55
0781c28f » rtomayko
2010-01-28 only define gem packaging tasks if rubygems is already loaded
56 if defined?(Gem)
57 # Load the gemspec using the same limitations as github
58 def spec
59 require 'rubygems' unless defined? Gem::Specification
60 @spec ||= eval(File.read('sinatra.gemspec'))
61 end
50999bf3 » rtomayko
2008-12-20 update sinatra.gemspec
62
0781c28f » rtomayko
2010-01-28 only define gem packaging tasks if rubygems is already loaded
63 def package(ext='')
64 "pkg/sinatra-#{spec.version}" + ext
65 end
77aa857c » Homer Simpson
2009-09-26 added rake task for rcov
66
0781c28f » rtomayko
2010-01-28 only define gem packaging tasks if rubygems is already loaded
67 desc 'Build packages'
68 task :package => %w[.gem .tar.gz].map {|e| package(e)}
69
70 desc 'Build and install as local gem'
71 task :install => package('.gem') do
72 sh "gem install #{package('.gem')}"
73 end
74
75 directory 'pkg/'
76 CLOBBER.include('pkg')
77
78 file package('.gem') => %w[pkg/ sinatra.gemspec] + spec.files do |f|
79 sh "gem build sinatra.gemspec"
80 mv File.basename(f.name), f.name
81 end
82
83 file package('.tar.gz') => %w[pkg/] + spec.files do |f|
84 sh <<-SH
85 git archive \
86 --prefix=sinatra-#{source_version}/ \
87 --format=tar \
88 HEAD | gzip > #{f.name}
89 SH
90 end
91
92 task 'sinatra.gemspec' => FileList['{lib,test,compat}/**','Rakefile','CHANGES','*.rdoc'] do |f|
93 # read spec file and split out manifest section
94 spec = File.read(f.name)
95 head, manifest, tail = spec.split(" # = MANIFEST =\n")
96 # replace version and date
97 head.sub!(/\.version = '.*'/, ".version = '#{source_version}'")
98 head.sub!(/\.date = '.*'/, ".date = '#{Date.today.to_s}'")
99 # determine file list from git ls-files
100 files = `git ls-files`.
101 split("\n").
102 sort.
103 reject{ |file| file =~ /^\./ }.
104 reject { |file| file =~ /^doc/ }.
105 map{ |file| " #{file}" }.
106 join("\n")
107 # piece file back together and write...
108 manifest = " s.files = %w[\n#{files}\n ]\n"
109 spec = [head,manifest,tail].join(" # = MANIFEST =\n")
110 File.open(f.name, 'w') { |io| io.write(spec) }
111 puts "updated #{f.name}"
77aa857c » Homer Simpson
2009-09-26 added rake task for rcov
112 end
113 end
Something went wrong with that request. Please try again.