ratch 0.3.0 → 0.4.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 (132) hide show
  1. data/{log/history → CHANGES} +0 -0
  2. data/{log/todo → TODO} +0 -0
  3. data/bin/manifest +451 -0
  4. data/bin/ratch +3 -3
  5. data/demo/task/config.yaml +4 -0
  6. data/lib/ratch/{batch/argvutils.rb → dsl/argv.rb} +9 -4
  7. data/lib/ratch/dsl/batch.rb +226 -0
  8. data/lib/ratch/{batch → dsl}/build.rb +83 -4
  9. data/lib/ratch/{batch/consoleutils.rb → dsl/console.rb} +13 -5
  10. data/lib/ratch/{batch/emailutils.rb → dsl/email.rb} +21 -25
  11. data/lib/ratch/{batch/fileutils.rb → dsl/file.rb} +56 -56
  12. data/lib/ratch/dsl/meta.rb +132 -0
  13. data/lib/ratch/{batch → dsl}/options.rb +7 -5
  14. data/lib/ratch/dsl/setup.rb +124 -0
  15. data/lib/ratch/{support/signiture.rb → dsl/sign.rb} +9 -18
  16. data/lib/ratch/dsl/stage.rb +147 -0
  17. data/lib/ratch/dsl/task.rb +139 -0
  18. data/lib/ratch/{uploadutils.rb → dsl/upload.rb} +7 -5
  19. data/lib/ratch/{batch/task.rb → dsl/zip.rb} +30 -14
  20. data/lib/ratch/dsl.rb +52 -0
  21. data/lib/ratch/extra/email.rb +5 -0
  22. data/lib/ratch/extra/stage.rb +5 -0
  23. data/lib/ratch/extra/zip.rb +5 -0
  24. data/lib/ratch/manifest.rb +540 -0
  25. data/lib/ratch/{project → metadata}/information.rb +1 -0
  26. data/lib/ratch/{project → metadata}/package.rb +28 -2
  27. data/lib/ratch/{project → metadata}/project.rb +8 -16
  28. data/lib/ratch/{project → metadata}/release.rb +6 -6
  29. data/lib/ratch/support/errors.rb +4 -0
  30. data/lib/ratch/support/filename.rb +18 -0
  31. data/lib/ratch/toolset/ruby/compile +49 -0
  32. data/lib/ratch/toolset/ruby/pack/gem +26 -18
  33. data/lib/ratch/toolset/ruby/pack/tgz +25 -64
  34. data/lib/ratch/toolset/ruby/pack/zip +46 -0
  35. data/lib/ratch/toolset/ruby/publish +23 -24
  36. data/lib/ratch/toolset/ruby/release +8 -0
  37. data/lib/ratch/toolset/ruby/stamp +33 -0
  38. data/lib/ratch/toolset/sandbox +11 -0
  39. data/meta/MANIFEST +101 -23
  40. data/meta/ROLLRC +1 -1
  41. data/meta/config.yaml +10 -0
  42. data/meta/icli.yaml +2 -2
  43. data/meta/project.yaml +9 -10
  44. data/meta/xProjectInfo +41 -0
  45. data/task/release +1 -4
  46. metadata +82 -156
  47. data/demo/task/rdoc +0 -88
  48. data/demo/task/rdoc-old +0 -182
  49. data/doc/images/clipboard.jpg +0 -0
  50. data/doc/images/clipboard2.png +0 -0
  51. data/doc/images/milles-tn.jpg +0 -0
  52. data/doc/images/mints.png +0 -0
  53. data/doc/images/ratch2.png +0 -0
  54. data/doc/images/ruby-sm.png +0 -0
  55. data/doc/images/silver.gif +0 -0
  56. data/doc/images/toolbox.jpg +0 -0
  57. data/doc/index.html +0 -181
  58. data/doc/notes/original.rb +0 -308
  59. data/doc/rdoc/classes/Array.html +0 -194
  60. data/doc/rdoc/classes/Dir.html +0 -317
  61. data/doc/rdoc/classes/Hash.html +0 -217
  62. data/doc/rdoc/classes/Ratch/ArgvUtils/Ext.html +0 -285
  63. data/doc/rdoc/classes/Ratch/ArgvUtils.html +0 -173
  64. data/doc/rdoc/classes/Ratch/BatchFile.html +0 -207
  65. data/doc/rdoc/classes/Ratch/BatchManager.html +0 -250
  66. data/doc/rdoc/classes/Ratch/BatchScript.html +0 -127
  67. data/doc/rdoc/classes/Ratch/Batchable.html +0 -373
  68. data/doc/rdoc/classes/Ratch/Build.html +0 -321
  69. data/doc/rdoc/classes/Ratch/BuildManager.html +0 -319
  70. data/doc/rdoc/classes/Ratch/Buildable.html +0 -202
  71. data/doc/rdoc/classes/Ratch/ConfigUtils.html +0 -281
  72. data/doc/rdoc/classes/Ratch/ConsoleUtils.html +0 -189
  73. data/doc/rdoc/classes/Ratch/EmailUtils.html +0 -209
  74. data/doc/rdoc/classes/Ratch/FileUtils.html +0 -674
  75. data/doc/rdoc/classes/Ratch/GeneralOptions.html +0 -430
  76. data/doc/rdoc/classes/Ratch/Task.html +0 -201
  77. data/doc/rdoc/classes/Ratch/TaskManager.html +0 -330
  78. data/doc/rdoc/classes/Ratch/Taskable.html +0 -231
  79. data/doc/rdoc/classes/Ratch/UploadUtils.html +0 -566
  80. data/doc/rdoc/classes/Ratch.html +0 -201
  81. data/doc/rdoc/created.rid +0 -1
  82. data/doc/rdoc/files/COPYING.html +0 -1003
  83. data/doc/rdoc/files/README.html +0 -143
  84. data/doc/rdoc/files/lib/ratch/argvutils_rb.html +0 -131
  85. data/doc/rdoc/files/lib/ratch/batch_rb.html +0 -155
  86. data/doc/rdoc/files/lib/ratch/batchable_rb.html +0 -131
  87. data/doc/rdoc/files/lib/ratch/batchfile_rb.html +0 -148
  88. data/doc/rdoc/files/lib/ratch/buildable_rb.html +0 -131
  89. data/doc/rdoc/files/lib/ratch/consoleutils_rb.html +0 -131
  90. data/doc/rdoc/files/lib/ratch/emailutils_rb.html +0 -139
  91. data/doc/rdoc/files/lib/ratch/facets/multiglob_rb.html +0 -137
  92. data/doc/rdoc/files/lib/ratch/fileutils_rb.html +0 -139
  93. data/doc/rdoc/files/lib/ratch/options_rb.html +0 -131
  94. data/doc/rdoc/files/lib/ratch/taskable_rb.html +0 -131
  95. data/doc/rdoc/files/lib/ratch/uploadutils_rb.html +0 -150
  96. data/doc/rdoc/fr_class_index.html +0 -48
  97. data/doc/rdoc/fr_file_index.html +0 -41
  98. data/doc/rdoc/fr_method_index.html +0 -133
  99. data/doc/rdoc/index.html +0 -24
  100. data/doc/rdoc/rdoc-style.css +0 -208
  101. data/doc/scrap/flexihead-flip.jpg +0 -0
  102. data/doc/scrap/flexihead.jpg +0 -0
  103. data/doc/scrap/head1.jpg +0 -0
  104. data/doc/scrap/ratch.jpg +0 -0
  105. data/doc/scrap/ratch1.png +0 -0
  106. data/doc/scrap/ratch2.jpg +0 -0
  107. data/doc/scrap/ratch3.png +0 -0
  108. data/doc/scrap/red-ratch.jpg +0 -0
  109. data/doc/scrap/redratchet.jpg +0 -0
  110. data/doc/scrap/ruby-kit/ruby.png +0 -0
  111. data/doc/scrap/scrap.red +0 -256
  112. data/doc/sitemap.yaml +0 -10
  113. data/doc/siteparts/index.red +0 -100
  114. data/doc/siteparts/layout.rhtml +0 -56
  115. data/doc/siteparts/tutorial.red +0 -578
  116. data/doc/style.css +0 -112
  117. data/doc/tutorial.html +0 -722
  118. data/lib/ratch/batch.rb +0 -488
  119. data/lib/ratch/support/setuputils.rb +0 -124
  120. data/lib/ratch/support/stage.rb +0 -292
  121. data/lib/ratch/toolset/ruby/rdoc +0 -88
  122. data/task/rdoc +0 -6
  123. data/work/old/batchfile.rb +0 -95
  124. data/work/project-old.rb +0 -67
  125. data/work/scrap/install +0 -89
  126. data/work/scrap/install.0 +0 -49
  127. data/work/scrap/install.1 +0 -63
  128. data/work/scrap/ludo +0 -25
  129. data/work/scrap/oldtaskable.rb +0 -573
  130. data/work/scrap/ratch.man +0 -39
  131. data/work/scrap/taskable-simple.rb +0 -42
  132. data/work/scrap/taskable.rb +0 -120
@@ -0,0 +1,226 @@
1
+ # = TITLE:
2
+ #
3
+ # Batch DSL
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
+ #require 'yaml'
25
+ #require 'rbconfig' # replace with facets/rbsystem in future ?
26
+
27
+ #require 'ratch/dsl/batch/task'
28
+ #require 'ratch/dsl/batch/build'
29
+ #require 'ratch/dsl/batch/directory'
30
+
31
+ module Ratch
32
+ module Dsl
33
+
34
+ # Batch module defines the DSL for calling other batch files
35
+ # and system binaries.
36
+
37
+ module Batch
38
+
39
+ # Shell runner.
40
+
41
+ def sh(cmd)
42
+ if noharm?
43
+ puts cmd
44
+ true
45
+ else
46
+ puts "--> system call: #{cmd}" if trace?
47
+ system(cmd)
48
+ end
49
+ end
50
+
51
+ # Abort running.
52
+ #def abort(msg=nil)
53
+ # puts msg if msg
54
+ # exit 0
55
+ #end
56
+
57
+ def root_directory
58
+ @root_directory ||= Dir.pwd
59
+ end
60
+
61
+ def call_directory
62
+ @call_directory ||= File.expand_path(File.dirname($0))
63
+ end
64
+
65
+ # TODO Better name? Better definition?
66
+
67
+ def batch_directory
68
+ @batch_directory ||= (
69
+ dir = call_directory.sub(root_directory + '/', '').split('/').first
70
+ File.join(root_directory, dir)
71
+ )
72
+ end
73
+
74
+ # Current batch file, relative to the batch directory.
75
+
76
+ def batch_file
77
+ File.expand_path($0).sub(batch_directory + '/', '')
78
+ end
79
+
80
+ # Run batch file and cache result.
81
+ #
82
+ # Usually this can be taken care of by method_missing.
83
+ # But, in some cases, built in method names block batch
84
+ # calls, so you have to use #batch to invoke those.
85
+
86
+ def batch(batchfile, arguments=nil)
87
+ batch_cache[batchfile] ||= batch!(batchfile, arguments)
88
+ end
89
+
90
+ # Lauch a batch file. Like #batch but not-cached.
91
+ # Run a batch file.
92
+ # TODO: How to handle arguments?
93
+
94
+ def batch!(batchfile, arguments=nil)
95
+ #BatchFile.new(batchfile).call # Old way with batch execution context object.
96
+
97
+ @main = nil # reset main task
98
+
99
+ script = File.read($0 = batchfile)
100
+ eval(script, TOPLEVEL_BINDING, $0)
101
+
102
+ #batch_file = File.expand_path($0).sub(batch_directory + '/', '')
103
+ #run(batch_file)
104
+ run_main #(batch_file)
105
+ end
106
+
107
+ # Is a path a local batch directory?
108
+
109
+ def batch_directory?(path)
110
+ b = File.join(File.dirname($0), path.to_s)
111
+ b if FileTest.directory?(b)
112
+ end
113
+
114
+ # Is a file a local batch file?
115
+
116
+ def batch?(path)
117
+ b = File.join(File.dirname($0), path.to_s)
118
+ b if FileTest.file?(b) && FileTest.executable?(b)
119
+ end
120
+
121
+ # Is a batch run complete or in the process of being completed?
122
+ # Has the batch file been executed before?
123
+
124
+ def done?(batchfile)
125
+ batchfile == $0 || batch_cache.key?(batchfile)
126
+ end
127
+
128
+ # Batch cache, which prevents batch runs from re-executing.
129
+
130
+ def batch_cache
131
+ @batch_cache ||= {}
132
+ end
133
+
134
+ # If method is missing try to run an external task
135
+ # or binary by that name. If it is a binary, arguments
136
+ # translate into commandline parameters. For example:
137
+ #
138
+ # tar 'foo/', :x=>true, :v=>true, :z=>true, :f=>'foo.tar.gz'
139
+ #
140
+ # or
141
+ #
142
+ # tar '-xvzf', "foo.tar.gz", "foo/"
143
+ #
144
+ # becomes
145
+ #
146
+ # tar -x -v -z -f foo.tar.gz foo/
147
+ #
148
+ # If it is a task, it will be cached. Tasks only ever run once.
149
+ # To run them more than once you can manually execute them with #run.
150
+ # Likewise you can manually run and cache by calling #batch.
151
+ # This is good to know, b/c in some cases built in method names
152
+ # block task calls, so you have to #batch to invoke them.
153
+
154
+ def method_missing(sym,*args)
155
+ puts "method_missing: #{sym}" if debug?
156
+ #begin
157
+ launch(sym,*args)
158
+ #rescue ArgumentError
159
+ # super
160
+ #end
161
+ end
162
+
163
+ # TODO Better name!!! Better code.
164
+
165
+ def launch(name, *args)
166
+ name = name.to_s
167
+ force = name.chomp!('!')
168
+
169
+ # is this a batch directory?
170
+ if batch_directory?(name)
171
+ return Batch::Space.new(self, name)
172
+ end
173
+
174
+ params = args.to_params
175
+
176
+ # is this a batch file?
177
+ if bat = batch?(name)
178
+ if force
179
+ cmd = "./#{bat} #{params}"
180
+ puts "--> non-cached execution: #{cmd}" if trace?
181
+ return batch!(bat, args)
182
+ else
183
+ if done?(bat)
184
+ return nil unless bin?(name) # return cache?
185
+ else
186
+ cmd = "./#{bat} #{params}"
187
+ puts "--> cached execution: #{cmd}" if trace?
188
+ return batch(bat, args)
189
+ end
190
+ end
191
+ end
192
+
193
+ # is this a bin file?
194
+ if bin = bin?(name)
195
+ cmd = "#{File.basename(bin)} #{params}"
196
+ return sh(cmd)
197
+ end
198
+
199
+ raise ArgumentError, "script not found -- #{name}"
200
+ end
201
+
202
+ end
203
+
204
+ # This is a type of functor, that allows for calling batch files
205
+ # that are in subdirectories using "dir.file" notation. Eg.
206
+ #
207
+ # svn.log
208
+ #
209
+ # could run the svn/log ratch file.
210
+
211
+ class Batch::Space
212
+ private *instance_methods.select{ |m| m !~ /^__/ }
213
+
214
+ def initialize(manager, directory)
215
+ @manager = manager
216
+ @directory = directory
217
+ end
218
+
219
+ def method_missing(sym, *args)
220
+ path = File.join(@directory, sym.to_s)
221
+ @manager.launch(path, *args)
222
+ end
223
+ end
224
+
225
+ end
226
+ end
@@ -1,8 +1,8 @@
1
- # TITLE:
1
+ # = TITLE:
2
2
  #
3
- # Build
3
+ # Build DSL
4
4
  #
5
- # COPYING:
5
+ # = COPYING:
6
6
  #
7
7
  # Copyright (c) 2007 Psi T Corp.
8
8
  #
@@ -22,8 +22,86 @@
22
22
  # along with Ratch. If not, see <http://www.gnu.org/licenses/>.
23
23
 
24
24
  module Ratch
25
+ module Dsl
25
26
 
26
- # = Build class
27
+ module Builds
28
+
29
+ # Define a build target.
30
+
31
+ def file(name, &block)
32
+ name, deps, block = *parse_build_dependencies(name, &block)
33
+ define_file(name, *deps, &block)
34
+ end
35
+
36
+ # Build target(s).
37
+
38
+ def build(path)
39
+ # TODO How to handle more than one matching means of building?
40
+ #warn "More than one build definition matches #{path} using #{means.first}" if means.size > 1
41
+ if build = find_build(path)
42
+ if build.needed_for?(path) || force?
43
+ list, todo = *build_plan(build, path)
44
+ todo.each{|bld, pth| bld.call(pth) } #@builds[name].call }
45
+ build.call(path)
46
+ end
47
+ else
48
+ raise "build not found -- #{path}"
49
+ end
50
+ end
51
+
52
+ private
53
+
54
+ def builds; @builds ||= [] ; end
55
+
56
+ #
57
+ def parse_build_dependencies(name_deps, &block)
58
+ if Hash===name_deps
59
+ name = name_deps.keys[0]
60
+ deps = name_deps.values[0]
61
+ else
62
+ name = name_deps
63
+ deps = []
64
+ end
65
+ [name, deps, block]
66
+ end
67
+
68
+ # Define a file build task.
69
+
70
+ def define_file(name, *depend, &block)
71
+ build = Build::File.new(name, *depend, &block)
72
+ builds << build
73
+ end
74
+
75
+ #
76
+
77
+ def find_build(path)
78
+ builds.find{ |b| b.match?(path) }
79
+ end
80
+
81
+ # Prepare build plan, checking for circular dependencies.
82
+
83
+ def build_plan(build, path, list=[], todo=[])
84
+ #if list.include?(build)
85
+ # raise "Circular build dependency #{build.name}."
86
+ #end
87
+
88
+ build.needed_paths.each do |npath|
89
+ next if list.include?(npath)
90
+ if nbuild = find_build(npath)
91
+ build_plan(nbuild, npath, list, todo)
92
+ todo << [nbuild, npath]
93
+ else
94
+ list << npath
95
+ end
96
+ end
97
+
98
+ return list, todo
99
+ end
100
+
101
+ end
102
+
103
+ # This class encapsulates the build procedure for creating
104
+ # a file (or directory).
27
105
 
28
106
  class Build
29
107
 
@@ -93,3 +171,4 @@ module Ratch
93
171
  end
94
172
 
95
173
  end
174
+ end
@@ -1,8 +1,8 @@
1
- # TITLE:
1
+ # = TITLE:
2
2
  #
3
- # ConsoleUtils
3
+ # Console
4
4
  #
5
- # COPYING:
5
+ # = COPYING:
6
6
  #
7
7
  # Copyright (c) 2007 Psi T Corp.
8
8
  #
@@ -22,8 +22,9 @@
22
22
  # along with Ratch. If not, see <http://www.gnu.org/licenses/>.
23
23
 
24
24
  module Ratch
25
+ module Dsl
25
26
 
26
- module ConsoleUtils
27
+ module Console
27
28
 
28
29
  # Convenient method to get simple console reply.
29
30
 
@@ -55,10 +56,17 @@ module Ratch
55
56
  return inp.chomp
56
57
  end
57
58
 
59
+ # Internal status report.
60
+ # Only output if dryrun or trace mode.
61
+
62
+ def status(message)
63
+ puts message if dryrun? or trace?
64
+ end
65
+
58
66
  end
59
67
 
60
68
  end
61
-
69
+ end
62
70
 
63
71
  class Array
64
72
 
@@ -1,9 +1,8 @@
1
-
2
- # TITLE:
1
+ # = TITLE:
3
2
  #
4
- # EmailUtils
3
+ # Email DSL
5
4
  #
6
- # COPYING:
5
+ # = COPYING:
7
6
  #
8
7
  # Copyright (c) 2007 Psi T Corp.
9
8
  #
@@ -28,12 +27,10 @@ rescue LoadError
28
27
  require 'net/smtp'
29
28
  end
30
29
 
31
-
32
30
  module Ratch
31
+ module Dsl
33
32
 
34
- module EmailUtils
35
-
36
- module_function
33
+ module Email
37
34
 
38
35
  # Email function to easily send out an email.
39
36
  #
@@ -45,24 +42,26 @@ module Ratch
45
42
  # server Email server to route message.
46
43
  # port Email server's port.
47
44
  # domain Email server's domain name.
48
- # account Email account name.
45
+ # account Email account name if needed.
46
+ # password Password for login..
49
47
  # login Login type: plain, cram_md5 or login [plain].
50
48
  # secure Uses TLS security, true or false? [false]
51
49
  # message Mesage to send -or-
52
50
  # file File that contains message.
53
- #
54
- # (Square brackets indicate defaults taken from Project information.
55
- # if used via Project class.)
56
51
 
57
52
  def email(message, settings)
58
- server = settings['server']
59
- account = settings['account']
60
- login = settings['login'].to_sym
61
- subject = settings['subject']
62
- mail_to = settings['to'] || settings['mail_to']
63
- mail_from = settings['from'] || settings['mail_from']
64
- secure = settings['secure']
65
- domain = settings['domain'] || server
53
+ settings ||= {}
54
+ settings.rekey
55
+
56
+ server = settings[:server]
57
+ account = settings[:account] || ENV['EMAIL_ACCOUNT']
58
+ passwd = settings[:password] || ENV['EMAIL_PASSWORD']
59
+ login = settings[:login].to_sym
60
+ subject = settings[:subject]
61
+ mail_to = settings[:to] || settings[:mail_to]
62
+ mail_from = settings[:from] || settings[:mail_from]
63
+ secure = settings[:secure]
64
+ domain = settings[:domain] || server
66
65
 
67
66
  port ||= (secure ? 465 : 25)
68
67
  account ||= mail_from
@@ -76,7 +75,7 @@ module Ratch
76
75
  raise ArgumentError, "missing email field -- to" unless mail_to
77
76
  raise ArgumentError, "missing email field -- from" unless mail_from
78
77
 
79
- passwd = password(account)
78
+ passwd ||= password(account)
80
79
 
81
80
  mail_to = [mail_to].flatten.compact
82
81
 
@@ -103,10 +102,7 @@ module Ratch
103
102
  end
104
103
  end
105
104
 
106
- #def password( account )
107
- # @password || ENV['PASSWORD'] || ask("Password for #{account}: ")
108
- #end
109
-
110
105
  end
111
106
 
112
107
  end
108
+ end
@@ -1,8 +1,8 @@
1
- # TITLE:
1
+ # = TITLE:
2
2
  #
3
- # FileUtils
3
+ # File DSL
4
4
  #
5
- # COPYING:
5
+ # = COPYING:
6
6
  #
7
7
  # Copyright (c) 2007 Psi T Corp.
8
8
  #
@@ -25,22 +25,45 @@ require 'fileutils'
25
25
  require 'facets/dir/multiglob'
26
26
  require 'ratch/support/filetest'
27
27
 
28
+
28
29
  module Ratch
30
+ module Dsl
29
31
 
30
- module FileUtils
32
+ module Filing
31
33
 
32
- # Glob files.
34
+ # Delegate access to FileUtils.
33
35
 
34
- def glob(*args, &blk)
35
- Dir.glob(*args, &blk)
36
+ def fileutils
37
+ dryrun? ? ::FileUtils::DryRun : ::FileUtils
36
38
  end
37
39
 
38
- def multiglob(*args, &blk)
39
- Dir.multiglob(*args, &blk)
40
+ # Add FileUtils Features
41
+
42
+ ::FileUtils.private_instance_methods(false).each do |meth|
43
+ next if meth =~ /^fu_/
44
+ module_eval %{
45
+ def #{meth}(*a,&b)
46
+ fileutils.#{meth}(*a,&b)
47
+ end
48
+ }
40
49
  end
41
50
 
42
- def multiglob_r(*args, &blk)
43
- Dir.multiglob_r(*args, &blk)
51
+ # Add FileTest Features
52
+
53
+ ::FileTest.private_instance_methods(false).each do |meth|
54
+ next if meth =~ /^fu_/
55
+ module_eval %{
56
+ def #{meth}(*a,&b)
57
+ FileTest.#{meth}(*a,&b)
58
+ end
59
+ }
60
+ end
61
+
62
+ # Bonus FileUtils features.
63
+
64
+ def cd(*a,&b)
65
+ puts "cd #{a}" if dryrun? or trace?
66
+ fileutils.chdir(*a,&b)
44
67
  end
45
68
 
46
69
  # Read file.
@@ -59,45 +82,22 @@ module Ratch
59
82
  end
60
83
  end
61
84
 
62
- ##########################
63
- # Add FileUtils Features #
64
- ##########################
65
-
66
- ::FileUtils.private_instance_methods(false).each do |meth|
67
- next if meth =~ /^fu_/
68
- module_eval %{
69
- def #{meth}(*a,&b)
70
- fileutils.#{meth}(*a,&b)
71
- end
72
- }
73
- end
74
-
75
- # Delegate access to FileUtils.
76
-
77
- def fileutils
78
- dryrun? ? ::FileUtils::DryRun : ::FileUtils
79
- end
80
-
81
- # Bonus FileUtils features.
85
+ # Assert that a path exists.
82
86
 
83
- def cd(*a,&b)
84
- puts "cd #{a}" if dryrun?
85
- fileutils.chdir(*a,&b)
87
+ def exists?(path)
88
+ paths = Dir.glob(path)
89
+ paths.not_empty?
86
90
  end
91
+ alias_method :exist?, :exists? ; module_function :exist?
92
+ alias_method :path?, :exists? ; module_function :path?
87
93
 
94
+ # Assert that a path exists.
88
95
 
89
- #########################
90
- # Add FileTest Features #
91
- #########################
92
-
93
- FileTest.private_instance_methods(false).each do |meth|
94
- next if meth =~ /^fu_/
95
- module_eval %{
96
- def #{meth}(*a,&b)
97
- FileTest.#{meth}(*a,&b)
98
- end
99
- }
96
+ def exists!(*paths)
97
+ abort "path not found #{path}" unless paths.any?{|path| exists?(path)}
100
98
  end
99
+ alias_method :exist!, :exists! ; module_function :exist!
100
+ alias_method :path!, :exists! ; module_function :path!
101
101
 
102
102
  # Is a given path a regular file? If +path+ is a glob
103
103
  # then checks to see if all matches are refular files.
@@ -145,22 +145,20 @@ module Ratch
145
145
  # abort "fold not found #{path}" unless paths.any?{|path| fold?(path)}
146
146
  # end
147
147
 
148
- # Assert that a path exists.
148
+ # Glob files.
149
149
 
150
- def exists?(path)
151
- paths = Dir.glob(path)
152
- paths.not_empty?
150
+ def glob(*args, &blk)
151
+ Dir.glob(*args, &blk)
153
152
  end
154
- alias_method :exist?, :exists? ; module_function :exist?
155
- alias_method :path?, :exists? ; module_function :path?
156
153
 
157
- # Assert that a path exists.
154
+ def multiglob(*args, &blk)
155
+ Dir.multiglob(*args, &blk)
156
+ end
158
157
 
159
- def exists!(*paths)
160
- abort "path not found #{path}" unless paths.any?{|path| exists?(path)}
158
+ def multiglob_r(*args, &blk)
159
+ Dir.multiglob_r(*args, &blk)
161
160
  end
162
- alias_method :exist!, :exists! ; module_function :exist!
163
- alias_method :path!, :exists! ; module_function :path!
161
+
164
162
 
165
163
  # # Is a file a task?
166
164
  #
@@ -202,4 +200,6 @@ module Ratch
202
200
  # end
203
201
 
204
202
  end
203
+
204
+ end
205
205
  end