dokkit 0.4.4 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +135 -3
- data/Manifest.txt +9 -2
- data/README.txt +35 -17
- data/Rakefile +12 -8
- data/lib/dokkit.rb +1 -1
- data/lib/dokkit/cache/cache.rb +6 -1
- data/lib/dokkit/environment.rb +1 -0
- data/lib/dokkit/environment/basic.rb +148 -122
- data/lib/dokkit/environment/container.rb +35 -0
- data/lib/dokkit/environment/helpers.rb +43 -0
- data/lib/dokkit/environment/helpers/fileselection.rb +17 -6
- data/lib/dokkit/factory/factory.rb +4 -4
- data/lib/dokkit/filters.rb +1 -0
- data/lib/dokkit/filters/maruku.rb +9 -1
- data/lib/dokkit/filters/yaml.rb +26 -0
- data/lib/dokkit/logging.rb +1 -1
- data/lib/dokkit/resource/document.rb +141 -142
- data/lib/dokkit/resource/extensions/builtin.rb +2 -0
- data/lib/dokkit/resource/extensions/url.rb +1 -1
- data/lib/dokkit/resource/filenamehelper.rb +5 -1
- data/lib/dokkit/tasklib.rb +5 -0
- data/lib/dokkit/tasklib/base.rb +36 -0
- data/lib/dokkit/tasklib/clean.rb +12 -19
- data/lib/dokkit/tasklib/render.rb +20 -24
- data/lib/models/simple/setup/setup.rb +5 -3
- data/tasks/ann.rake +81 -0
- data/tasks/bones.rake +21 -0
- data/tasks/gem.rake +67 -30
- data/tasks/git.rake +41 -0
- data/tasks/manifest.rake +30 -22
- data/tasks/notes.rake +28 -0
- data/tasks/post_load.rake +39 -0
- data/tasks/{doc.rake → rdoc.rake} +11 -9
- data/tasks/rubyforge.rake +12 -12
- data/tasks/setup.rb +189 -72
- data/tasks/spec.rake +24 -9
- data/tasks/svn.rake +15 -11
- data/tasks/test.rake +7 -9
- metadata +14 -7
- data/tasks/annotations.rake +0 -30
data/tasks/git.rake
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# $Id$
|
2
|
+
|
3
|
+
if HAVE_GIT
|
4
|
+
|
5
|
+
namespace :git do
|
6
|
+
|
7
|
+
# A prerequisites task that all other tasks depend upon
|
8
|
+
task :prereqs
|
9
|
+
|
10
|
+
desc 'Show tags from the Git repository'
|
11
|
+
task :show_tags => 'git:prereqs' do |t|
|
12
|
+
puts %x/git tag/
|
13
|
+
end
|
14
|
+
|
15
|
+
desc 'Create a new tag in the Git repository'
|
16
|
+
task :create_tag => 'git:prereqs' do |t|
|
17
|
+
v = ENV['VERSION'] or abort 'Must supply VERSION=x.y.z'
|
18
|
+
abort "Versions don't match #{v} vs #{PROJ.version}" if v != PROJ.version
|
19
|
+
|
20
|
+
tag = "%s-%s" % [PROJ.name, PROJ.version]
|
21
|
+
msg = "Creating tag for #{PROJ.name} version #{PROJ.version}"
|
22
|
+
|
23
|
+
puts "Creating Git tag '#{tag}'"
|
24
|
+
unless system "git tag -a -m '#{msg}' #{tag}"
|
25
|
+
abort "Tag creation failed"
|
26
|
+
end
|
27
|
+
|
28
|
+
if %x/git remote/ =~ %r/^origin\s*$/
|
29
|
+
unless system "git push origin #{tag}"
|
30
|
+
abort "Could not push tag to remote Git repository"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end # namespace :git
|
36
|
+
|
37
|
+
task 'gem:release' => 'git:create_tag'
|
38
|
+
|
39
|
+
end # if HAVE_GIT
|
40
|
+
|
41
|
+
# EOF
|
data/tasks/manifest.rake
CHANGED
@@ -6,36 +6,44 @@ namespace :manifest do
|
|
6
6
|
|
7
7
|
desc 'Verify the manifest'
|
8
8
|
task :check do
|
9
|
-
fn = '
|
10
|
-
files =
|
11
|
-
exclude = Regexp.new(PROJ.exclude.join('|'))
|
12
|
-
Find.find '.' do |path|
|
13
|
-
path.sub! %r/^(\.\/|\/)/o, ''
|
14
|
-
next unless test ?f, path
|
15
|
-
next if path =~ exclude
|
16
|
-
files << path
|
17
|
-
end
|
9
|
+
fn = PROJ.manifest_file + '.tmp'
|
10
|
+
files = manifest_files
|
18
11
|
|
19
|
-
File.open(fn, 'w') {|fp| fp.puts files
|
20
|
-
|
12
|
+
File.open(fn, 'w') {|fp| fp.puts files}
|
13
|
+
lines = %x(#{DIFF} -du #{PROJ.manifest_file} #{fn}).split("\n")
|
14
|
+
if HAVE_FACETS_ANSICODE and ENV.has_key?('TERM')
|
15
|
+
lines.map! do |line|
|
16
|
+
case line
|
17
|
+
when %r/^(-{3}|\+{3})/; nil
|
18
|
+
when %r/^@/; Console::ANSICode.blue line
|
19
|
+
when %r/^\+/; Console::ANSICode.green line
|
20
|
+
when %r/^\-/; Console::ANSICode.red line
|
21
|
+
else line end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
puts lines.compact
|
21
25
|
rm fn rescue nil
|
22
26
|
end
|
23
27
|
|
24
28
|
desc 'Create a new manifest'
|
25
29
|
task :create do
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
path.sub! %r/^(\.\/|\/)/o, ''
|
31
|
-
next unless test ?f, path
|
32
|
-
next if path =~ exclude
|
33
|
-
files << path
|
30
|
+
files = manifest_files
|
31
|
+
unless test(?f, PROJ.manifest_file)
|
32
|
+
files << PROJ.manifest_file
|
33
|
+
files.sort!
|
34
34
|
end
|
35
|
+
File.open(PROJ.manifest_file, 'w') {|fp| fp.puts files}
|
36
|
+
end
|
35
37
|
|
36
|
-
|
37
|
-
|
38
|
+
task :assert do
|
39
|
+
files = manifest_files
|
40
|
+
manifest = File.read(PROJ.manifest_file).split($/)
|
41
|
+
raise "ERROR: #{PROJ.manifest_file} is out of date" unless files == manifest
|
38
42
|
end
|
39
|
-
|
43
|
+
|
44
|
+
end # namespace :manifest
|
45
|
+
|
46
|
+
desc 'Alias to manifest:check'
|
47
|
+
task :manifest => 'manifest:check'
|
40
48
|
|
41
49
|
# EOF
|
data/tasks/notes.rake
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# $Id$
|
2
|
+
|
3
|
+
if HAVE_BONES
|
4
|
+
|
5
|
+
desc "Enumerate all annotations"
|
6
|
+
task :notes do |t|
|
7
|
+
id = if t.application.top_level_tasks.length > 1
|
8
|
+
t.application.top_level_tasks.slice!(1..-1).join(' ')
|
9
|
+
end
|
10
|
+
Bones::AnnotationExtractor.enumerate(
|
11
|
+
PROJ, PROJ.notes.tags.join('|'), id, :tag => true)
|
12
|
+
end
|
13
|
+
|
14
|
+
namespace :notes do
|
15
|
+
PROJ.notes.tags.each do |tag|
|
16
|
+
desc "Enumerate all #{tag} annotations"
|
17
|
+
task tag.downcase.to_sym do |t|
|
18
|
+
id = if t.application.top_level_tasks.length > 1
|
19
|
+
t.application.top_level_tasks.slice!(1..-1).join(' ')
|
20
|
+
end
|
21
|
+
Bones::AnnotationExtractor.enumerate(PROJ, tag, id)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end # if HAVE_BONES
|
27
|
+
|
28
|
+
# EOF
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# $Id$
|
2
|
+
|
3
|
+
# This file does not define any rake tasks. It is used to load some project
|
4
|
+
# settings if they are not defined by the user.
|
5
|
+
|
6
|
+
PROJ.rdoc.exclude << "^#{Regexp.escape(PROJ.manifest_file)}$"
|
7
|
+
PROJ.exclude << ["^#{Regexp.escape(PROJ.ann.file)}$",
|
8
|
+
"^#{Regexp.escape(PROJ.rdoc.dir)}/",
|
9
|
+
"^#{Regexp.escape(PROJ.rcov.dir)}/"]
|
10
|
+
|
11
|
+
flatten_arrays = lambda do |this,os|
|
12
|
+
os.instance_variable_get(:@table).each do |key,val|
|
13
|
+
next if key == :dependencies
|
14
|
+
case val
|
15
|
+
when Array; val.flatten!
|
16
|
+
when OpenStruct; this.call(this,val)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
flatten_arrays.call(flatten_arrays,PROJ)
|
21
|
+
|
22
|
+
PROJ.changes ||= paragraphs_of(PROJ.history_file, 0..1).join("\n\n")
|
23
|
+
|
24
|
+
PROJ.description ||= paragraphs_of(PROJ.readme_file, 'description').join("\n\n")
|
25
|
+
|
26
|
+
PROJ.summary ||= PROJ.description.split('.').first
|
27
|
+
|
28
|
+
PROJ.gem.files ||=
|
29
|
+
if test(?f, PROJ.manifest_file)
|
30
|
+
files = File.readlines(PROJ.manifest_file).map {|fn| fn.chomp.strip}
|
31
|
+
files.delete ''
|
32
|
+
files
|
33
|
+
else [] end
|
34
|
+
|
35
|
+
PROJ.gem.executables ||= PROJ.gem.files.find_all {|fn| fn =~ %r/^bin/}
|
36
|
+
|
37
|
+
PROJ.rdoc.main ||= PROJ.readme_file
|
38
|
+
|
39
|
+
# EOF
|
@@ -6,13 +6,13 @@ namespace :doc do
|
|
6
6
|
|
7
7
|
desc 'Generate RDoc documentation'
|
8
8
|
Rake::RDocTask.new do |rd|
|
9
|
-
|
10
|
-
rd.
|
11
|
-
rd.rdoc_dir =
|
9
|
+
rdoc = PROJ.rdoc
|
10
|
+
rd.main = rdoc.main
|
11
|
+
rd.rdoc_dir = rdoc.dir
|
12
12
|
|
13
|
-
incl = Regexp.new(
|
14
|
-
excl = Regexp.new(
|
15
|
-
files = PROJ.files.find_all do |fn|
|
13
|
+
incl = Regexp.new(rdoc.include.join('|'))
|
14
|
+
excl = Regexp.new(rdoc.exclude.join('|'))
|
15
|
+
files = PROJ.gem.files.find_all do |fn|
|
16
16
|
case fn
|
17
17
|
when excl; false
|
18
18
|
when incl; true
|
@@ -21,9 +21,12 @@ namespace :doc do
|
|
21
21
|
rd.rdoc_files.push(*files)
|
22
22
|
|
23
23
|
title = "#{PROJ.name}-#{PROJ.version} Documentation"
|
24
|
-
|
24
|
+
|
25
|
+
rf_name = PROJ.rubyforge.name
|
26
|
+
title = "#{rf_name}'s " + title if rf_name.valid? and rf_name != title
|
25
27
|
|
26
28
|
rd.options << "-t #{title}"
|
29
|
+
rd.options.concat(rdoc.opts)
|
27
30
|
end
|
28
31
|
|
29
32
|
desc 'Generate ri locally for testing'
|
@@ -31,7 +34,6 @@ namespace :doc do
|
|
31
34
|
sh "#{RDOC} --ri -o ri ."
|
32
35
|
end
|
33
36
|
|
34
|
-
desc 'Remove ri products'
|
35
37
|
task :clobber_ri do
|
36
38
|
rm_r 'ri' rescue nil
|
37
39
|
end
|
@@ -44,6 +46,6 @@ task :doc => 'doc:rdoc'
|
|
44
46
|
desc 'Remove all build products'
|
45
47
|
task :clobber => %w(doc:clobber_rdoc doc:clobber_ri)
|
46
48
|
|
47
|
-
remove_desc_for_task %w(doc:clobber_rdoc
|
49
|
+
remove_desc_for_task %w(doc:clobber_rdoc)
|
48
50
|
|
49
51
|
# EOF
|
data/tasks/rubyforge.rake
CHANGED
@@ -1,23 +1,23 @@
|
|
1
|
-
# $Id$
|
2
1
|
|
3
|
-
if PROJ.
|
2
|
+
if PROJ.rubyforge.name.valid? && HAVE_RUBYFORGE
|
4
3
|
|
5
4
|
require 'rubyforge'
|
6
5
|
require 'rake/contrib/sshpublisher'
|
7
6
|
|
8
7
|
namespace :gem do
|
9
8
|
desc 'Package and upload to RubyForge'
|
10
|
-
task :release => [:clobber, :package] do |t|
|
9
|
+
task :release => [:clobber, 'gem:package'] do |t|
|
11
10
|
v = ENV['VERSION'] or abort 'Must supply VERSION=x.y.z'
|
12
11
|
abort "Versions don't match #{v} vs #{PROJ.version}" if v != PROJ.version
|
13
|
-
pkg = "pkg/#{PROJ.
|
12
|
+
pkg = "pkg/#{PROJ.gem._spec.full_name}"
|
14
13
|
|
15
14
|
if $DEBUG then
|
16
|
-
puts "release_id = rf.add_release #{PROJ.
|
17
|
-
puts "rf.add_file #{PROJ.
|
15
|
+
puts "release_id = rf.add_release #{PROJ.rubyforge.name.inspect}, #{PROJ.name.inspect}, #{PROJ.version.inspect}, \"#{pkg}.tgz\""
|
16
|
+
puts "rf.add_file #{PROJ.rubyforge.name.inspect}, #{PROJ.name.inspect}, release_id, \"#{pkg}.gem\""
|
18
17
|
end
|
19
18
|
|
20
19
|
rf = RubyForge.new
|
20
|
+
rf.configure rescue nil
|
21
21
|
puts 'Logging in'
|
22
22
|
rf.login
|
23
23
|
|
@@ -26,12 +26,12 @@ namespace :gem do
|
|
26
26
|
c['release_changes'] = PROJ.changes if PROJ.changes
|
27
27
|
c['preformatted'] = true
|
28
28
|
|
29
|
-
files = [(PROJ.need_tar ? "#{pkg}.tgz" : nil),
|
30
|
-
(PROJ.need_zip ? "#{pkg}.zip" : nil),
|
29
|
+
files = [(PROJ.gem.need_tar ? "#{pkg}.tgz" : nil),
|
30
|
+
(PROJ.gem.need_zip ? "#{pkg}.zip" : nil),
|
31
31
|
"#{pkg}.gem"].compact
|
32
32
|
|
33
33
|
puts "Releasing #{PROJ.name} v. #{PROJ.version}"
|
34
|
-
rf.add_release PROJ.
|
34
|
+
rf.add_release PROJ.rubyforge.name, PROJ.name, PROJ.version, *files
|
35
35
|
end
|
36
36
|
end # namespace :gem
|
37
37
|
|
@@ -44,9 +44,9 @@ namespace :doc do
|
|
44
44
|
)
|
45
45
|
|
46
46
|
host = "#{config['username']}@rubyforge.org"
|
47
|
-
remote_dir = "/var/www/gforge-projects/#{PROJ.
|
48
|
-
remote_dir << PROJ.
|
49
|
-
local_dir = PROJ.
|
47
|
+
remote_dir = "/var/www/gforge-projects/#{PROJ.rubyforge.name}/"
|
48
|
+
remote_dir << PROJ.rdoc.remote_dir if PROJ.rdoc.remote_dir
|
49
|
+
local_dir = PROJ.rdoc.dir
|
50
50
|
|
51
51
|
Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
|
52
52
|
end
|
data/tasks/setup.rb
CHANGED
@@ -2,76 +2,123 @@
|
|
2
2
|
|
3
3
|
require 'rubygems'
|
4
4
|
require 'rake'
|
5
|
+
require 'rake/clean'
|
5
6
|
require 'fileutils'
|
6
7
|
require 'ostruct'
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
PROJ
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
#
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
9
|
+
class OpenStruct; undef :gem; end
|
10
|
+
|
11
|
+
PROJ = OpenStruct.new(
|
12
|
+
# Project Defaults
|
13
|
+
:name => nil,
|
14
|
+
:summary => nil,
|
15
|
+
:description => nil,
|
16
|
+
:changes => nil,
|
17
|
+
:authors => nil,
|
18
|
+
:email => nil,
|
19
|
+
:url => "\000",
|
20
|
+
:version => ENV['VERSION'] || '0.0.0',
|
21
|
+
:exclude => %w(tmp$ bak$ ~$ CVS \.svn/ \.git/ ^pkg/),
|
22
|
+
:release_name => ENV['RELEASE'],
|
23
|
+
|
24
|
+
# System Defaults
|
25
|
+
:ruby_opts => %w(-w),
|
26
|
+
:libs => [],
|
27
|
+
:history_file => 'History.txt',
|
28
|
+
:manifest_file => 'Manifest.txt',
|
29
|
+
:readme_file => 'README.txt',
|
30
|
+
|
31
|
+
# Announce
|
32
|
+
:ann => OpenStruct.new(
|
33
|
+
:file => 'announcement.txt',
|
34
|
+
:text => nil,
|
35
|
+
:paragraphs => [],
|
36
|
+
:email => {
|
37
|
+
:from => nil,
|
38
|
+
:to => %w(ruby-talk@ruby-lang.org),
|
39
|
+
:server => 'localhost',
|
40
|
+
:port => 25,
|
41
|
+
:domain => ENV['HOSTNAME'],
|
42
|
+
:acct => nil,
|
43
|
+
:passwd => nil,
|
44
|
+
:authtype => :plain
|
45
|
+
}
|
46
|
+
),
|
47
|
+
|
48
|
+
# Gem Packaging
|
49
|
+
:gem => OpenStruct.new(
|
50
|
+
:dependencies => [],
|
51
|
+
:executables => nil,
|
52
|
+
:extensions => FileList['ext/**/extconf.rb'],
|
53
|
+
:files => nil,
|
54
|
+
:need_tar => true,
|
55
|
+
:need_zip => false,
|
56
|
+
:extras => {}
|
57
|
+
),
|
58
|
+
|
59
|
+
# File Annotations
|
60
|
+
:notes => OpenStruct.new(
|
61
|
+
:exclude => %w(^tasks/setup\.rb$),
|
62
|
+
:extensions => %w(.txt .rb .erb) << '',
|
63
|
+
:tags => %w(FIXME OPTIMIZE TODO)
|
64
|
+
),
|
65
|
+
|
66
|
+
# Rcov
|
67
|
+
:rcov => OpenStruct.new(
|
68
|
+
:dir => 'coverage',
|
69
|
+
:opts => %w[--sort coverage -T],
|
70
|
+
:threshold => 90.0,
|
71
|
+
:threshold_exact => false
|
72
|
+
),
|
73
|
+
|
74
|
+
# Rdoc
|
75
|
+
:rdoc => OpenStruct.new(
|
76
|
+
:opts => [],
|
77
|
+
:include => %w(^lib/ ^bin/ ^ext/ \.txt$),
|
78
|
+
:exclude => %w(extconf\.rb$),
|
79
|
+
:main => nil,
|
80
|
+
:dir => 'doc',
|
81
|
+
:remote_dir => nil
|
82
|
+
),
|
46
83
|
|
47
|
-
#
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
84
|
+
# Rubyforge
|
85
|
+
:rubyforge => OpenStruct.new(
|
86
|
+
:name => "\000"
|
87
|
+
),
|
88
|
+
|
89
|
+
# Rspec
|
90
|
+
:spec => OpenStruct.new(
|
91
|
+
:files => FileList['spec/**/*_spec.rb'],
|
92
|
+
:opts => []
|
93
|
+
),
|
94
|
+
|
95
|
+
# Subversion Repository
|
96
|
+
:svn => OpenStruct.new(
|
97
|
+
:root => nil,
|
98
|
+
:path => '',
|
99
|
+
:trunk => 'trunk',
|
100
|
+
:tags => 'tags',
|
101
|
+
:branches => 'branches'
|
102
|
+
),
|
103
|
+
|
104
|
+
# Test::Unit
|
105
|
+
:test => OpenStruct.new(
|
106
|
+
:files => FileList['test/**/test_*.rb'],
|
107
|
+
:file => 'test/all.rb',
|
108
|
+
:opts => []
|
109
|
+
)
|
110
|
+
)
|
69
111
|
|
70
112
|
# Load the other rake files in the tasks folder
|
71
|
-
Dir.glob('tasks/*.rake').sort
|
113
|
+
rakefiles = Dir.glob('tasks/*.rake').sort
|
114
|
+
rakefiles.unshift(rakefiles.delete('tasks/post_load.rake')).compact!
|
115
|
+
import(*rakefiles)
|
116
|
+
|
117
|
+
# Setup the project libraries
|
118
|
+
%w(lib ext).each {|dir| PROJ.libs << dir if test ?d, dir}
|
72
119
|
|
73
120
|
# Setup some constants
|
74
|
-
WIN32 = %r/
|
121
|
+
WIN32 = %r/djgpp|(cyg|ms|bcc)win|mingw/ =~ RUBY_PLATFORM unless defined? WIN32
|
75
122
|
|
76
123
|
DEV_NULL = WIN32 ? 'NUL:' : '/dev/null'
|
77
124
|
|
@@ -83,6 +130,7 @@ def quiet( &block )
|
|
83
130
|
ensure
|
84
131
|
STDOUT.reopen io.first
|
85
132
|
STDERR.reopen io.last
|
133
|
+
$stdout, $stderr = STDOUT, STDERR
|
86
134
|
end
|
87
135
|
|
88
136
|
DIFF = if WIN32 then 'diff.exe'
|
@@ -97,10 +145,11 @@ SUDO = if WIN32 then ''
|
|
97
145
|
else '' end
|
98
146
|
end
|
99
147
|
|
100
|
-
RCOV = WIN32 ? 'rcov.
|
101
|
-
|
148
|
+
RCOV = WIN32 ? 'rcov.bat' : 'rcov'
|
149
|
+
RDOC = WIN32 ? 'rdoc.bat' : 'rdoc'
|
150
|
+
GEM = WIN32 ? 'gem.bat' : 'gem'
|
102
151
|
|
103
|
-
%w(rcov spec/rake/spectask rubyforge bones).each do |lib|
|
152
|
+
%w(rcov spec/rake/spectask rubyforge bones facets/ansicode).each do |lib|
|
104
153
|
begin
|
105
154
|
require lib
|
106
155
|
Object.instance_eval {const_set "HAVE_#{lib.tr('/','_').upcase}", true}
|
@@ -108,6 +157,10 @@ GEM = WIN32 ? 'gem.cmd' : 'gem'
|
|
108
157
|
Object.instance_eval {const_set "HAVE_#{lib.tr('/','_').upcase}", false}
|
109
158
|
end
|
110
159
|
end
|
160
|
+
HAVE_SVN = (Dir.entries(Dir.pwd).include?('.svn') and
|
161
|
+
system("svn --version 2>&1 > #{DEV_NULL}"))
|
162
|
+
HAVE_GIT = (Dir.entries(Dir.pwd).include?('.git') and
|
163
|
+
system("git --version 2>&1 > #{DEV_NULL}"))
|
111
164
|
|
112
165
|
# Reads a file at +path+ and spits out an array of the +paragraphs+
|
113
166
|
# specified.
|
@@ -115,8 +168,28 @@ end
|
|
115
168
|
# changes = paragraphs_of('History.txt', 0..1).join("\n\n")
|
116
169
|
# summary, *description = paragraphs_of('README.txt', 3, 3..8)
|
117
170
|
#
|
118
|
-
def paragraphs_of(path, *paragraphs)
|
119
|
-
|
171
|
+
def paragraphs_of( path, *paragraphs )
|
172
|
+
title = String === paragraphs.first ? paragraphs.shift : nil
|
173
|
+
ary = File.read(path).delete("\r").split(/\n\n+/)
|
174
|
+
|
175
|
+
result = if title
|
176
|
+
tmp, matching = [], false
|
177
|
+
rgxp = %r/^=+\s*#{Regexp.escape(title)}/i
|
178
|
+
paragraphs << (0..-1) if paragraphs.empty?
|
179
|
+
|
180
|
+
ary.each do |val|
|
181
|
+
if val =~ rgxp
|
182
|
+
break if matching
|
183
|
+
matching = true
|
184
|
+
rgxp = %r/^=+/i
|
185
|
+
elsif matching
|
186
|
+
tmp << val
|
187
|
+
end
|
188
|
+
end
|
189
|
+
tmp
|
190
|
+
else ary end
|
191
|
+
|
192
|
+
result.values_at(*paragraphs)
|
120
193
|
end
|
121
194
|
|
122
195
|
# Adds the given gem _name_ to the current project's dependency list. An
|
@@ -127,14 +200,19 @@ def depend_on( name, version = nil )
|
|
127
200
|
spec = Gem.source_index.find_name(name).last
|
128
201
|
version = spec.version.to_s if version.nil? and !spec.nil?
|
129
202
|
|
130
|
-
PROJ.dependencies <<
|
203
|
+
PROJ.gem.dependencies << case version
|
204
|
+
when nil; [name]
|
205
|
+
when %r/^\d/; [name, ">= #{version}"]
|
206
|
+
else [name, version] end
|
131
207
|
end
|
132
208
|
|
133
|
-
# Adds the given
|
209
|
+
# Adds the given arguments to the include path if they are not already there
|
134
210
|
#
|
135
|
-
def ensure_in_path(
|
136
|
-
|
137
|
-
|
211
|
+
def ensure_in_path( *args )
|
212
|
+
args.each do |path|
|
213
|
+
path = File.expand_path(path)
|
214
|
+
$:.unshift(path) if test(?d, path) and not $:.include?(path)
|
215
|
+
end
|
138
216
|
end
|
139
217
|
|
140
218
|
# Find a rake task using the task name and remove any description text. This
|
@@ -148,4 +226,43 @@ def remove_desc_for_task( names )
|
|
148
226
|
end
|
149
227
|
end
|
150
228
|
|
229
|
+
# Change working directories to _dir_, call the _block_ of code, and then
|
230
|
+
# change back to the original working directory (the current directory when
|
231
|
+
# this method was called).
|
232
|
+
#
|
233
|
+
def in_directory( dir, &block )
|
234
|
+
curdir = pwd
|
235
|
+
begin
|
236
|
+
cd dir
|
237
|
+
return block.call
|
238
|
+
ensure
|
239
|
+
cd curdir
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
# Scans the current working directory and creates a list of files that are
|
244
|
+
# candidates to be in the manifest.
|
245
|
+
#
|
246
|
+
def manifest_files
|
247
|
+
files = []
|
248
|
+
exclude = Regexp.new(PROJ.exclude.join('|'))
|
249
|
+
Find.find '.' do |path|
|
250
|
+
path.sub! %r/^(\.\/|\/)/o, ''
|
251
|
+
next unless test ?f, path
|
252
|
+
next if path =~ exclude
|
253
|
+
files << path
|
254
|
+
end
|
255
|
+
files.sort!
|
256
|
+
end
|
257
|
+
|
258
|
+
# We need a "valid" method thtat determines if a string is suitable for use
|
259
|
+
# in the gem specification.
|
260
|
+
#
|
261
|
+
class Object
|
262
|
+
def valid?
|
263
|
+
return !(self.empty? or self == "\000") if self.respond_to?(:to_str)
|
264
|
+
return false
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
151
268
|
# EOF
|