Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 136 lines (118 sloc) 4.087 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 ===============================================================
30de338 @rkh Reset LANG and LC_CTYPE before running tests (thus avoiding that ever…
rkh authored
15 task :test do
16 ENV['LANG'] = 'C'
17 ENV.delete 'LC_CTYPE'
18 end
e31941d @rtomayko add .gemspec; remove echoe
rtomayko authored
19
e801b5a @rkh remove special treatment for 1.9.2-p0 from Rakefile
rkh authored
20 Rake::TestTask.new(:test) do |t|
21 t.test_files = FileList['test/*_test.rb']
22 t.ruby_opts = ['-rubygems'] if defined? Gem
23 t.ruby_opts << '-I.'
a734cf3 @rtomayko I knew I shoulda taken that left turn at Hoboken
rtomayko authored
24 end
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
25 # Rcov ================================================================
26 namespace :test do
27 desc 'Mesures test coverage'
28 task :coverage do
29 rm_f "coverage"
d3a401e @tdawe removed deprecated --test-unit-only from rcov rake task
tdawe authored
30 rcov = "rcov --text-summary -Ilib"
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
31 system("#{rcov} --no-html --no-color test/*_test.rb")
32 end
ca9ac7b Sinatra 0.2.0 released
Blake Mizerany authored
33 end
0e367a5 @rtomayko rake task for generating rdoc with hanna template
rtomayko authored
34
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
35 # Website =============================================================
69293f6 @rtomayko doc/website cleanup
rtomayko authored
36 # Building docs requires HAML and the hanna gem:
37 # gem install mislav-hanna --source=http://gems.github.com
38
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
39 desc 'Generate RDoc under doc/api'
926f10b @bmizerany remove defunct doc stuff
bmizerany authored
40 task 'doc' => ['doc:api']
a220329 @rkh Switch from Hanna to YARD.
rkh authored
41 task('doc:api') { sh "yardoc -o doc/api" }
69293f6 @rtomayko doc/website cleanup
rtomayko authored
42 CLEAN.include 'doc/api'
43
8753c60 @rkh Add task for adding template languages to all READMEs.
rkh authored
44 # README ===============================================================
45 task :add_template, [:name] do |t, args|
46 Dir.glob('README.*') do |file|
47 code = File.read(file)
48 if code =~ /^===.*#{args.name.capitalize}/
1cf11cb @rkh Fix add_template rake task.
rkh authored
49 puts "Already covered in #{file}"
8753c60 @rkh Add task for adding template languages to all READMEs.
rkh authored
50 else
51 template = code[/===[^\n]*Liquid.*index\.liquid<\/tt>[^\n]*/m]
52 if !template
53 puts "Liquid not found in #{file}"
54 else
1cf11cb @rkh Fix add_template rake task.
rkh authored
55 puts "Adding section to #{file}"
56 template = template.gsub(/Liquid/, args.name.capitalize).gsub(/liquid/, args.name.downcase)
ca7fbe5 @rkh Add documentation for Slim templates.
rkh authored
57 code.gsub! /^(\s*===.*CoffeeScript)/, "\n" << template << "\n\\1"
8753c60 @rkh Add task for adding template languages to all READMEs.
rkh authored
58 File.open(file, "w") { |f| f << code }
59 end
60 end
61 end
62 end
63
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
64 # PACKAGING ============================================================
8c412cf @rtomayko rake task for updating sinatra.gemspec files manifest
rtomayko authored
65
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
66 if defined?(Gem)
67 # Load the gemspec using the same limitations as github
68 def spec
69 require 'rubygems' unless defined? Gem::Specification
70 @spec ||= eval(File.read('sinatra.gemspec'))
71 end
50999bf @rtomayko update sinatra.gemspec
rtomayko authored
72
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
73 def package(ext='')
74 "pkg/sinatra-#{spec.version}" + ext
75 end
77aa857 added rake task for rcov
Homer Simpson authored
76
0781c28 @rtomayko only define gem packaging tasks if rubygems is already loaded
rtomayko authored
77 desc 'Build packages'
78 task :package => %w[.gem .tar.gz].map {|e| package(e)}
79
80 desc 'Build and install as local gem'
81 task :install => package('.gem') do
82 sh "gem install #{package('.gem')}"
83 end
84
85 directory 'pkg/'
86 CLOBBER.include('pkg')
87
88 file package('.gem') => %w[pkg/ sinatra.gemspec] + spec.files do |f|
89 sh "gem build sinatra.gemspec"
90 mv File.basename(f.name), f.name
91 end
92
93 file package('.tar.gz') => %w[pkg/] + spec.files do |f|
94 sh <<-SH
95 git archive \
96 --prefix=sinatra-#{source_version}/ \
97 --format=tar \
98 HEAD | gzip > #{f.name}
99 SH
100 end
101
102 task 'sinatra.gemspec' => FileList['{lib,test,compat}/**','Rakefile','CHANGES','*.rdoc'] do |f|
103 # read spec file and split out manifest section
104 spec = File.read(f.name)
105 head, manifest, tail = spec.split(" # = MANIFEST =\n")
106 # replace version and date
107 head.sub!(/\.version = '.*'/, ".version = '#{source_version}'")
108 head.sub!(/\.date = '.*'/, ".date = '#{Date.today.to_s}'")
109 # determine file list from git ls-files
110 files = `git ls-files`.
111 split("\n").
112 sort.
113 reject{ |file| file =~ /^\./ }.
114 reject { |file| file =~ /^doc/ }.
115 map{ |file| " #{file}" }.
116 join("\n")
117 # piece file back together and write...
118 manifest = " s.files = %w[\n#{files}\n ]\n"
119 spec = [head,manifest,tail].join(" # = MANIFEST =\n")
120 File.open(f.name, 'w') { |io| io.write(spec) }
121 puts "updated #{f.name}"
77aa857 added rake task for rcov
Homer Simpson authored
122 end
d3ef930 @rkh Add release task.
rkh authored
123
124 task 'release' => package('.gem') do
125 sh <<-SH
126 gem install #{package('.gem')} --local &&
127 gem push #{package('.gem')} &&
128 git add sinatra.gemspec &&
ad648be @rkh 1.1.0 release
rkh authored
129 git commit --allow-empty -m '#{source_version} release' &&
130 git tag -s #{source_version} -m '#{source_version} release' &&
d3ef930 @rkh Add release task.
rkh authored
131 git push && (git push sinatra || true) &&
132 git push --tags && (git push sinatra --tags || true)
133 SH
134 end
77aa857 added rake task for rcov
Homer Simpson authored
135 end
Something went wrong with that request. Please try again.