ratch 1.1.0 → 1.2.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 (86) hide show
  1. data/.ruby +99 -0
  2. data/COPYING +203 -21
  3. data/History.rdoc +35 -0
  4. data/License.txt +204 -0
  5. data/README.rdoc +113 -0
  6. data/Version +1 -0
  7. data/bin/ludo +16 -0
  8. data/bin/ratch +1 -8
  9. data/lib/ratch.rb +28 -0
  10. data/lib/ratch.yml +99 -0
  11. data/lib/ratch/batch.rb +500 -0
  12. data/lib/ratch/console.rb +199 -0
  13. data/lib/ratch/core_ext.rb +1 -4
  14. data/lib/ratch/core_ext/facets.rb +15 -1
  15. data/lib/ratch/core_ext/filetest.rb +29 -0
  16. data/lib/ratch/core_ext/{string.rb → to_actual_filename.rb} +0 -23
  17. data/lib/ratch/core_ext/to_console.rb +30 -12
  18. data/lib/ratch/core_ext/{object.rb → to_yamlfrag.rb} +1 -0
  19. data/lib/ratch/core_ext/unfold_paragraphs.rb +27 -0
  20. data/lib/ratch/file_list.rb +411 -0
  21. data/lib/ratch/script.rb +99 -5
  22. data/lib/ratch/script/help.rb +84 -0
  23. data/lib/ratch/shell.rb +783 -0
  24. data/lib/ratch/system.rb +15 -0
  25. data/lib/ratch/utils/cli.rb +49 -0
  26. data/lib/ratch/utils/config.rb +52 -0
  27. data/lib/ratch/{emailer.rb → utils/email.rb} +43 -6
  28. data/lib/ratch/utils/ftp.rb +134 -0
  29. data/lib/ratch/utils/pom.rb +22 -0
  30. data/lib/ratch/utils/rdoc.rb +48 -0
  31. data/lib/ratch/utils/tar.rb +88 -0
  32. data/lib/ratch/utils/xdg.rb +39 -0
  33. data/lib/ratch/utils/zlib.rb +54 -0
  34. data/spec/01_shell.rdoc +198 -0
  35. data/spec/02_script.rdoc +34 -0
  36. data/spec/03_batch.rdoc +71 -0
  37. data/spec/04_system.rdoc +3 -0
  38. data/spec/applique/array.rb +8 -0
  39. data/spec/applique/setup.rb +20 -0
  40. data/test/case_batch.rb +63 -0
  41. data/test/case_shell.rb +46 -0
  42. data/test/core_ext/case_pathname.rb +361 -0
  43. data/test/helper.rb +4 -0
  44. data/test/utils/case_cli.rb +6 -0
  45. data/test/utils/case_config.rb +12 -0
  46. data/test/utils/case_email.rb +10 -0
  47. data/test/utils/case_ftp.rb +6 -0
  48. data/test/utils/case_pom.rb +17 -0
  49. data/test/utils/case_rdoc.rb +23 -0
  50. data/test/utils/case_tar.rb +6 -0
  51. data/test/utils/case_zlib.rb +11 -0
  52. data/test/utils/fixtures/pom_sample/Profile +4 -0
  53. data/test/utils/fixtures/rdoc_sample/README.rdoc +4 -0
  54. data/test/utils/fixtures/rdoc_sample/lib/rdoc_sample/rdoc_sample.rb +9 -0
  55. metadata +139 -82
  56. data/HISTORY +0 -6
  57. data/MANIFEST +0 -53
  58. data/NEWS +0 -12
  59. data/README +0 -87
  60. data/VERSION +0 -1
  61. data/demo/tryme-task.ratch +0 -12
  62. data/demo/tryme1.ratch +0 -6
  63. data/doc/log/basic_stats/index.html +0 -39
  64. data/doc/log/notes.xml +0 -18
  65. data/doc/log/stats.log +0 -14
  66. data/doc/log/syntax.log +0 -0
  67. data/doc/log/testunit.log +0 -156
  68. data/lib/ratch/commandline.rb +0 -16
  69. data/lib/ratch/core_ext/pathname.rb +0 -38
  70. data/lib/ratch/dsl.rb +0 -420
  71. data/lib/ratch/index.rb +0 -4
  72. data/lib/ratch/io.rb +0 -116
  73. data/lib/ratch/plugin.rb +0 -65
  74. data/lib/ratch/service.rb +0 -33
  75. data/lib/ratch/task.rb +0 -249
  76. data/lib/ratch/task2.rb +0 -298
  77. data/meta/abstract +0 -4
  78. data/meta/author +0 -1
  79. data/meta/contact +0 -1
  80. data/meta/homepage +0 -1
  81. data/meta/name +0 -1
  82. data/meta/requires +0 -4
  83. data/meta/summary +0 -1
  84. data/test/README +0 -1
  85. data/test/test_helper.rb +0 -4
  86. data/test/test_task.rb +0 -46
@@ -0,0 +1,46 @@
1
+ require 'ratch/shell'
2
+
3
+ KO.case 'Shell' do
4
+
5
+ test 'with no path given current working directory is used' do
6
+ sh = Ratch::Shell.new
7
+ sh.work == Pathname.new(Dir.pwd)
8
+ end
9
+
10
+ test :quiet? do |options|
11
+ o = Hash[*options]
12
+ sh = Ratch::Shell.new(o)
13
+ sh.quiet?
14
+ end
15
+
16
+ ok [:quiet, true]
17
+
18
+ test :trace? do |options|
19
+ o = Hash[*options]
20
+ sh = Ratch::Shell.new(o)
21
+ sh.trace?
22
+ end
23
+
24
+ ok [:trace, true]
25
+
26
+ test :noop? do |options|
27
+ o = Hash[*options]
28
+ sh = Ratch::Shell.new(o)
29
+ sh.noop?
30
+ end
31
+
32
+ ok [:noop, true]
33
+
34
+ test :dryrun? do |options|
35
+ o = Hash[*options]
36
+ sh = Ratch::Shell.new(o)
37
+ sh.dryrun?
38
+ end
39
+
40
+ ok [:noop, true, :trace, true]
41
+ ok [:dryrun, true]
42
+
43
+ no [:noop, true]
44
+ no [:verbose, true]
45
+
46
+ end
@@ -0,0 +1,361 @@
1
+ require 'ratch/core_ext'
2
+
3
+ # Test the Pathname extensions.
4
+ KO.case 'Pathname' do
5
+
6
+ # Test some standard pathname features to ensure nothing is screwed up.
7
+
8
+ test :initialize do
9
+ p1 = Pathname.new('a')
10
+ p2 = Pathname.new(p1)
11
+ p1 == p2 && 'a' == p1.to_s
12
+ end
13
+
14
+ test :== do |obj2|
15
+ obj1 = Pathname.new("a")
16
+ obj2 = Pathname.new("a")
17
+ obj1 == obj2
18
+ end
19
+
20
+ test :=== do
21
+ obj1 = Pathname.new("a")
22
+ obj2 = Pathname.new("a")
23
+ obj1 === obj2
24
+ end
25
+
26
+ test :eql? do
27
+ obj1 = Pathname.new("a")
28
+ obj2 = Pathname.new("a")
29
+ obj1.eql?(obj2)
30
+ end
31
+
32
+
33
+ class AnotherStringLike # :nodoc:
34
+ def initialize(s) @s = s end
35
+ def to_str() @s end
36
+ def ==(other) @s == other end
37
+ end
38
+
39
+ test 'equality' do
40
+ obj = Pathname.new("a")
41
+ str = "a"
42
+ sym = :a
43
+ ano = AnotherStringLike.new("a")
44
+ return false if obj == str
45
+ return false if str == obj
46
+ return false if obj == ano
47
+ return false if ano == obj
48
+ return false if obj == sym
49
+ return false if sym == obj
50
+ return true
51
+ end
52
+
53
+ test :hash do
54
+ h = {}
55
+ h[Pathname.new("a")] = 1
56
+ h[Pathname.new("a")] = 2
57
+ h.size == 1
58
+ end
59
+
60
+ test :<=> do |e, s1, s2|
61
+ p1 = Pathname.new(s1)
62
+ p2 = Pathname.new(s2)
63
+ e == (p1 <=> p2)
64
+ end
65
+
66
+ ok 0, "a", "a"
67
+ ok 1, "b", "a"
68
+ ok -1, "a", "b"
69
+
70
+ ok -1, "a", "a/"
71
+ ok -1, "a/", "a/b"
72
+ ok -1, "a/b", "a."
73
+ ok -1, "a.", "a0"
74
+
75
+ test :<=> do
76
+ (Pathname.new("a") <=> "a").nil? &&
77
+ ("a" <=> Pathname.new("a")).nil?
78
+ end
79
+
80
+ test :root do |a|
81
+ Pathname.new(a).root?
82
+ end
83
+
84
+ ok '/'
85
+ ok '//'
86
+ ok '///'
87
+
88
+ no ''
89
+ no 'a'
90
+
91
+ test :to_s do |a,b|
92
+ a == Pathname.new(b).to_s
93
+ end
94
+
95
+ ok '/' , '/'
96
+ ok 'a/', 'a/'
97
+ ok '/a', '/a'
98
+ ok '.' , '.'
99
+ ok '..', '..'
100
+
101
+ test :cleanpath do |a,b|
102
+ a == Pathname.new(b).cleanpath(true).to_s
103
+ end
104
+
105
+ ok '/' , '/'
106
+ ok '/' , '//'
107
+ ok '/' , '/.'
108
+ ok '/' , '/..'
109
+ ok '/', '/./..'
110
+ ok '/', '/../.'
111
+ ok '/', '/./../'
112
+ ok '/', '/.././'
113
+
114
+ ok '.' , '.'
115
+ ok '.' , './'
116
+
117
+ ok '..', '..'
118
+ ok '..', '../'
119
+ ok '..', './..'
120
+ ok '..', '../.'
121
+ ok '..', './../'
122
+ ok '..', '.././'
123
+
124
+ ok 'a' , 'a'
125
+ ok 'a/' , 'a/'
126
+ ok 'a/.' , 'a/.'
127
+ ok 'a/.' , 'a/./'
128
+ ok 'a/..', 'a/../'
129
+ ok 'a/..', 'a/../.'
130
+
131
+ ok '/a' , '/a'
132
+ ok '/a/.', '/a/.'
133
+
134
+ ok 'a/b' , 'a//b'
135
+ ok 'a/b/c', 'a/b/c'
136
+ ok 'b/c' , './b/c'
137
+ ok 'a/c' , 'a/./c'
138
+ ok 'a/b/.', 'a/b/.'
139
+
140
+ ok '/a', '/../.././../a'
141
+ ok 'a/b/../../../../c/../d', 'a/b/../../../../c/../d'
142
+
143
+ =begin
144
+ def test_cleanpath_no_symlink
145
+ assert_equal('/', Pathname.new('/').cleanpath.to_s)
146
+ assert_equal('/', Pathname.new('//').cleanpath.to_s)
147
+ assert_equal('', Pathname.new('').cleanpath.to_s)
148
+
149
+ assert_equal('.', Pathname.new('.').cleanpath.to_s)
150
+ assert_equal('..', Pathname.new('..').cleanpath.to_s)
151
+ assert_equal('a', Pathname.new('a').cleanpath.to_s)
152
+ assert_equal('/', Pathname.new('/.').cleanpath.to_s)
153
+ assert_equal('/', Pathname.new('/..').cleanpath.to_s)
154
+ assert_equal('/a', Pathname.new('/a').cleanpath.to_s)
155
+ assert_equal('.', Pathname.new('./').cleanpath.to_s)
156
+ assert_equal('..', Pathname.new('../').cleanpath.to_s)
157
+ assert_equal('a', Pathname.new('a/').cleanpath.to_s)
158
+
159
+ assert_equal('a/b', Pathname.new('a//b').cleanpath.to_s)
160
+ assert_equal('a', Pathname.new('a/.').cleanpath.to_s)
161
+ assert_equal('a', Pathname.new('a/./').cleanpath.to_s)
162
+ assert_equal('.', Pathname.new('a/../').cleanpath.to_s)
163
+ assert_equal('/a', Pathname.new('/a/.').cleanpath.to_s)
164
+ assert_equal('..', Pathname.new('./..').cleanpath.to_s)
165
+ assert_equal('..', Pathname.new('../.').cleanpath.to_s)
166
+ assert_equal('..', Pathname.new('./../').cleanpath.to_s)
167
+ assert_equal('..', Pathname.new('.././').cleanpath.to_s)
168
+ assert_equal('/', Pathname.new('/./..').cleanpath.to_s)
169
+ assert_equal('/', Pathname.new('/../.').cleanpath.to_s)
170
+ assert_equal('/', Pathname.new('/./../').cleanpath.to_s)
171
+ assert_equal('/', Pathname.new('/.././').cleanpath.to_s)
172
+ return false unless obj.equal? obj.taint
173
+ assert_equal('a/b/c', Pathname.new('a/b/c').cleanpath.to_s)
174
+ assert_equal('b/c', Pathname.new('./b/c').cleanpath.to_s)
175
+ assert_equal('a/c', Pathname.new('a/./c').cleanpath.to_s)
176
+ assert_equal('a/b', Pathname.new('a/b/.').cleanpath.to_s)
177
+ assert_equal('.', Pathname.new('a/../.').cleanpath.to_s)
178
+
179
+ assert_equal('/a', Pathname.new('/../.././../a').cleanpath.to_s)
180
+ assert_equal('../../d', Pathname.new('a/b/../../../../c/../d').cleanpath.to_s)
181
+ end
182
+ =end
183
+
184
+ =begin
185
+ def test_destructive_update
186
+ path = Pathname.new("a")
187
+ path.to_s.replace "b"
188
+ assert_equal(Pathname.new("a"), path)
189
+ end
190
+ =end
191
+
192
+ #def test_null_character
193
+ # assert_raise(ArgumentError) { Pathname.new("\0") }
194
+ #end
195
+
196
+ test :relative_path_from do |result, dest, base|
197
+ Pathname.new(result) == Pathname.new(dest).relative_path_from(Pathname.new(base))
198
+ end
199
+
200
+ ok "../a", "a", "b"
201
+ ok "../a", "a", "b/"
202
+ ok "../a", "a/", "b"
203
+ ok "../a", "a/", "b/"
204
+ ok "../a", "/a", "/b"
205
+ ok "../a", "/a", "/b/"
206
+ ok "../a", "/a/", "/b"
207
+ ok "../a", "/a/", "/b/"
208
+
209
+ ok "../b", "a/b", "a/c"
210
+ ok "../a", "../a", "../b"
211
+
212
+ ok "a", "a", "."
213
+ ok "..", ".", "a"
214
+
215
+ ok ".", ".", "."
216
+ ok ".", "..", ".."
217
+ ok "..", "..", "."
218
+
219
+ ok "c/d", "/a/b/c/d", "/a/b"
220
+ ok "../..", "/a/b", "/a/b/c/d"
221
+ ok "../../../../e", "/e", "/a/b/c/d"
222
+ ok "../b/c", "a/b/c", "a/d"
223
+
224
+ ok "../a", "/../a", "/b"
225
+ ok "../../a", "../a", "b"
226
+ ok ".", "/a/../../b", "/b"
227
+ ok "..", "a/..", "a"
228
+ ok ".", "a/../b", "b"
229
+
230
+ ok "a", "a", "b/.."
231
+ ok "b/c", "b/c", "b/.."
232
+
233
+ test :relative_path_from do |dest, base|
234
+ ArgumentError.raised? {
235
+ Pathname.new(dest).relative_path_from(Pathname.new(base))
236
+ }
237
+ end
238
+
239
+ ok "/", "."
240
+ ok ".", "/"
241
+ ok "a", ".."
242
+ ok ".", ".."
243
+
244
+ test :+ do |a, b, c|
245
+ a = Pathname.new(a)
246
+ b = Pathname.new(b)
247
+ c = Pathname.new(c)
248
+ a == b + c
249
+ end
250
+
251
+ ok 'a/b', 'a', 'b'
252
+ ok 'a', 'a', '.'
253
+ ok 'b', '.', 'b'
254
+ ok '.', '.', '.'
255
+
256
+ ok '/', '/', '..'
257
+ ok '.', 'a', '..'
258
+ ok 'a', 'a/b', '..'
259
+ ok '../..', '..', '..'
260
+ ok '/c', '/', '../c'
261
+ ok 'c', 'a', '../c'
262
+ ok 'a/c', 'a/b', '../c'
263
+ ok '../../c', '..', '../c'
264
+
265
+ # TODO: Is this really what we want?
266
+ ok '/b', 'a', '/b'
267
+
268
+ test :taint do
269
+ obj = Pathname.new("a")
270
+ obj.equal? obj.taint
271
+ end
272
+
273
+ test :untaint do
274
+ obj = Pathname.new("a")
275
+ obj.equal? obj.untaint
276
+ end
277
+
278
+ test :tainted? do
279
+ return false if Pathname.new("a").tainted?
280
+ return false if Pathname.new("a").to_s.tainted?
281
+ true
282
+ end
283
+
284
+ test :tainted? do
285
+ Pathname.new("a" ).taint.tainted? &&
286
+ Pathname.new("a" ).taint.to_s.tainted? &&
287
+ Pathname.new("a".taint) .tainted? &&
288
+ Pathname.new("a".taint) .to_s.tainted? &&
289
+ Pathname.new("a".taint).taint .tainted? &&
290
+ Pathname.new("a".taint).taint.to_s.tainted?
291
+ end
292
+
293
+ test :tainted? do
294
+ str = "a"
295
+ path = Pathname.new(str)
296
+ str.taint
297
+ return false if path.tainted?
298
+ return false if path.to_s.tainted?
299
+ return true
300
+ end
301
+
302
+ test :tainted? do
303
+ !Pathname.new("a").taint.untaint .tainted? &&
304
+ !Pathname.new("a").taint.untaint.to_s.tainted?
305
+ end
306
+
307
+ test :tainted? do
308
+ str = "a".taint
309
+ path = Pathname.new(str)
310
+ str.untaint
311
+ path.tainted? && path.to_s.tainted?
312
+ end
313
+
314
+ test :freeze do
315
+ obj = Pathname.new("a")
316
+ obj.equal? obj.freeze
317
+ end
318
+
319
+ test :freeze do
320
+ Pathname.new("a" ).freeze.frozen? &&
321
+ Pathname.new("a".freeze).freeze.frozen?
322
+ end
323
+
324
+ test :freeze do
325
+ not (
326
+ Pathname.new("a" ) .frozen? &&
327
+ Pathname.new("a".freeze) .frozen? &&
328
+ Pathname.new("a" ) .to_s.frozen? &&
329
+ Pathname.new("a".freeze) .to_s.frozen? &&
330
+ Pathname.new("a" ).freeze.to_s.frozen? &&
331
+ Pathname.new("a".freeze).freeze.to_s.frozen?
332
+ )
333
+ end
334
+
335
+ test :to_s do
336
+ str = "a"
337
+ obj = Pathname.new(str)
338
+ str == obj.to_s &&
339
+ !str.equal?(obj.to_s) &&
340
+ !obj.to_s.equal?(obj.to_s)
341
+ end
342
+
343
+ =begin
344
+ test "kernel open" do
345
+ count = 0
346
+ stat1 = File.stat(__FILE__)
347
+ result = Kernel.open(Pathname.new(__FILE__)) do |f|
348
+ stat2 = f.stat
349
+ assert_equal(stat1.dev, stat2.dev)
350
+ assert_equal(stat1.ino, stat2.ino)
351
+ assert_equal(stat1.size, stat2.size)
352
+ count += 1
353
+ 2
354
+ end
355
+ assert_equal(1, count)
356
+ assert_equal(2, result)
357
+ end
358
+ =end
359
+
360
+ end
361
+
@@ -0,0 +1,4 @@
1
+ puts "Ruby v#{RUBY_VERSION}"
2
+
3
+ $LOAD_PATH.unshift(File.dirname('__FILE__') + '/../lib')
4
+
@@ -0,0 +1,6 @@
1
+ # TODO
2
+
3
+ KO.case "Ratch::CLI" do
4
+
5
+ end
6
+
@@ -0,0 +1,12 @@
1
+ # TODO
2
+
3
+ KO.case "Ratch::ConfigUtils" do
4
+
5
+ #test "#configuration" do
6
+ #end
7
+
8
+ #test "configuration!" do
9
+ #end
10
+
11
+ end
12
+
@@ -0,0 +1,10 @@
1
+ # TODO
2
+
3
+ KO.case "Ratch::EMailUtils" do
4
+
5
+ setup do
6
+ #p Dir.pwd
7
+ end
8
+
9
+ end
10
+
@@ -0,0 +1,6 @@
1
+ # TODO
2
+
3
+ KO.case "Ratch::FTPUtils" do
4
+
5
+ end
6
+