ratch 0.2.3 → 0.3.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.
Files changed (129) hide show
  1. data/bin/ratch +60 -47
  2. data/bin/ratch-find +21 -0
  3. data/demo/{README → XR} +0 -0
  4. data/demo/task/stats +0 -2
  5. data/doc/images/clipboard.jpg +0 -0
  6. data/doc/images/clipboard2.png +0 -0
  7. data/doc/images/milles-tn.jpg +0 -0
  8. data/doc/images/mints.png +0 -0
  9. data/doc/images/ratch2.png +0 -0
  10. data/doc/images/ruby-sm.png +0 -0
  11. data/doc/images/silver.gif +0 -0
  12. data/doc/images/toolbox.jpg +0 -0
  13. data/doc/index.html +181 -0
  14. data/doc/notes/original.rb +308 -0
  15. data/doc/rdoc/classes/Array.html +194 -0
  16. data/doc/rdoc/classes/Dir.html +317 -0
  17. data/doc/rdoc/classes/Hash.html +217 -0
  18. data/doc/rdoc/classes/Ratch.html +201 -0
  19. data/doc/rdoc/classes/Ratch/ArgvUtils.html +173 -0
  20. data/doc/rdoc/classes/Ratch/ArgvUtils/Ext.html +285 -0
  21. data/doc/rdoc/classes/Ratch/BatchFile.html +207 -0
  22. data/doc/rdoc/classes/Ratch/BatchManager.html +250 -0
  23. data/doc/rdoc/classes/Ratch/BatchScript.html +127 -0
  24. data/doc/rdoc/classes/Ratch/Batchable.html +373 -0
  25. data/doc/rdoc/classes/Ratch/Build.html +321 -0
  26. data/doc/rdoc/classes/Ratch/BuildManager.html +319 -0
  27. data/doc/rdoc/classes/Ratch/Buildable.html +202 -0
  28. data/doc/rdoc/classes/Ratch/ConfigUtils.html +281 -0
  29. data/doc/rdoc/classes/Ratch/ConsoleUtils.html +189 -0
  30. data/doc/rdoc/classes/Ratch/EmailUtils.html +209 -0
  31. data/doc/rdoc/classes/Ratch/FileUtils.html +674 -0
  32. data/doc/rdoc/classes/Ratch/GeneralOptions.html +430 -0
  33. data/doc/rdoc/classes/Ratch/Task.html +201 -0
  34. data/doc/rdoc/classes/Ratch/TaskManager.html +330 -0
  35. data/doc/rdoc/classes/Ratch/Taskable.html +231 -0
  36. data/doc/rdoc/classes/Ratch/UploadUtils.html +566 -0
  37. data/doc/rdoc/created.rid +1 -0
  38. data/doc/rdoc/files/COPYING.html +1003 -0
  39. data/{demo/doc → doc}/rdoc/files/README.html +36 -5
  40. data/doc/rdoc/files/lib/ratch/argvutils_rb.html +131 -0
  41. data/doc/rdoc/files/lib/ratch/batch_rb.html +155 -0
  42. data/doc/rdoc/files/lib/ratch/batchable_rb.html +131 -0
  43. data/doc/rdoc/files/lib/ratch/batchfile_rb.html +148 -0
  44. data/doc/rdoc/files/lib/ratch/buildable_rb.html +131 -0
  45. data/doc/rdoc/files/lib/ratch/consoleutils_rb.html +131 -0
  46. data/{demo/doc/rdoc/files/lib/foo/foo_rb.html → doc/rdoc/files/lib/ratch/emailutils_rb.html} +35 -41
  47. data/doc/rdoc/files/lib/ratch/facets/multiglob_rb.html +137 -0
  48. data/doc/rdoc/files/lib/ratch/fileutils_rb.html +139 -0
  49. data/doc/rdoc/files/lib/ratch/options_rb.html +131 -0
  50. data/doc/rdoc/files/lib/ratch/taskable_rb.html +131 -0
  51. data/doc/rdoc/files/lib/ratch/uploadutils_rb.html +150 -0
  52. data/doc/rdoc/fr_class_index.html +48 -0
  53. data/doc/rdoc/fr_file_index.html +41 -0
  54. data/doc/rdoc/fr_method_index.html +133 -0
  55. data/{demo/doc → doc}/rdoc/index.html +1 -1
  56. data/{demo/doc → doc}/rdoc/rdoc-style.css +0 -0
  57. data/doc/scrap/flexihead-flip.jpg +0 -0
  58. data/doc/scrap/flexihead.jpg +0 -0
  59. data/doc/scrap/head1.jpg +0 -0
  60. data/doc/scrap/ratch.jpg +0 -0
  61. data/doc/scrap/ratch1.png +0 -0
  62. data/doc/scrap/ratch2.jpg +0 -0
  63. data/doc/scrap/ratch3.png +0 -0
  64. data/doc/scrap/red-ratch.jpg +0 -0
  65. data/doc/scrap/redratchet.jpg +0 -0
  66. data/doc/scrap/ruby-kit/ruby.png +0 -0
  67. data/doc/scrap/scrap.red +256 -0
  68. data/doc/sitemap.yaml +10 -0
  69. data/doc/siteparts/index.red +100 -0
  70. data/doc/siteparts/layout.rhtml +56 -0
  71. data/doc/siteparts/tutorial.red +578 -0
  72. data/doc/style.css +112 -0
  73. data/doc/tutorial.html +722 -0
  74. data/lib/ratch/batch.rb +417 -30
  75. data/lib/ratch/{argvutils.rb → batch/argvutils.rb} +27 -19
  76. data/lib/ratch/batch/build.rb +95 -0
  77. data/lib/ratch/{consoleutils.rb → batch/consoleutils.rb} +0 -0
  78. data/lib/ratch/{emailutils.rb → batch/emailutils.rb} +0 -0
  79. data/lib/ratch/{fileutils.rb → batch/fileutils.rb} +32 -32
  80. data/lib/ratch/{options.rb → batch/options.rb} +0 -0
  81. data/lib/ratch/batch/task.rb +43 -0
  82. data/lib/ratch/manager.rb +34 -0
  83. data/lib/ratch/project/information.rb +257 -0
  84. data/lib/ratch/project/package.rb +82 -0
  85. data/lib/ratch/project/project.rb +531 -0
  86. data/lib/ratch/project/release.rb +112 -0
  87. data/lib/ratch/support/filetest.rb +29 -0
  88. data/lib/ratch/support/setuputils.rb +124 -0
  89. data/lib/ratch/support/signiture.rb +252 -0
  90. data/lib/ratch/support/stage.rb +292 -0
  91. data/lib/ratch/toolset/ruby/pack/gem +85 -0
  92. data/lib/ratch/toolset/ruby/pack/tgz +85 -0
  93. data/lib/ratch/toolset/ruby/{crosstest → test/crosstest} +0 -0
  94. data/lib/ratch/toolset/ruby/{extest → test/extest} +0 -0
  95. data/lib/ratch/toolset/ruby/{isotest → test/isotest} +0 -0
  96. data/lib/ratch/toolset/ruby/{load → test/load} +0 -0
  97. data/lib/ratch/toolset/ruby/{loadtest → test/loadtest} +0 -0
  98. data/lib/ratch/toolset/ruby/{syntax → test/syntax} +0 -0
  99. data/lib/ratch/toolset/ruby/{test → test/test} +0 -0
  100. data/log/{history.rd → history} +6 -0
  101. data/log/{todo.rd → todo} +0 -0
  102. data/meta/MANIFEST +52 -36
  103. data/meta/ROLLRC +2 -0
  104. data/meta/icli.yaml +16 -0
  105. data/meta/{ratch-0.2.3.roll → project.yaml} +1 -7
  106. data/task/release +12 -0
  107. data/{lib/ratch → work/old}/batchfile.rb +0 -0
  108. data/work/project-old.rb +67 -0
  109. data/work/scrap/install +89 -0
  110. data/work/scrap/install.0 +49 -0
  111. data/work/scrap/install.1 +63 -0
  112. data/work/scrap/ludo +25 -0
  113. data/work/scrap/oldtaskable.rb +573 -0
  114. data/work/scrap/ratch.man +39 -0
  115. data/work/scrap/taskable-simple.rb +42 -0
  116. data/work/scrap/taskable.rb +120 -0
  117. metadata +170 -72
  118. data/demo/doc/rdoc/created.rid +0 -1
  119. data/demo/doc/rdoc/fr_class_index.html +0 -26
  120. data/demo/doc/rdoc/fr_file_index.html +0 -28
  121. data/demo/doc/rdoc/fr_method_index.html +0 -27
  122. data/demo/task/config.yaml +0 -2
  123. data/lib/ratch/batchable.rb +0 -169
  124. data/lib/ratch/buildable.rb +0 -182
  125. data/lib/ratch/configutils.rb +0 -132
  126. data/lib/ratch/facets/multiglob.rb +0 -160
  127. data/lib/ratch/taskable.rb +0 -152
  128. data/log/recent.rd +0 -8
  129. data/task/config.yaml +0 -10
@@ -1 +0,0 @@
1
- Sun, 11 Nov 2007 10:50:18 -0500
@@ -1,26 +0,0 @@
1
-
2
- <?xml version="1.0" encoding="iso-8859-1"?>
3
- <!DOCTYPE html
4
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
5
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
6
-
7
- <!--
8
-
9
- Classes
10
-
11
- -->
12
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
13
- <head>
14
- <title>Classes</title>
15
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
16
- <link rel="stylesheet" href="rdoc-style.css" type="text/css" />
17
- <base target="docwin" />
18
- </head>
19
- <body>
20
- <div id="index">
21
- <h1 class="section-bar">Classes</h1>
22
- <div id="index-entries">
23
- </div>
24
- </div>
25
- </body>
26
- </html>
@@ -1,28 +0,0 @@
1
-
2
- <?xml version="1.0" encoding="iso-8859-1"?>
3
- <!DOCTYPE html
4
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
5
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
6
-
7
- <!--
8
-
9
- Files
10
-
11
- -->
12
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
13
- <head>
14
- <title>Files</title>
15
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
16
- <link rel="stylesheet" href="rdoc-style.css" type="text/css" />
17
- <base target="docwin" />
18
- </head>
19
- <body>
20
- <div id="index">
21
- <h1 class="section-bar">Files</h1>
22
- <div id="index-entries">
23
- <a href="files/README.html">README</a><br />
24
- <a href="files/lib/foo/foo_rb.html">lib/foo/foo.rb</a><br />
25
- </div>
26
- </div>
27
- </body>
28
- </html>
@@ -1,27 +0,0 @@
1
-
2
- <?xml version="1.0" encoding="iso-8859-1"?>
3
- <!DOCTYPE html
4
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
5
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
6
-
7
- <!--
8
-
9
- Methods
10
-
11
- -->
12
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
13
- <head>
14
- <title>Methods</title>
15
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
16
- <link rel="stylesheet" href="rdoc-style.css" type="text/css" />
17
- <base target="docwin" />
18
- </head>
19
- <body>
20
- <div id="index">
21
- <h1 class="section-bar">Methods</h1>
22
- <div id="index-entries">
23
- <a href="files/lib/foo/foo_rb.html#M000001">hello (lib/foo/foo.rb)</a><br />
24
- </div>
25
- </div>
26
- </body>
27
- </html>
@@ -1,2 +0,0 @@
1
-
2
-
@@ -1,169 +0,0 @@
1
- # TITLE:
2
- #
3
- # Batchable
4
- #
5
- # COPYING:
6
- #
7
- # Copyright (c) 2007 Psi T Corp.
8
- #
9
- # This file is part of the ProUtils' Ratch program.
10
- #
11
- # Ratch is free software: you can redistribute it and/or modify
12
- # it under the terms of the GNU General Public License as published by
13
- # the Free Software Foundation, either version 3 of the License, or
14
- # (at your option) any later version.
15
- #
16
- # Ratch is distributed in the hope that it will be useful,
17
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
18
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
- # GNU General Public License for more details.
20
- #
21
- # You should have received a copy of the GNU General Public License
22
- # along with Ratch. If not, see <http://www.gnu.org/licenses/>.
23
-
24
- module Ratch
25
-
26
- class BatchManager
27
-
28
- # Task cache, which prevents batch runs from re-executing.
29
- attr :cache
30
-
31
- # New BatchManager.
32
- def initialize(runspace)
33
- @runspace = runspace
34
- @cache = {}
35
- end
36
-
37
- #
38
- def batch(batchfile, arguments=nil)
39
- @cache[batchfile] ||= run(batchfile, arguments)
40
- end
41
-
42
- # Run a batch file.
43
- # TODO: How to handle arguments?
44
-
45
- def run(batchfile, arguments=nil)
46
- # # TODO probably should raise error instead
47
- # abort "missing batch file -- #{batchfile}" unless File.file?(batchfile)
48
-
49
- #BatchFile.new(batchfile).call # Old way with batch execution context object.
50
- script = File.read($0 = batchfile)
51
- eval(script, $batch_binding, $0)
52
- end
53
-
54
- #
55
- def done?(batchfile)
56
- batchfile == $0 or @cache.key?(batchfile)
57
- end
58
-
59
- end
60
-
61
- #
62
-
63
- module Batchable
64
-
65
- # Reference batch manager.
66
- def batch_manager
67
- @batch_manager ||= BatchManager.new(self)
68
- end
69
-
70
- # Batch run, ie. run and cache.
71
- # Usually this can be take care of by method_missing.
72
- # But, in some cases, built in method names block task
73
- # calls, so you have to use #batch to invoke those.
74
- def batch(batchfile, arguments=nil)
75
- batch_manager.batch(batchfile, arguments=nil) # why did I have task instead of batchfile before?
76
- end
77
-
78
- # Lauch a batch file (non-cached)
79
- def launch(batchfile, arguments=nil)
80
- batch_manager.run(batchfile, arguments=nil)
81
- end
82
-
83
- # Is a batch run complete or in the process of being completed?
84
- def done?(batchfile)
85
- batch_manager.done?(batchfile)
86
- end
87
-
88
- # Shell runner.
89
- # TODO Does this belong here?
90
- def sh(cmd)
91
- if noharm?
92
- puts cmd
93
- true
94
- else
95
- puts "--> system call: #{cmd}" if trace?
96
- system(cmd)
97
- end
98
- end
99
-
100
- # Is a file a local batch file?
101
-
102
- def batch?(path)
103
- b = File.dirname($0) + "/#{path}"
104
- b.chomp!('!')
105
- b if FileTest.file?(b) && FileTest.executable?(b)
106
- end
107
-
108
- # Abort running.
109
- #def abort(msg=nil)
110
- # puts msg if msg
111
- # exit 0
112
- #end
113
-
114
- # If method is missing try to run an external task
115
- # or binary by that name. If it is a binary, arguments
116
- # translate into commandline parameters. For example:
117
- #
118
- # tar 'foo/', :x=>true, :v=>true, :z=>true, :f=>'foo.tar.gz'
119
- #
120
- # or
121
- #
122
- # tar '-xvzf', "foo.tar.gz", "foo/"
123
- #
124
- # becomes
125
- #
126
- # tar -x -v -z -f foo.tar.gz foo/
127
- #
128
- # If it is a task, it will be cached. Tasks only ever run once.
129
- # To run them more than once you can manually execute them with #run.
130
- # Likewise you can manually run and cache by calling #batch.
131
- # This is good to know, b/c in some cases built in method names
132
- # block task calls, so you have to #batch to invoke them.
133
-
134
- def method_missing(sym,*args)
135
- puts "method_missing: #{sym}" if debug?
136
-
137
- name = sym.to_s
138
-
139
- bat = batch?(name)
140
- done = bat && done?(bat)
141
- cache = bat && !done && name[1,-1] != '!'
142
- bin = bin?(name) if (!bat || done)
143
- none = bat && done && !bin
144
- #bat = name if bin
145
-
146
- return super unless bat || bin
147
-
148
- return if none # nothing to do
149
-
150
- params = args.to_params
151
-
152
- if bin
153
- cmd = "#{File.basename(bin)} #{params}"
154
- res = sh(cmd)
155
- elsif bat
156
- cmd = "./#{bat} #{params}"
157
- puts "--> #{cache ? '' : 'not-'}cached execution: #{cmd}" if trace?
158
- res = batch(bat, args)
159
- if cache
160
- #@batch_catch[bat] ||= (system(cmd); true)
161
- #batch_cache[bat] ||= res
162
- batch_manager.cache ||= res
163
- end
164
- end
165
-
166
- return res
167
- end
168
- end
169
- end
@@ -1,182 +0,0 @@
1
- # TITLE:
2
- #
3
- # Buildable
4
- #
5
- # COPYING:
6
- #
7
- # Copyright (c) 2007 Psi T Corp.
8
- #
9
- # This file is part of the ProUtils' Ratch program.
10
- #
11
- # Ratch is free software: you can redistribute it and/or modify
12
- # it under the terms of the GNU General Public License as published by
13
- # the Free Software Foundation, either version 3 of the License, or
14
- # (at your option) any later version.
15
- #
16
- # Ratch is distributed in the hope that it will be useful,
17
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
18
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
- # GNU General Public License for more details.
20
- #
21
- # You should have received a copy of the GNU General Public License
22
- # along with Ratch. If not, see <http://www.gnu.org/licenses/>.
23
-
24
- module Ratch
25
-
26
- # = Buildable mixin
27
- #
28
- module Buildable
29
-
30
- # Reference task manager.
31
- def build_manager
32
- @build_manager ||= BuildManager.new(self)
33
- end
34
-
35
- # Define a build target.
36
- def file(name, &block)
37
- name, deps, block = *parse_build_dependencies(name, &block)
38
- build_manager.define_file(name, *deps, &block)
39
- end
40
-
41
- # Build a file.
42
- def build(file)
43
- build_manager.call(file)
44
- end
45
-
46
- private
47
-
48
- #
49
- def parse_build_dependencies(name_deps, &block)
50
- if Hash===name_deps
51
- name = name_deps.keys[0]
52
- deps = name_deps.values[0]
53
- else
54
- name = name_deps
55
- deps = []
56
- end
57
- [name, deps, block]
58
- end
59
- end
60
-
61
- # = BuildManager class
62
- #
63
- class BuildManager
64
- attr :builds
65
-
66
- def initialize(runspace)
67
- @runspace = runspace
68
- @builds = []
69
- end
70
-
71
- def force? ; @runspace.force? ; end
72
-
73
- # Define a file build task.
74
- def define_file(name, *depend, &block)
75
- build = Build.new(name, *depend, &block)
76
- builds << build
77
- end
78
-
79
- # Call build.
80
- def call(path)
81
- # TODO How to handle more than one matching means of building?
82
- #warn "More than one build definition matches #{path} using #{means.first}" if means.size > 1
83
- if build = find(path)
84
- if build.needed_for?(path) || force?
85
- list, todo = *plan(build, path)
86
- todo.each{|bld, pth| bld.call(pth) } #@builds[name].call }
87
- build.call(path)
88
- end
89
- else
90
- raise
91
- end
92
- end
93
-
94
- def find(path)
95
- builds.find{ |b| b.match?(path) }
96
- end
97
-
98
- # Prepare plan, checking for circular dependencies.
99
- def plan(build, path, list=[], todo=[])
100
- #if list.include?(build)
101
- # raise "Circular build dependency #{build.name}."
102
- #end
103
-
104
- build.needed_paths.each do |npath|
105
- next if list.include?(npath)
106
- if nbuild = find(npath)
107
- plan(nbuild, npath, list, todo)
108
- todo << [nbuild, npath]
109
- else
110
- list << npath
111
- end
112
- end
113
-
114
- return list, todo
115
- end
116
-
117
- end
118
-
119
- # = Build class
120
- #
121
- class Build
122
-
123
- attr :match
124
- attr :needs
125
- attr :action
126
-
127
- alias_method :name, :match
128
-
129
- # Create a new build definition.
130
-
131
- def initialize(match, *needs, &action)
132
- @match = match
133
- @needs = needs
134
- @action = action
135
- end
136
-
137
- # Call this build process for the given path.
138
-
139
- def call(path)
140
- if File.exist?(path)
141
- mtime = File.mtime(path)
142
- dated = needs.find do |file|
143
- !File.exist?(file) || File.mtime(file) > mtime
144
- end
145
- else
146
- dated = true
147
- end
148
- action.call(path) if dated
149
- end
150
-
151
- # Does a file match this build definition?
152
-
153
- def match?(path)
154
- case match
155
- when String
156
- File.fnmatch(match, path)
157
- when Regexp
158
- match =~ path
159
- else
160
- false # ???
161
- end
162
- end
163
-
164
- # Is this build needed to update/create path?
165
-
166
- def needed_for?(path)
167
- return true unless File.exist?(path)
168
- mtimes = needed_paths.collect{|f| File.mtime(f)}
169
- mtimes.max > File.mtime(path)
170
- end
171
-
172
- # Glob expanded needs.
173
-
174
- def needed_paths
175
- #exact = needs.select{|n| File.fnmatch?(n,n)} +
176
- exact = needs.select{|n| n !~ /[\[*?]/ }
177
- globs = needs.collect{|n| Dir.glob(n)}.flatten
178
- (exact + globs).uniq
179
- end
180
-
181
- end
182
- end
@@ -1,132 +0,0 @@
1
- # TITLE:
2
- #
3
- # ConfigUtils
4
- #
5
- # COPYING:
6
- #
7
- # Copyright (c) 2007 Psi T Corp.
8
- #
9
- # This file is part of the ProUtils' Ratch program.
10
- #
11
- # Ratch is free software: you can redistribute it and/or modify
12
- # it under the terms of the GNU General Public License as published by
13
- # the Free Software Foundation, either version 3 of the License, or
14
- # (at your option) any later version.
15
- #
16
- # Ratch is distributed in the hope that it will be useful,
17
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
18
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
- # GNU General Public License for more details.
20
- #
21
- # You should have received a copy of the GNU General Public License
22
- # along with Ratch. If not, see <http://www.gnu.org/licenses/>.
23
-
24
- module Ratch
25
-
26
- module ConfigUtils
27
-
28
- #DEFAULT_CONFIG_FILE = '{config, config/general}'
29
-
30
- # Load configuration data from a file. The file will
31
- # be looked for in the current script directory then
32
- # from the project root.
33
- #
34
- # Since they are YAML files, they can optionally
35
- # end with '.yaml' or '.yml'.
36
-
37
- def configuration(file=nil)
38
- @configuration ||= {}
39
- @configuration[file] ||= (
40
- if file = config_file(file)
41
- config_read(file)
42
- else
43
- Hash.new{ |h,k| h[k] = {} }
44
- end
45
- )
46
- end
47
-
48
- # If a +path+ is given it will first be looked for in the config directory of
49
- # the utility directory. If not there, then it will be looked for in the project's trunk.
50
- #
51
- # If +path+ is not given then config.yaml or config/general.yaml will be used.
52
-
53
- def config_file(path=nil)
54
- if path
55
- find = "{#{utility_directory}/config/,}#{path}{.yaml,.yml,}"
56
- else
57
- #path = DEFAULT_CONFIG_FILE
58
- find = "{#{utility_directory}/config,#{utility_directory}/config/general}{.yaml,.yml,}"
59
- end
60
- file = Dir.glob(find).find{ |f| File.file?(f) }
61
- return file
62
- end
63
-
64
- #
65
-
66
- def config_read(path)
67
- #find = "{#{utility_directory}/,}#{path}{.yaml,.yml,}"
68
- #if file = Dir.glob(find)[0]
69
- if File.file?(path)
70
- YAML::load(File.open(path)) || {} # The || {} is in case the file is empty.
71
- else
72
- raise LoadError, "Missing file -- #{path}"
73
- end
74
- end
75
-
76
- # TODO Better name? Better definition? (Won't handle task subdirs!).
77
-
78
- def utility_directory
79
- File.dirname($0)
80
- end
81
-
82
- # Create an argument vector from a set of config options.
83
- # TODO Deprecate in favor of Hash extension.
84
-
85
- def config_vector(config, args_field=nil)
86
- config.command_vector(args_field)
87
- end
88
-
89
- # # FIXME ProjectInfo, if available.
90
- #
91
- # def projectinfo
92
- # require 'box/project'
93
- # @projectinfo
94
- #
95
- # #begin
96
- # # @projectinfo = ProjectInfo.open
97
- # #rescue LoadError
98
- # # @projectinfo = nil
99
- # #end
100
- # end
101
-
102
- # def config_file
103
- # @config_file ||= (
104
- # dir = utility_directory
105
- # name = Dir.basename(dir)
106
- # Dir.glob("{#{dir},meta,info,}/{#{name},config}{.yaml,.yml}")
107
- # )
108
- # end
109
-
110
- # # Load task configuration if any.
111
- #
112
- # def config_load(*names) #, defaults=nil)
113
- #
114
- # names.inject({}) do |memo, name|
115
- # name = name.to_s
116
- # #defaults = defaults || {}
117
- #
118
- # if file = config_file(name)
119
- # config = YAML.load(File.open(file))
120
- # elsif file = Dir.glob("#{utility_directory}/config{,.yaml,.yml}")[0]
121
- # config = YAML.load(File.open(file))[name.to_s]
122
- # else
123
- # config = {}
124
- # end
125
- #
126
- # config.update(memo)
127
- # end
128
- # #return defaults.update(config || {})
129
- # end
130
-
131
- end
132
- end