heel 2.0.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CONTRIBUTING.md +46 -0
- data/{HISTORY → HISTORY.rdoc} +13 -0
- data/Manifest.txt +45 -0
- data/{README → README.rdoc} +2 -3
- data/Rakefile +20 -0
- data/TODO +2 -0
- data/bin/heel +1 -3
- data/data/css/coderay-alpha.css +120 -0
- data/lib/heel.rb +10 -15
- data/lib/heel/configuration.rb +6 -8
- data/lib/heel/directory_indexer.rb +9 -9
- data/lib/heel/error_response.rb +11 -10
- data/lib/heel/mime_map.rb +3 -3
- data/lib/heel/rackapp.rb +13 -26
- data/lib/heel/request.rb +3 -3
- data/lib/heel/server.rb +88 -75
- data/spec/configuration_spec.rb +9 -5
- data/spec/directory_indexer_spec.rb +8 -8
- data/spec/rackapp_spec.rb +16 -16
- data/spec/server_spec.rb +23 -22
- data/spec/spec_helper.rb +10 -9
- data/tasks/default.rake +212 -0
- data/tasks/this.rb +202 -0
- metadata +178 -110
- data/gemspec.rb +0 -42
- data/lib/heel/logger.rb +0 -42
- data/lib/heel/version.rb +0 -26
- data/tasks/announce.rake +0 -42
- data/tasks/config.rb +0 -103
- data/tasks/distribution.rake +0 -47
- data/tasks/documentation.rake +0 -36
- data/tasks/rspec.rb +0 -34
- data/tasks/rubyforge.rb +0 -67
- data/tasks/utils.rb +0 -85
data/spec/rackapp_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
require 'rack/mock'
|
3
3
|
require 'heel/rackapp'
|
4
4
|
|
@@ -10,34 +10,34 @@ describe Heel::RackApp do
|
|
10
10
|
|
11
11
|
it "should return the a listing for the currrent directory" do
|
12
12
|
res = @request.get("/")
|
13
|
-
res.
|
14
|
-
res['Content-Type'].
|
15
|
-
res.body.
|
13
|
+
res.must_be :ok?
|
14
|
+
res['Content-Type'].must_equal "text/html"
|
15
|
+
res.body.must_match( /Rakefile/ )
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'should highlight a ruby file' do
|
19
|
-
res = @request.get("/
|
20
|
-
res.
|
21
|
-
res['Content-Type'].
|
22
|
-
res.body.
|
19
|
+
res = @request.get("/lib/heel.rb")
|
20
|
+
res.must_be :ok?
|
21
|
+
res['Content-Type'].must_equal "text/html"
|
22
|
+
res.body.must_match( /class="CodeRay"/ )
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should not highlight a ruby file if told not to" do
|
26
|
-
res = @request.get("/
|
27
|
-
res.
|
28
|
-
res.body.size.
|
29
|
-
res['Content-Type'].
|
26
|
+
res = @request.get("/lib/heel.rb?highlighting=off")
|
27
|
+
res.must_be :ok?
|
28
|
+
res.body.size.must_equal File.size("lib/heel.rb")
|
29
|
+
res['Content-Type'].must_equal "application/x-ruby"
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should return a 405 if given a non-GET request" do
|
33
33
|
res = @request.post("/")
|
34
|
-
res.
|
35
|
-
res.status.
|
34
|
+
res.wont_be :ok?
|
35
|
+
res.status.must_equal 405
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should return a 403 if accessing an invalid location" do
|
39
39
|
res = @request.get("/../../../../etc/passwd")
|
40
|
-
res.
|
41
|
-
res.status.
|
40
|
+
res.wont_be :ok?
|
41
|
+
res.status.must_equal 403
|
42
42
|
end
|
43
43
|
end
|
data/spec/server_spec.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
require "
|
1
|
+
require "spec_helper"
|
2
|
+
|
2
3
|
describe Heel::Server do
|
3
4
|
before(:each) do
|
4
5
|
@stdin = StringIO.new
|
@@ -18,8 +19,8 @@ describe Heel::Server do
|
|
18
19
|
begin
|
19
20
|
server.run
|
20
21
|
rescue SystemExit => se
|
21
|
-
se.status.
|
22
|
-
@stdout.string.
|
22
|
+
se.status.must_equal 0
|
23
|
+
@stdout.string.must_match( /version #{Heel::VERSION}/ )
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
@@ -29,8 +30,8 @@ describe Heel::Server do
|
|
29
30
|
begin
|
30
31
|
server.run
|
31
32
|
rescue SystemExit => se
|
32
|
-
se.status.
|
33
|
-
@stdout.string.
|
33
|
+
se.status.must_equal 0
|
34
|
+
@stdout.string.must_match( /Usage/m )
|
34
35
|
end
|
35
36
|
end
|
36
37
|
|
@@ -40,8 +41,8 @@ describe Heel::Server do
|
|
40
41
|
begin
|
41
42
|
server.run
|
42
43
|
rescue SystemExit => se
|
43
|
-
se.status.
|
44
|
-
@stdout.string.
|
44
|
+
se.status.must_equal 1
|
45
|
+
@stdout.string.must_match( /Try .*--help/m )
|
45
46
|
end
|
46
47
|
end
|
47
48
|
|
@@ -51,34 +52,34 @@ describe Heel::Server do
|
|
51
52
|
begin
|
52
53
|
server.run
|
53
54
|
rescue SystemExit => se
|
54
|
-
se.status.
|
55
|
-
@stdout.string.
|
55
|
+
se.status.must_equal 1
|
56
|
+
@stdout.string.must_match( /Try .*--help/m )
|
56
57
|
end
|
57
58
|
end
|
58
59
|
|
59
60
|
it "should allow port and address to be set" do
|
60
61
|
server = Heel::Server.new(%w[--port 4242 --address 192.168.1.1])
|
61
62
|
server.merge_options
|
62
|
-
server.options.address.
|
63
|
-
server.options.port.
|
63
|
+
server.options.address.must_equal "192.168.1.1"
|
64
|
+
server.options.port.must_equal 4242
|
64
65
|
end
|
65
66
|
|
66
67
|
it "should allow the highlighting option to be set" do
|
67
68
|
server = Heel::Server.new(%w[--highlighting])
|
68
69
|
server.merge_options
|
69
|
-
server.options.highlighting.
|
70
|
+
server.options.highlighting.must_equal true
|
70
71
|
end
|
71
72
|
|
72
73
|
it "should have highlighting off as a default" do
|
73
74
|
server = Heel::Server.new
|
74
75
|
server.merge_options
|
75
|
-
server.options.highlighting.
|
76
|
+
server.options.highlighting.must_equal false
|
76
77
|
end
|
77
78
|
|
78
|
-
it "should set no-launch-browser option
|
79
|
+
it "should set no-launch-browser option" do
|
79
80
|
server = Heel::Server.new(%w[--no-launch-browser])
|
80
81
|
server.merge_options
|
81
|
-
server.options.launch_browser.
|
82
|
+
server.options.launch_browser.must_equal false
|
82
83
|
end
|
83
84
|
|
84
85
|
it "should attempt to kill the process" do
|
@@ -89,18 +90,18 @@ describe Heel::Server do
|
|
89
90
|
server.run
|
90
91
|
violated("Should have thrown SystemExit")
|
91
92
|
rescue SystemExit => se
|
92
|
-
se.status.
|
93
|
-
@stdout.string.
|
93
|
+
se.status.must_equal 0
|
94
|
+
@stdout.string.must_match( /Done/m )
|
94
95
|
end
|
95
96
|
end
|
96
97
|
|
97
98
|
it "should setup a heel directory" do
|
98
99
|
server = Heel::Server.new(%w[--daemonize])
|
99
100
|
server.set_io(@stdin,@stdout)
|
100
|
-
File.directory?(server.default_directory).
|
101
|
+
File.directory?(server.default_directory).must_equal false
|
101
102
|
server.setup_heel_dir
|
102
|
-
File.directory?(server.default_directory).
|
103
|
-
@stdout.string.
|
103
|
+
File.directory?(server.default_directory).must_equal true
|
104
|
+
@stdout.string.must_match( /Created/m )
|
104
105
|
end
|
105
106
|
|
106
107
|
it "should send a signal to a pid" do
|
@@ -113,8 +114,8 @@ describe Heel::Server do
|
|
113
114
|
server.run
|
114
115
|
violated("Should have exited")
|
115
116
|
rescue SystemExit => se
|
116
|
-
se.status.
|
117
|
-
@stdout.string.
|
117
|
+
se.status.must_equal 0
|
118
|
+
@stdout.string.must_match( /Sending TERM to process -42/m )
|
118
119
|
end
|
119
120
|
end
|
120
121
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
1
|
+
if RUBY_VERSION >= '1.9.2' then
|
2
|
+
require 'simplecov'
|
3
|
+
puts "Using coverage!"
|
4
|
+
SimpleCov.start if ENV['COVERAGE']
|
5
|
+
end
|
6
|
+
|
7
|
+
gem 'minitest'
|
8
|
+
require 'heel'
|
9
|
+
require 'minitest/autorun'
|
10
|
+
require 'minitest/pride'
|
data/tasks/default.rake
ADDED
@@ -0,0 +1,212 @@
|
|
1
|
+
# vim: syntax=ruby
|
2
|
+
require 'rake/clean'
|
3
|
+
#------------------------------------------------------------------------------
|
4
|
+
# If you want to Develop on this project just run 'rake develop' and you'll
|
5
|
+
# have all you need to get going. If you want to use bundler for development,
|
6
|
+
# then run 'rake develop:using_bundler'
|
7
|
+
#------------------------------------------------------------------------------
|
8
|
+
namespace :develop do
|
9
|
+
|
10
|
+
# Install all the development and runtime dependencies of this gem using the
|
11
|
+
# gemspec.
|
12
|
+
task :default do
|
13
|
+
require 'rubygems/dependency_installer'
|
14
|
+
installer = Gem::DependencyInstaller.new
|
15
|
+
|
16
|
+
This.set_coverage_gem
|
17
|
+
|
18
|
+
puts "Installing gem depedencies needed for development"
|
19
|
+
This.platform_gemspec.dependencies.each do |dep|
|
20
|
+
if dep.matching_specs.empty? then
|
21
|
+
puts "Installing : #{dep}"
|
22
|
+
installer.install dep
|
23
|
+
else
|
24
|
+
puts "Skipping : #{dep} -> already installed #{dep.matching_specs.first.full_name}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
puts "\n\nNow run 'rake test'"
|
28
|
+
end
|
29
|
+
|
30
|
+
# Create a Gemfile that just references the gemspec
|
31
|
+
file 'Gemfile' => :gemspec do
|
32
|
+
File.open( "Gemfile", "w+" ) do |f|
|
33
|
+
f.puts 'source :rubygems'
|
34
|
+
f.puts 'gemspec'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
desc "Create a bundler Gemfile"
|
39
|
+
task :using_bundler => 'Gemfile' do
|
40
|
+
puts "Now you can 'bundle'"
|
41
|
+
end
|
42
|
+
|
43
|
+
# Gemfiles are build artifacts
|
44
|
+
CLOBBER << FileList['Gemfile*']
|
45
|
+
end
|
46
|
+
desc "Boostrap development"
|
47
|
+
task :develop => "develop:default"
|
48
|
+
|
49
|
+
#------------------------------------------------------------------------------
|
50
|
+
# Minitest - standard TestTask
|
51
|
+
#------------------------------------------------------------------------------
|
52
|
+
begin
|
53
|
+
require 'rake/testtask'
|
54
|
+
Rake::TestTask.new( :test ) do |t|
|
55
|
+
t.ruby_opts = %w[ -w -rubygems ]
|
56
|
+
t.libs = %w[ lib spec ]
|
57
|
+
t.pattern = "spec/**/*_spec.rb"
|
58
|
+
end
|
59
|
+
task :default => :test
|
60
|
+
rescue LoadError
|
61
|
+
This.task_warning( 'test' )
|
62
|
+
end
|
63
|
+
|
64
|
+
#------------------------------------------------------------------------------
|
65
|
+
# RDoc - standard rdoc rake task, although we must make sure to use a more
|
66
|
+
# recent version of rdoc since it is the one that has 'tomdoc' markup
|
67
|
+
#------------------------------------------------------------------------------
|
68
|
+
begin
|
69
|
+
gem 'rdoc' # otherwise we get the wrong task from stdlib
|
70
|
+
require 'rdoc/task'
|
71
|
+
RDoc::Task.new do |t|
|
72
|
+
t.markup = 'tomdoc'
|
73
|
+
t.rdoc_dir = 'doc'
|
74
|
+
t.main = 'README.rdoc'
|
75
|
+
t.title = "#{This.name} #{This.version}"
|
76
|
+
t.rdoc_files.include( '*.rdoc', 'lib/**/*.rb' )
|
77
|
+
end
|
78
|
+
rescue LoadError => le
|
79
|
+
This.task_warning( 'rdoc' )
|
80
|
+
end
|
81
|
+
|
82
|
+
#------------------------------------------------------------------------------
|
83
|
+
# Coverage - optional code coverage, rcov for 1.8 and simplecov for 1.9, so
|
84
|
+
# for the moment only rcov is listed.
|
85
|
+
#------------------------------------------------------------------------------
|
86
|
+
if RUBY_VERSION < "1.9.0"
|
87
|
+
begin
|
88
|
+
require 'rcov/rcovtask'
|
89
|
+
Rcov::RcovTask.new( 'coverage' ) do |t|
|
90
|
+
t.libs << 'spec'
|
91
|
+
t.pattern = 'spec/**/*_spec.rb'
|
92
|
+
t.verbose = true
|
93
|
+
t.rcov_opts << "-x ^/" # remove all the global files
|
94
|
+
t.rcov_opts << "--sort coverage" # so we see the worst files at the top
|
95
|
+
end
|
96
|
+
rescue LoadError
|
97
|
+
This.task_warning( 'rcov' )
|
98
|
+
end
|
99
|
+
else
|
100
|
+
begin
|
101
|
+
require 'simplecov'
|
102
|
+
desc 'Run tests with code coverage'
|
103
|
+
task :coverage do
|
104
|
+
ENV['COVERAGE'] = 'true'
|
105
|
+
Rake::Task[:test].execute
|
106
|
+
end
|
107
|
+
CLOBBER << FileList["coverage"]
|
108
|
+
rescue LoadError
|
109
|
+
This.task_warning( 'simplecov' )
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
#------------------------------------------------------------------------------
|
114
|
+
# Manifest - We want an explicit list of thos files that are to be packaged in
|
115
|
+
# the gem. Most of this is from Hoe.
|
116
|
+
#------------------------------------------------------------------------------
|
117
|
+
namespace 'manifest' do
|
118
|
+
desc "Check the manifest"
|
119
|
+
task :check => :clean do
|
120
|
+
files = FileList["**/*", ".*"].exclude( This.exclude_from_manifest ).to_a.sort
|
121
|
+
files = files.select{ |f| File.file?( f ) }
|
122
|
+
|
123
|
+
tmp = "Manifest.tmp"
|
124
|
+
File.open( tmp, 'w' ) do |f|
|
125
|
+
f.puts files.join("\n")
|
126
|
+
end
|
127
|
+
|
128
|
+
begin
|
129
|
+
sh "diff -du Manifest.txt #{tmp}"
|
130
|
+
ensure
|
131
|
+
rm tmp
|
132
|
+
end
|
133
|
+
puts "Manifest looks good"
|
134
|
+
end
|
135
|
+
|
136
|
+
desc "Generate the manifest"
|
137
|
+
task :generate => :clean do
|
138
|
+
files = %x[ git ls-files ].split("\n").sort
|
139
|
+
files.reject! { |f| f =~ This.exclude_from_manifest }
|
140
|
+
File.open( "Manifest.txt", "w" ) do |f|
|
141
|
+
f.puts files.join("\n")
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
#------------------------------------------------------------------------------
|
147
|
+
# Fixme - look for fixmes and report them
|
148
|
+
#------------------------------------------------------------------------------
|
149
|
+
desc "Look for fixmes and report them"
|
150
|
+
task :fixme => 'manifest:check' do
|
151
|
+
This.manifest.each do |file|
|
152
|
+
next if file == __FILE__
|
153
|
+
next unless file =~ %r/(txt|rb|md|rdoc|css|html|xml|css)\Z/
|
154
|
+
puts "FIXME: Rename #{file}" if file =~ /fixme/i
|
155
|
+
IO.readlines( file ).each_with_index do |line, idx|
|
156
|
+
prefix = "FIXME: #{file}:#{idx+1}".ljust(42)
|
157
|
+
puts "#{prefix} => #{line.strip}" if line =~ /fixme/i
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
#------------------------------------------------------------------------------
|
163
|
+
# Gem Specification
|
164
|
+
#------------------------------------------------------------------------------
|
165
|
+
# Really this is only here to support those who use bundler
|
166
|
+
desc "Build the #{This.name}.gemspec file"
|
167
|
+
task :gemspec do
|
168
|
+
File.open( This.gemspec_file, "wb+" ) do |f|
|
169
|
+
f.write This.platform_gemspec.to_ruby
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
# the gemspec is also a dev artifact and should not be kept around.
|
174
|
+
CLOBBER << This.gemspec_file
|
175
|
+
|
176
|
+
# The standard gem packaging task, everyone has it.
|
177
|
+
require 'rubygems/package_task'
|
178
|
+
Gem::PackageTask.new( This.platform_gemspec ) do
|
179
|
+
# nothing
|
180
|
+
end
|
181
|
+
|
182
|
+
#------------------------------------------------------------------------------
|
183
|
+
# Release - the steps we go through to do a final release, this is pulled from
|
184
|
+
# a compbination of mojombo's rakegem, hoe and hoe-git
|
185
|
+
#
|
186
|
+
# 1) make sure we are on the master branch
|
187
|
+
# 2) make sure there are no uncommitted items
|
188
|
+
# 3) check the manifest and make sure all looks good
|
189
|
+
# 4) build the gem
|
190
|
+
# 5) do an empty commit to have the commit message of the version
|
191
|
+
# 6) tag that commit as the version
|
192
|
+
# 7) push master
|
193
|
+
# 8) push the tag
|
194
|
+
# 7) pus the gem
|
195
|
+
#------------------------------------------------------------------------------
|
196
|
+
task :release_check do
|
197
|
+
unless `git branch` =~ /^\* master$/
|
198
|
+
abort "You must be on the master branch to release!"
|
199
|
+
end
|
200
|
+
unless `git status` =~ /^nothing to commit/m
|
201
|
+
abort "Nope, sorry, you have unfinished business"
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
desc "Create tag v#{This.version}, build and push #{This.platform_gemspec.full_name} to rubygems.org"
|
206
|
+
task :release => [ :release_check, 'manifest:check', :gem ] do
|
207
|
+
sh "git commit --allow-empty -a -m 'Release #{This.version}'"
|
208
|
+
sh "git tag -a -m 'v#{This.version}' v#{This.version}"
|
209
|
+
sh "git push origin master"
|
210
|
+
sh "git push origin v#{This.version}"
|
211
|
+
sh "gem push pkg/#{This.platform_gemspec.full_name}.gem"
|
212
|
+
end
|
data/tasks/this.rb
ADDED
@@ -0,0 +1,202 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
3
|
+
# Public: A Class containing all the metadata and utilities needed to manage a
|
4
|
+
# ruby project.
|
5
|
+
class ThisProject
|
6
|
+
# The name of this project
|
7
|
+
attr_accessor :name
|
8
|
+
|
9
|
+
# The author's name
|
10
|
+
attr_accessor :author
|
11
|
+
|
12
|
+
# The email address of the author(s)
|
13
|
+
attr_accessor :email
|
14
|
+
|
15
|
+
# The homepage of this project
|
16
|
+
attr_accessor :homepage
|
17
|
+
|
18
|
+
# The regex of files to exclude from the manifest
|
19
|
+
attr_accessor :exclude_from_manifest
|
20
|
+
|
21
|
+
# The hash of Gem::Specifications keyed' by platform
|
22
|
+
attr_accessor :gemspecs
|
23
|
+
|
24
|
+
# Public: Initialize ThisProject
|
25
|
+
#
|
26
|
+
# Yields self
|
27
|
+
def initialize(&block)
|
28
|
+
@exclude_from_manifest = %r/tmp$|\.(git|DS_Store)|^(doc|coverage|pkg)|Gemfile*|\.gemspec$|\.swp$|\.jar|\.rvmrc$|~$/
|
29
|
+
@gemspecs = Hash.new
|
30
|
+
yield self if block_given?
|
31
|
+
end
|
32
|
+
|
33
|
+
# Public: return the version of ThisProject
|
34
|
+
#
|
35
|
+
# Search the ruby files in the project looking for the one that has the
|
36
|
+
# version string in it. This does not eval any code in the project, it parses
|
37
|
+
# the source code looking for the string.
|
38
|
+
#
|
39
|
+
# Returns a String version
|
40
|
+
def version
|
41
|
+
[ "lib/#{ name }.rb", "lib/#{ name }/version.rb" ].each do |v|
|
42
|
+
path = project_path( v )
|
43
|
+
line = path.read[/^\s*VERSION\s*=\s*.*/]
|
44
|
+
if line then
|
45
|
+
return line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# Internal: Return a section of an RDoc file with the given section name
|
51
|
+
#
|
52
|
+
# path - the relative path in the project of the file to parse
|
53
|
+
# section_name - the section out of the file from which to parse data
|
54
|
+
#
|
55
|
+
# Retuns the text of the section as an array of paragrphs.
|
56
|
+
def section_of( file, section_name )
|
57
|
+
re = /^=+ (.*)$/
|
58
|
+
sectional = project_path( file )
|
59
|
+
parts = sectional.read.split( re )[1..-1]
|
60
|
+
parts.map! { |p| p.strip }
|
61
|
+
|
62
|
+
sections = Hash.new
|
63
|
+
Hash[*parts].each do |k,v|
|
64
|
+
sections[k] = v.split("\n\n")
|
65
|
+
end
|
66
|
+
return sections[section_name]
|
67
|
+
end
|
68
|
+
|
69
|
+
# Internal: print out a warning about the give task
|
70
|
+
def task_warning( task )
|
71
|
+
warn "WARNING: '#{task}' tasks are not defined. Please run 'rake develop'"
|
72
|
+
end
|
73
|
+
|
74
|
+
# Internal: Return the full path to the file that is relative to the project
|
75
|
+
# root.
|
76
|
+
#
|
77
|
+
# path - the relative path of the file from the project root
|
78
|
+
#
|
79
|
+
# Returns the Pathname of the file
|
80
|
+
def project_path( relative_path )
|
81
|
+
project_root.join( relative_path )
|
82
|
+
end
|
83
|
+
|
84
|
+
# Internal: The absolute path of this file
|
85
|
+
#
|
86
|
+
# Returns the Pathname of this file.
|
87
|
+
def this_file_path
|
88
|
+
Pathname.new( __FILE__ ).expand_path
|
89
|
+
end
|
90
|
+
|
91
|
+
# Internal: The root directory of this project
|
92
|
+
#
|
93
|
+
# This is defined as being the directory that is in the path of this project
|
94
|
+
# that has the first Rakefile
|
95
|
+
#
|
96
|
+
# Returns the Pathname of the directory
|
97
|
+
def project_root
|
98
|
+
this_file_path.ascend do |p|
|
99
|
+
rakefile = p.join( 'Rakefile' )
|
100
|
+
return p if rakefile.exist?
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
# Internal: Returns the contents of the Manifest.txt file as an array
|
105
|
+
#
|
106
|
+
# Returns an Array of strings
|
107
|
+
def manifest
|
108
|
+
manifest_file = project_path( "Manifest.txt" )
|
109
|
+
abort "You need a Manifest.txt" unless manifest_file.readable?
|
110
|
+
manifest_file.readlines.map { |l| l.strip }
|
111
|
+
end
|
112
|
+
|
113
|
+
# Internal: Returns the gemspace associated with the current ruby platform
|
114
|
+
def platform_gemspec
|
115
|
+
gemspecs.fetch( platform, ruby_gemspec )
|
116
|
+
end
|
117
|
+
|
118
|
+
def core_gemspec
|
119
|
+
Gem::Specification.new do |spec|
|
120
|
+
spec.name = name
|
121
|
+
spec.version = version
|
122
|
+
spec.author = author
|
123
|
+
spec.email = email
|
124
|
+
spec.homepage = homepage
|
125
|
+
|
126
|
+
spec.summary = summary
|
127
|
+
spec.description = description
|
128
|
+
|
129
|
+
spec.files = manifest
|
130
|
+
spec.executables = spec.files.grep(/^bin/) { |f| File.basename(f) }
|
131
|
+
spec.test_files = spec.files.grep(/^spec/)
|
132
|
+
|
133
|
+
spec.extra_rdoc_files += spec.files.grep(/(txt|rdoc)$/)
|
134
|
+
spec.rdoc_options = [ "--main" , 'README.rdoc',
|
135
|
+
"--markup", "tomdoc" ]
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
# Internal: Return the gemspec for the ruby platform
|
140
|
+
def ruby_gemspec( core = core_gemspec, &block )
|
141
|
+
yielding_gemspec( 'ruby', core, &block )
|
142
|
+
end
|
143
|
+
|
144
|
+
# Internal: Return the gemspec for the jruby platform
|
145
|
+
def java_gemspec( core = core_gemspec, &block )
|
146
|
+
yielding_gemspec( 'java', core, &block )
|
147
|
+
end
|
148
|
+
|
149
|
+
# Internal: give an initial spec and a key, create a new gemspec based off of
|
150
|
+
# it.
|
151
|
+
#
|
152
|
+
# This will force the new gemspecs 'platform' to be that of the key, since the
|
153
|
+
# only reason you would have multiple gemspecs at this point is to deal with
|
154
|
+
# different platforms.
|
155
|
+
def yielding_gemspec( key, core )
|
156
|
+
spec = gemspecs[key] ||= core.dup
|
157
|
+
spec.platform = key
|
158
|
+
yield spec if block_given?
|
159
|
+
return spec
|
160
|
+
end
|
161
|
+
|
162
|
+
# Internal: Set the recovery gem development dependency
|
163
|
+
#
|
164
|
+
# These are dynamically set since they cannot be hard coded as there is
|
165
|
+
# no way to ship them correctly in the gemspec
|
166
|
+
#
|
167
|
+
# Returns nothing.
|
168
|
+
def set_coverage_gem
|
169
|
+
if RUBY_VERSION < "1.9.0"
|
170
|
+
platform_gemspec.add_development_dependency( 'rcov', '~> 1.0.0' )
|
171
|
+
else
|
172
|
+
platform_gemspec.add_development_dependency( 'simplecov', '~> 0.7.1' )
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
# Internal: Return the platform of ThisProject at the current moment in time.
|
177
|
+
def platform
|
178
|
+
(RUBY_PLATFORM == "java") ? 'java' : Gem::Platform::RUBY
|
179
|
+
end
|
180
|
+
|
181
|
+
# Internal: Return the DESCRIPTION section of the README.rdoc file
|
182
|
+
def description_section
|
183
|
+
section_of( 'README.rdoc', 'DESCRIPTION')
|
184
|
+
end
|
185
|
+
|
186
|
+
# Internal: Return the summary text from the README
|
187
|
+
def summary
|
188
|
+
description_section.first
|
189
|
+
end
|
190
|
+
|
191
|
+
# Internal: Return the full description text from the READEM
|
192
|
+
def description
|
193
|
+
description_section.join(" ").tr("\n", ' ').gsub(/[{}]/,'').gsub(/\[[^\]]+\]/,'') # strip rdoc
|
194
|
+
end
|
195
|
+
|
196
|
+
# Internal: The path to the gemspec file
|
197
|
+
def gemspec_file
|
198
|
+
project_path( "#{ name }.gemspec" )
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
This = ThisProject.new
|