reap 4.3.3 → 4.3.4
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/COPYING +400 -8
- data/ProjectInfo +26 -26
- data/ProjectInfo.rb +88 -0
- data/bin/reap +1 -1
- data/bin/rubytest +1 -1
- data/data/reap/scaffold/standard/COPYING +403 -0
- data/data/reap/scaffold/{ChangeLog → standard/ChangeLog} +0 -0
- data/data/reap/scaffold/standard/INSTALL +14 -0
- data/data/reap/scaffold/{ProjectInfo → standard/ProjectInfo} +12 -12
- data/data/reap/scaffold/standard/README +3 -0
- data/data/reap/scaffold/standard/Rakefile +10 -0
- data/data/reap/scaffold/{INSTALL → standard/TODO} +0 -0
- data/data/reap/scaffold/subversion/trunk/COPYING +403 -0
- data/data/reap/scaffold/{README → subversion/trunk/ChangeLog} +0 -0
- data/data/reap/scaffold/subversion/trunk/INSTALL +14 -0
- data/data/reap/scaffold/subversion/trunk/ProjectInfo +78 -0
- data/data/reap/scaffold/subversion/trunk/README +3 -0
- data/data/reap/scaffold/subversion/trunk/Rakefile +10 -0
- data/data/reap/scaffold/{Todo → subversion/trunk/TODO} +0 -0
- data/data/reap/{setup-3.4.1/setup.rb → setup.rb} +181 -202
- data/{ChangeLog → doc/ChangeLog} +0 -0
- data/doc/doap.xml +27 -0
- data/doc/note/Rakefile.htm +69 -0
- data/{note/Rakefile → doc/note/aRakefile} +0 -0
- data/{note → doc/note}/composite_task.rb +0 -0
- data/{note → doc/note}/compositepublisher.rb +0 -0
- data/{note → doc/note}/ftptools.rb +0 -0
- data/{note → doc/note}/interface/interface.rb +0 -0
- data/{note → doc/note}/interface/rubyforge.rb +0 -0
- data/{note → doc/note}/license-each.rb +0 -0
- data/{note → doc/note}/package.rb.0 +0 -0
- data/{note → doc/note}/publisher.rb +0 -0
- data/{note → doc/note}/rubyforgepublisher.rb +0 -0
- data/{lib/reap/task → doc/note}/scaffold.rb +4 -3
- data/{lib/reap → doc/note}/setup.rb +7 -6
- data/{note → doc/note}/sshpublisher.rb +0 -0
- data/{note → doc/note}/suby-cvs.rb +0 -0
- data/{note → doc/note}/template.rb +0 -0
- data/lib/reap/bin/reap.rb +75 -51
- data/lib/reap/bin/{lint.rb → rubylint.rb} +0 -0
- data/lib/reap/projectinfo.rb +107 -50
- data/lib/reap/reap.rb +60 -0
- data/lib/reap/task.rb +46 -60
- data/lib/reap/task/doap.rb +67 -0
- data/lib/reap/task/info.rb +2 -2
- data/lib/reap/task/install.rb +29 -18
- data/lib/reap/task/package.rb +56 -56
- data/lib/reap/task/release.rb +34 -13
- data/package.rb +627 -0
- data/setup.rb +287 -272
- data/test/tc_reap.rb +1 -1
- metadata +64 -61
- data/ANN +0 -8
- data/data/reap/scaffold/COPYING +0 -11
- data/data/reap/scaffold/Rakefile +0 -146
- data/data/reap/scaffold/setup.rb +0 -1551
- data/data/reap/setup-3.4.1/COPYING +0 -515
- data/data/reap/setup-3.4.1/ChangeLog +0 -732
- data/data/reap/setup-3.4.1/Makefile +0 -56
- data/data/reap/setup-3.4.1/NEWS.en +0 -155
- data/data/reap/setup-3.4.1/NEWS.ja +0 -152
- data/data/reap/setup-3.4.1/README.en +0 -30
- data/data/reap/setup-3.4.1/README.ja +0 -34
- data/data/reap/setup-3.4.1/TODO +0 -14
- data/data/reap/setup-3.4.1/Template.README.en +0 -41
- data/data/reap/setup-3.4.1/Template.README.ja +0 -46
- data/data/reap/setup-3.4.1/Usage_en.txt +0 -231
- data/data/reap/setup-3.4.1/Usage_ja.txt +0 -250
- data/data/reap/setup-3.4.1/doc.en/hookapi.html +0 -91
- data/data/reap/setup-3.4.1/doc.en/index.html +0 -28
- data/data/reap/setup-3.4.1/doc.en/metaconfapi.html +0 -79
- data/data/reap/setup-3.4.1/doc.en/news.html +0 -189
- data/data/reap/setup-3.4.1/doc.en/usage.html +0 -297
- data/data/reap/setup-3.4.1/doc.ja/hookapi.html +0 -84
- data/data/reap/setup-3.4.1/doc.ja/index.html +0 -28
- data/data/reap/setup-3.4.1/doc.ja/metaconfapi.html +0 -80
- data/data/reap/setup-3.4.1/doc.ja/news.html +0 -186
- data/data/reap/setup-3.4.1/doc.ja/usage.html +0 -319
- data/data/reap/setup-3.4.1/sample/add-task.rb +0 -15
- data/data/reap/setup-3.4.1/test/test_installer.rb +0 -136
data/{ChangeLog → doc/ChangeLog}
RENAMED
|
File without changes
|
data/doc/doap.xml
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<Project xmlns="http://usefulinc.com/ns/doap#"
|
|
2
|
+
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
|
3
|
+
xmlns:foaf="http://xmlns.com/foaf/0.1/">
|
|
4
|
+
<name>Reap</name>
|
|
5
|
+
<shortname>reap</shortname>
|
|
6
|
+
<homepage rdf:resource="http://reap.rubyforge.org" />
|
|
7
|
+
<wiki rdf:resource="" />
|
|
8
|
+
<created>2004-04-01</created>
|
|
9
|
+
<shortdesc xml:lang="en">
|
|
10
|
+
Tools for Ruby project testing, management and
|
|
11
|
+
assistance.
|
|
12
|
+
</shortdesc>
|
|
13
|
+
<description xml:lang="en">
|
|
14
|
+
Reap comprises a set of commonly needed tools for
|
|
15
|
+
Ruby package developers/deployers. Because of the
|
|
16
|
+
commonality, Reap utilizes a YAML configuration
|
|
17
|
+
file to harvest project information, significantly
|
|
18
|
+
simplifying usage.
|
|
19
|
+
</description>
|
|
20
|
+
<maintainer>
|
|
21
|
+
<foaf:Person>
|
|
22
|
+
<foaf:name>Thomas Sawyer</foaf:name>
|
|
23
|
+
<foaf:email>transfire@gmail.com</foaf:name>
|
|
24
|
+
<foaf:homepage rdf:resource="http://reap.rubyforge.org" />
|
|
25
|
+
</foaf:Person>
|
|
26
|
+
</maintainer>
|
|
27
|
+
</Project>
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Rakefile for xoxo-rb. -*-ruby-*-
|
|
2
|
+
require 'rake/rdoctask'
|
|
3
|
+
require 'rake/testtask'
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
desc "Run all the tests"
|
|
7
|
+
task :default => [:test]
|
|
8
|
+
|
|
9
|
+
desc "Do predistribution stuff"
|
|
10
|
+
task :predist => [:chmod, :changelog, :doc]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
desc "Run all the tests"
|
|
14
|
+
Rake::TestTask.new do |t|
|
|
15
|
+
t.libs << "test"
|
|
16
|
+
t.test_files = FileList['test_*.rb']
|
|
17
|
+
t.verbose = true
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
desc "Make an archive as .tar.gz"
|
|
21
|
+
task :dist => :test do
|
|
22
|
+
system "export DARCS_REPO=#{File.expand_path "."}; " +
|
|
23
|
+
"darcs dist -d xoxo-rb#{get_darcs_tree_version}"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
desc "Make binaries executable"
|
|
27
|
+
task :chmod do
|
|
28
|
+
Dir["bin/*"].each { |binary| File.chmod(0775, binary) }
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
desc "Generate a ChangeLog"
|
|
32
|
+
task :changelog do
|
|
33
|
+
system "darcs changes --repo=#{ENV["DARCS_REPO"] || "."} >ChangeLog"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
desc "Generate RDoc documentation"
|
|
37
|
+
Rake::RDocTask.new(:doc) do |rdoc|
|
|
38
|
+
rdoc.options << '--line-numbers --inline-source'
|
|
39
|
+
rdoc.rdoc_dir = "rdoc"
|
|
40
|
+
rdoc.rdoc_files.include 'README'
|
|
41
|
+
rdoc.rdoc_files.include 'xoxo.rb'
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
# Helper to retrieve the "revision number" of the darcs tree.
|
|
46
|
+
def get_darcs_tree_version
|
|
47
|
+
return "" unless File.directory? "_darcs"
|
|
48
|
+
|
|
49
|
+
changes = `darcs changes`
|
|
50
|
+
count = 0
|
|
51
|
+
tag = "0.0"
|
|
52
|
+
|
|
53
|
+
changes.each("\n\n") { |change|
|
|
54
|
+
head, title, desc = change.split("\n", 3)
|
|
55
|
+
|
|
56
|
+
if title =~ /^ \*/
|
|
57
|
+
# Normal change.
|
|
58
|
+
count += 1
|
|
59
|
+
elsif title =~ /tagged (.*)/
|
|
60
|
+
# Tag. We look for these.
|
|
61
|
+
tag = $1
|
|
62
|
+
break
|
|
63
|
+
else
|
|
64
|
+
warn "Unparsable change: #{change}"
|
|
65
|
+
end
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
"-" + tag + "." + count.to_s
|
|
69
|
+
end
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
module Scaffold
|
|
12
12
|
extend self
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
SVNPaths => %w{
|
|
15
15
|
trunk
|
|
16
16
|
branch
|
|
17
17
|
tag
|
|
@@ -23,10 +23,11 @@ module Scaffold
|
|
|
23
23
|
bin
|
|
24
24
|
lib
|
|
25
25
|
ext
|
|
26
|
-
|
|
26
|
+
conf
|
|
27
27
|
data
|
|
28
28
|
test
|
|
29
|
-
|
|
29
|
+
note
|
|
30
|
+
sample
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
TrunkFiles = %w{
|
|
@@ -57,7 +57,7 @@ class ConfigTable
|
|
|
57
57
|
@config_opt = nil
|
|
58
58
|
@verbose = true
|
|
59
59
|
@no_harm = false
|
|
60
|
-
@libsrc_pattern = '*.rb'
|
|
60
|
+
@libsrc_pattern = '*.rb' # THIS IS NOT GOOD!!!
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
attr_accessor :install_prefix
|
|
@@ -637,8 +637,8 @@ module FileOperations
|
|
|
637
637
|
f.write str
|
|
638
638
|
}
|
|
639
639
|
File.chmod mode, realdest
|
|
640
|
-
|
|
641
|
-
File.open("#{objdir_root()}/InstalledFiles", 'a') {|f|
|
|
640
|
+
# 0777
|
|
641
|
+
File.open("#{objdir_root()}/InstalledFiles", 'a', 0777) {|f|
|
|
642
642
|
if prefix
|
|
643
643
|
f.puts realdest.sub(prefix, '')
|
|
644
644
|
else
|
|
@@ -662,7 +662,7 @@ module FileOperations
|
|
|
662
662
|
def ruby(*args)
|
|
663
663
|
command config('rubyprog'), *args
|
|
664
664
|
end
|
|
665
|
-
|
|
665
|
+
|
|
666
666
|
def make(task = nil)
|
|
667
667
|
command(*[config('makeprog'), task].compact)
|
|
668
668
|
end
|
|
@@ -725,7 +725,7 @@ module HookScriptAPI
|
|
|
725
725
|
def srcdirectory?(path)
|
|
726
726
|
File.dir?(srcfile(path))
|
|
727
727
|
end
|
|
728
|
-
|
|
728
|
+
|
|
729
729
|
def srcfile?(path)
|
|
730
730
|
File.file?(srcfile(path))
|
|
731
731
|
end
|
|
@@ -831,7 +831,7 @@ class ToplevelInstaller
|
|
|
831
831
|
__send__ "exec_#{task}"
|
|
832
832
|
end
|
|
833
833
|
end
|
|
834
|
-
|
|
834
|
+
|
|
835
835
|
def run_metaconfigs
|
|
836
836
|
@config.load_script "#{@ardir}/metaconfig"
|
|
837
837
|
end
|
|
@@ -1310,6 +1310,7 @@ class Installer
|
|
|
1310
1310
|
end
|
|
1311
1311
|
|
|
1312
1312
|
def install_dir_lib(rel)
|
|
1313
|
+
p rubyscripts(), "#{config('rbdir')}/#{rel}", 0644
|
|
1313
1314
|
install_files rubyscripts(), "#{config('rbdir')}/#{rel}", 0644
|
|
1314
1315
|
end
|
|
1315
1316
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
data/lib/reap/bin/reap.rb
CHANGED
|
@@ -3,34 +3,14 @@
|
|
|
3
3
|
require 'rbconfig'
|
|
4
4
|
|
|
5
5
|
require 'facets'
|
|
6
|
-
require '
|
|
6
|
+
require 'consoleapp'
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
require 'reap/projectinfo'
|
|
8
|
+
require 'reap/reap'
|
|
10
9
|
|
|
11
|
-
# Reap tasks
|
|
12
|
-
require 'reap/task/fileperm'
|
|
13
|
-
require 'reap/task/test'
|
|
14
|
-
require 'reap/task/testext'
|
|
15
|
-
require 'reap/task/rdoc'
|
|
16
|
-
require 'reap/task/announce'
|
|
17
|
-
require 'reap/task/package'
|
|
18
|
-
require 'reap/task/publish'
|
|
19
|
-
require 'reap/task/info'
|
|
20
|
-
require 'reap/task/install'
|
|
21
|
-
require 'reap/task/release'
|
|
22
|
-
#require 'reap/task/noop'
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
Reap.register
|
|
26
|
-
|
|
27
|
-
module Reap
|
|
28
|
-
Version = "1.2.0"
|
|
29
|
-
end
|
|
30
10
|
|
|
31
11
|
class ReapCommand < Console::Application
|
|
32
12
|
|
|
33
|
-
# to do first for
|
|
13
|
+
# to do first for every task
|
|
34
14
|
#def application_setup
|
|
35
15
|
# $PROJECT_INFO = ProjectInfo.new( $PROJECT_FILE )
|
|
36
16
|
#end
|
|
@@ -41,15 +21,22 @@ class ReapCommand < Console::Application
|
|
|
41
21
|
def __verbose ; $VERBOSE = true ; end
|
|
42
22
|
alias_method :_V, :__verbose
|
|
43
23
|
|
|
44
|
-
#
|
|
45
|
-
def
|
|
46
|
-
alias_method :
|
|
24
|
+
# option to display help
|
|
25
|
+
def __force ; $FORCE = true ; end
|
|
26
|
+
alias_method :_f, :__force
|
|
47
27
|
|
|
48
28
|
# pretend mode (under construction)
|
|
49
29
|
def __pretend; $PRETEND = true ; end
|
|
50
30
|
alias_method :_P, :__pretend
|
|
51
31
|
|
|
52
|
-
#
|
|
32
|
+
# debug mode (under construction)
|
|
33
|
+
def __debug; $DEBUG = true ; end
|
|
34
|
+
alias_method :_D, :__debug
|
|
35
|
+
|
|
36
|
+
def __password( pass ); $PASSWORD = pass ; end
|
|
37
|
+
alias_method :_p, :__password
|
|
38
|
+
|
|
39
|
+
# display reap version
|
|
53
40
|
def __version ; version ; end
|
|
54
41
|
alias_method :_v, :__version
|
|
55
42
|
|
|
@@ -67,10 +54,6 @@ class ReapCommand < Console::Application
|
|
|
67
54
|
#def _f( pif ) ; $PROJECT_FILE = pif ; end
|
|
68
55
|
#alias_method :_f, :__file
|
|
69
56
|
|
|
70
|
-
# option for require
|
|
71
|
-
#def __require(r); @require = r ; end
|
|
72
|
-
#alias_method :_r, :__require
|
|
73
|
-
|
|
74
57
|
# Commands
|
|
75
58
|
|
|
76
59
|
# default action
|
|
@@ -109,12 +92,15 @@ class ReapCommand < Console::Application
|
|
|
109
92
|
# list available tasks
|
|
110
93
|
|
|
111
94
|
def tasks
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
95
|
+
if Reap.projectfile?
|
|
96
|
+
puts
|
|
97
|
+
Reap.tasks.each do |name,task_class|
|
|
98
|
+
puts " #{name}".ljust(20) + "#{task_class.task_desc}"
|
|
99
|
+
end
|
|
100
|
+
puts
|
|
101
|
+
else
|
|
102
|
+
puts "No project information file found."
|
|
116
103
|
end
|
|
117
|
-
puts
|
|
118
104
|
exit 0
|
|
119
105
|
end
|
|
120
106
|
alias_method :ls, :tasks
|
|
@@ -122,23 +108,50 @@ class ReapCommand < Console::Application
|
|
|
122
108
|
# copy the file from lib/data to the current dir.
|
|
123
109
|
|
|
124
110
|
def template
|
|
125
|
-
|
|
126
|
-
|
|
111
|
+
f = nil
|
|
112
|
+
if ::ProjectInfo::INFO_FILES.any?{ |f| File.exists?(f) }
|
|
113
|
+
puts "Project file '#{f}' already exists."
|
|
127
114
|
exit 0
|
|
128
115
|
end
|
|
129
116
|
filename = 'ProjectInfo'
|
|
130
|
-
|
|
117
|
+
# need to add gems workaround
|
|
118
|
+
dir = File.join( ::Config::CONFIG['datadir'], 'reap', 'scaffold', 'standard' )
|
|
131
119
|
f = File.join( dir, filename )
|
|
132
120
|
raise "ProjectInfo template file #{f} is missing." unless File.file?( f )
|
|
133
121
|
# copy
|
|
134
|
-
FileUtils.
|
|
122
|
+
FileUtils.install( f, '.' )
|
|
135
123
|
puts "#{filename} created. You'll need to fill it out."
|
|
136
124
|
exit 0
|
|
137
125
|
end
|
|
138
126
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
127
|
+
def scaffold( name, type=nil )
|
|
128
|
+
if File.directory?(name) and not $FORCE
|
|
129
|
+
puts "Directory already exists. Use -f option to force scaffoling."
|
|
130
|
+
exit -1
|
|
131
|
+
end
|
|
132
|
+
case type
|
|
133
|
+
when 'std', 'standard', nil
|
|
134
|
+
type = 'standard'
|
|
135
|
+
when 'svn', 'subversion'
|
|
136
|
+
type = 'subversion'
|
|
137
|
+
else
|
|
138
|
+
puts "Unrecognized project type."
|
|
139
|
+
exit -1
|
|
140
|
+
end
|
|
141
|
+
# need to add gems workaround
|
|
142
|
+
dir = File.join( ::Config::CONFIG['datadir'], 'reap', 'scaffold', type )
|
|
143
|
+
#FileUtils.mkdir_p( name )
|
|
144
|
+
FileUtils.cp_r( dir, name )
|
|
145
|
+
puts "Project #{name} created. Good luck with your new project!"
|
|
146
|
+
exit 0
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
# Add all the reap tasks.
|
|
150
|
+
if Reap.register
|
|
151
|
+
Reap.tasks.each do |sym,taskclass|
|
|
152
|
+
define_method(sym) do |*args|
|
|
153
|
+
taskclass.new(*args)
|
|
154
|
+
end
|
|
142
155
|
end
|
|
143
156
|
end
|
|
144
157
|
|
|
@@ -153,17 +166,25 @@ HELP = <<-HERE
|
|
|
153
166
|
|
|
154
167
|
COMMANDS:
|
|
155
168
|
|
|
169
|
+
tasks (default)
|
|
170
|
+
List all the current tasks with descriptions.
|
|
171
|
+
This is the default action if no command
|
|
172
|
+
is given. (Also aliased as 'ls'.)
|
|
173
|
+
|
|
174
|
+
help [task]
|
|
175
|
+
Displays this help information. If a task name
|
|
176
|
+
is given, it will provide help information
|
|
177
|
+
specific to that task.
|
|
178
|
+
|
|
156
179
|
template
|
|
157
180
|
Copies a ProjectInfo template into the current
|
|
158
|
-
directory, if it
|
|
159
|
-
|
|
160
|
-
scaffold
|
|
161
|
-
Builds a project directory based on settings of
|
|
162
|
-
project information file. This will not destroy
|
|
163
|
-
any structure already in place!
|
|
181
|
+
directory, if it does not already exist.
|
|
164
182
|
|
|
165
|
-
|
|
166
|
-
|
|
183
|
+
scaffold [directory] [type]
|
|
184
|
+
Builds a starter project directory. There are
|
|
185
|
+
two types: 'standard' and 'subversion'. These can
|
|
186
|
+
be abbreviated 'std' and 'svn', repectively. If
|
|
187
|
+
no type is given then standard is used.
|
|
167
188
|
|
|
168
189
|
OPTIONS:
|
|
169
190
|
|
|
@@ -173,6 +194,9 @@ HELP = <<-HERE
|
|
|
173
194
|
-V --verbose
|
|
174
195
|
Provides extra verbose processing information.
|
|
175
196
|
|
|
197
|
+
-f --force
|
|
198
|
+
Forces certain operations to be performed.
|
|
199
|
+
|
|
176
200
|
-D --debug
|
|
177
201
|
Provides extra verbose processing information.
|
|
178
202
|
|
|
File without changes
|
data/lib/reap/projectinfo.rb
CHANGED
|
@@ -8,7 +8,12 @@ require 'facet/dir/self/ascend'
|
|
|
8
8
|
|
|
9
9
|
class ProjectInfo
|
|
10
10
|
|
|
11
|
-
INFO_FILES = [
|
|
11
|
+
INFO_FILES = [
|
|
12
|
+
'ProjectInfo',
|
|
13
|
+
'ReapFile',
|
|
14
|
+
'projectinfo',
|
|
15
|
+
'reapfile'
|
|
16
|
+
]
|
|
12
17
|
|
|
13
18
|
def self.add_info_file( f )
|
|
14
19
|
INFO_FILES.unshift( f )
|
|
@@ -21,68 +26,120 @@ class ProjectInfo
|
|
|
21
26
|
|
|
22
27
|
attr_reader :info, :info_stream, :info_dir
|
|
23
28
|
|
|
24
|
-
def initialize(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
def initialize( alt_info_file=nil )
|
|
30
|
+
|
|
31
|
+
# Consider alternative info files?
|
|
32
|
+
# NOTE Should this work out of the current working dir only?
|
|
33
|
+
add_info_file( alt_info_file ) if alt_info_file
|
|
34
|
+
|
|
35
|
+
info_dir = nil
|
|
36
|
+
info_file = nil
|
|
37
|
+
|
|
38
|
+
Dir.ascend(Dir.pwd) do |info_dir|
|
|
39
|
+
#Dir.chdir(info_dir)
|
|
40
|
+
info_file = INFO_FILES.find{ |f| File.file?( File.join( info_dir, f ) ) }
|
|
41
|
+
break if info_file
|
|
33
42
|
end
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
|
|
44
|
+
return unless info_file
|
|
45
|
+
|
|
46
|
+
info_file = File.basename( info_file )
|
|
47
|
+
@info_dir = info_dir
|
|
48
|
+
@info_file = info_file
|
|
49
|
+
Dir.chdir(info_dir)
|
|
50
|
+
|
|
51
|
+
puts "(in #{Dir.pwd})" #unless dir == Dir.pwd
|
|
52
|
+
|
|
53
|
+
info_stream = File.read( info_file ).strip
|
|
54
|
+
|
|
55
|
+
begin
|
|
56
|
+
info = YAML::load( info_stream )
|
|
57
|
+
rescue
|
|
58
|
+
#info_proc = lambda { instance_eval( info_stream ) }
|
|
59
|
+
info = HashBuilder.new( info_stream ).to_h
|
|
44
60
|
end
|
|
45
|
-
end
|
|
46
61
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
# unless @info_stream
|
|
50
|
-
# Dir.ascend(Dir.pwd) do |d|
|
|
51
|
-
# Dir.chdir(d)
|
|
52
|
-
# info_file = INFO_FILES.find{ |f| File.file?( f ) }
|
|
53
|
-
# if info_file
|
|
54
|
-
# @info_stream = File.read( info_file )
|
|
55
|
-
# puts "(in #{d})" unless dir == Dir.pwd
|
|
56
|
-
# break
|
|
57
|
-
# end
|
|
58
|
-
# end
|
|
59
|
-
# end
|
|
60
|
-
# @info_stream
|
|
61
|
-
# end
|
|
62
|
-
|
|
63
|
-
# def info
|
|
64
|
-
# @info
|
|
65
|
-
# #if info_stream
|
|
66
|
-
# # @info ||= YAML::load(info_stream).traverse{ |k,v| [k.downcase, v] }
|
|
67
|
-
# #else
|
|
68
|
-
# # {}
|
|
69
|
-
# #end
|
|
70
|
-
# end
|
|
62
|
+
@info_stream = info_stream
|
|
63
|
+
@info = info.traverse{ |k,v| [k.to_s.downcase, v] }
|
|
71
64
|
|
|
72
|
-
|
|
73
|
-
|
|
65
|
+
validate
|
|
66
|
+
defaults
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def exists?
|
|
70
|
+
@info_dir
|
|
74
71
|
end
|
|
75
72
|
|
|
76
|
-
# not using at the moment
|
|
77
73
|
def validate
|
|
78
|
-
# required main parameters
|
|
79
|
-
#raise "TITLE is a required configuration field" unless info['title']
|
|
80
74
|
raise "NAME is a required piece of information" unless info['name']
|
|
81
75
|
raise "VERSION is a required piece of informatiomn" unless info['version']
|
|
82
76
|
end
|
|
83
77
|
|
|
78
|
+
def defaults
|
|
79
|
+
self['title'] ||= self['name'].capitalize
|
|
80
|
+
self['series'] ||= '1'
|
|
81
|
+
self['date'] ||= Time.now.strftime("%Y-%m-%d")
|
|
82
|
+
self['author'] ||= "Anonymous"
|
|
83
|
+
self['maintainer'] ||= self['author']
|
|
84
|
+
self['arch'] ||= 'Any'
|
|
85
|
+
self['license'] ||= 'Ruby/GPL'
|
|
86
|
+
self['status'] ||= 'Beta'
|
|
87
|
+
self['project'] ||= self['rubyforge'] ? self['rubyforge']['project'] : nil
|
|
88
|
+
self['homepage'] ||= self['rubyforge'] ? self['rubyforge']['homepage'] : nil
|
|
89
|
+
end
|
|
90
|
+
|
|
84
91
|
def [](name)
|
|
85
92
|
info[name]
|
|
86
93
|
end
|
|
87
94
|
|
|
95
|
+
def []=(name, x)
|
|
96
|
+
info[name] = x
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def to_h
|
|
100
|
+
@info
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
# Build a hash from missing method calls.
|
|
107
|
+
|
|
108
|
+
class ProjectInfo::HashBuilder < BasicObject
|
|
109
|
+
|
|
110
|
+
def initialize( blockstr=nil, &block )
|
|
111
|
+
@hash = {}
|
|
112
|
+
@flag = {}
|
|
113
|
+
raise "both string and block given" if blockstr and block_given?
|
|
114
|
+
if blockstr
|
|
115
|
+
instance_eval blockstr
|
|
116
|
+
else
|
|
117
|
+
instance_eval &block
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def to_h ; @hash ; end
|
|
122
|
+
|
|
123
|
+
def method_missing( sym, *args, &block )
|
|
124
|
+
|
|
125
|
+
if @hash.key?(sym)
|
|
126
|
+
unless @flag[sym]
|
|
127
|
+
@hash[sym] = [ @hash[sym] ]
|
|
128
|
+
@flag[sym] = true
|
|
129
|
+
end
|
|
130
|
+
if block_given?
|
|
131
|
+
@hash[sym] << HashBuilder.new( &block ).to_h
|
|
132
|
+
else
|
|
133
|
+
@hash[sym] << args[0]
|
|
134
|
+
end
|
|
135
|
+
else
|
|
136
|
+
if block_given?
|
|
137
|
+
@hash[sym] = HashBuilder.new( &block ).to_h
|
|
138
|
+
else
|
|
139
|
+
@hash[sym] = args[0]
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
end
|
|
144
|
+
|
|
88
145
|
end
|