ratch 1.2.0 → 2.0.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.
- checksums.yaml +7 -0
- data/HISTORY.rdoc +87 -0
- data/README.rdoc +86 -66
- data/bin/ludo +26 -10
- data/lib/ratch/batch.rb +115 -74
- data/lib/ratch/core_ext/facets.rb +2 -1
- data/lib/ratch/core_ext/to_console.rb +11 -11
- data/lib/ratch/file_list.rb +6 -15
- data/lib/ratch/script.rb +1 -1
- data/lib/ratch/shell.rb +356 -518
- data/lib/ratch/utils/config.rb +4 -4
- data/lib/ratch/utils/email.rb +20 -97
- data/lib/ratch/utils/rdoc.rb +4 -7
- data/lib/ratch/utils/tar.rb +94 -50
- data/lib/ratch/utils/xdg.rb +2 -3
- data/lib/ratch/utils/zlib.rb +5 -4
- data/lib/ratch/version.rb +3 -0
- data/lib/ratch.rb +8 -24
- metadata +134 -157
- data/.ruby +0 -99
- data/History.rdoc +0 -35
- data/License.txt +0 -204
- data/Version +0 -1
- data/lib/ratch/console.rb +0 -199
- data/lib/ratch/system.rb +0 -15
- data/lib/ratch/utils/ftp.rb +0 -134
- data/lib/ratch/utils/pom.rb +0 -22
- data/lib/ratch.yml +0 -99
- data/man/ratch.1 +0 -28
- data/spec/01_shell.rdoc +0 -198
- data/spec/02_script.rdoc +0 -34
- data/spec/03_batch.rdoc +0 -71
- data/spec/04_system.rdoc +0 -3
- data/spec/applique/array.rb +0 -8
- data/spec/applique/setup.rb +0 -20
- data/test/case_batch.rb +0 -63
- data/test/case_shell.rb +0 -46
- data/test/core_ext/case_pathname.rb +0 -361
- data/test/helper.rb +0 -4
- data/test/utils/case_cli.rb +0 -6
- data/test/utils/case_config.rb +0 -12
- data/test/utils/case_email.rb +0 -10
- data/test/utils/case_ftp.rb +0 -6
- data/test/utils/case_pom.rb +0 -17
- data/test/utils/case_rdoc.rb +0 -23
- data/test/utils/case_tar.rb +0 -6
- data/test/utils/case_zlib.rb +0 -11
- data/test/utils/fixtures/pom_sample/Profile +0 -4
- data/test/utils/fixtures/rdoc_sample/README.rdoc +0 -4
- data/test/utils/fixtures/rdoc_sample/lib/rdoc_sample/rdoc_sample.rb +0 -9
- /data/{COPYING → LICENSE.txt} +0 -0
data/spec/02_script.rdoc
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
= Ratch::Script
|
|
2
|
-
|
|
3
|
-
The Ratch::Script class is the context used for evaluating Ratch-based
|
|
4
|
-
batch files, aka shell scripts.
|
|
5
|
-
|
|
6
|
-
require 'ratch/script'
|
|
7
|
-
|
|
8
|
-
In most every respect the Script class behaves like Ratch::Shell, except that
|
|
9
|
-
its initializer takes a file name to be evaluated.
|
|
10
|
-
|
|
11
|
-
Let's say we have a Ratch script called 'foo.ratch':
|
|
12
|
-
|
|
13
|
-
#!/usr/bin/env ratch
|
|
14
|
-
|
|
15
|
-
@test_message = "Hello World!"
|
|
16
|
-
|
|
17
|
-
We can load the script via Ratch::Script.new.
|
|
18
|
-
|
|
19
|
-
script = Ratch::Script.new('foo.ratch')
|
|
20
|
-
|
|
21
|
-
The file name can be accessed from the script using #script_file.
|
|
22
|
-
|
|
23
|
-
script.script_file.assert == 'foo.ratch'
|
|
24
|
-
|
|
25
|
-
To execute a script, use the `#execute!` method, or it's alias `#run!`.
|
|
26
|
-
|
|
27
|
-
script.execute!
|
|
28
|
-
|
|
29
|
-
We can see that the script did indeed execute by plubming for the instance
|
|
30
|
-
variable it set.
|
|
31
|
-
|
|
32
|
-
msg = script.instance_variable_get('@test_message')
|
|
33
|
-
msg.assert == "Hello World!"
|
|
34
|
-
|
data/spec/03_batch.rdoc
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
= Ratch::Batch
|
|
2
|
-
|
|
3
|
-
The Batch class makes makes it possible to work with multiple files
|
|
4
|
-
at once as easily as one would work with a single file.
|
|
5
|
-
|
|
6
|
-
require 'ratch/batch'
|
|
7
|
-
|
|
8
|
-
The demonstration sets up a sample directory consisting of the following
|
|
9
|
-
entires in the temporary working directory:
|
|
10
|
-
|
|
11
|
-
foo.txt
|
|
12
|
-
bar.txt
|
|
13
|
-
zoo/
|
|
14
|
-
zoo/one.txt
|
|
15
|
-
zoo/two.txt
|
|
16
|
-
|
|
17
|
-
To create a new Batch instance, pass the the base directory and any
|
|
18
|
-
inclusion patterns to the initializer.
|
|
19
|
-
|
|
20
|
-
batch = Ratch::Batch.new('.', '*.txt')
|
|
21
|
-
|
|
22
|
-
In this example we will get every `.txt` file at the toplevel of the base
|
|
23
|
-
directory.
|
|
24
|
-
|
|
25
|
-
batch.to_a.assert = ['foo.txt', 'bar.txt'].to_pathnames
|
|
26
|
-
|
|
27
|
-
To get a list of files relative to the base directory, use #entries.
|
|
28
|
-
|
|
29
|
-
batch.entries.assert = ['foo.txt', 'bar.txt'].to_pathnames
|
|
30
|
-
|
|
31
|
-
Internally a Batch instance tracks the files selected via a Ratch::FileList
|
|
32
|
-
object. This can be directly accessed via the #list method.
|
|
33
|
-
|
|
34
|
-
batch.file_list.assert.is_a?(Ratch::FileList)
|
|
35
|
-
|
|
36
|
-
batch.file_list.to_a.assert = ['foo.txt', 'bar.txt']
|
|
37
|
-
|
|
38
|
-
As with the delegated FileTest methods of the Shell class, Batch can test
|
|
39
|
-
the set of files in agregate. For example, to ensure all the entries
|
|
40
|
-
are files we can use the #file? method.
|
|
41
|
-
|
|
42
|
-
batch.assert.file?
|
|
43
|
-
|
|
44
|
-
Likewise to enusre none the entires are directories we can use the #directory?
|
|
45
|
-
method.
|
|
46
|
-
|
|
47
|
-
batch.refute.directory?
|
|
48
|
-
|
|
49
|
-
The Batch list can be reduced to just files or just directories via the #file!
|
|
50
|
-
and #directory! methods.
|
|
51
|
-
|
|
52
|
-
batch = Ratch::Batch.new('.', '*')
|
|
53
|
-
batch.file!
|
|
54
|
-
batch.list.assert = ['foo.txt', 'bar.txt']
|
|
55
|
-
|
|
56
|
-
batch = Ratch::Batch.new('.', '*')
|
|
57
|
-
batch.directory!
|
|
58
|
-
batch.list.assert = ['zoo']
|
|
59
|
-
|
|
60
|
-
The Batch class is enumerable, both #each and #size are defined.
|
|
61
|
-
|
|
62
|
-
batch = Ratch::Batch.new('.', '*.txt')
|
|
63
|
-
|
|
64
|
-
batch.each do |pathname|
|
|
65
|
-
pathname.assert.is_a?(Pathname)
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
batch.size.assert = 2
|
|
69
|
-
|
|
70
|
-
Any enumerable method is likewise applicable.
|
|
71
|
-
|
data/spec/04_system.rdoc
DELETED
data/spec/applique/array.rb
DELETED
data/spec/applique/setup.rb
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
require 'fileutils'
|
|
2
|
-
|
|
3
|
-
Before :demo do
|
|
4
|
-
clear_working_directory!
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
When "consisting of the following entires" do |text|
|
|
8
|
-
text.split(/\s+/).each do |file|
|
|
9
|
-
if /\/$/ =~ file
|
|
10
|
-
FileUtils.mkdir_p(file) unless File.directory?(file)
|
|
11
|
-
else
|
|
12
|
-
File.open(file, 'w+'){ |f| f << "SAMPLE #{file}".upcase }
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
When "Let's say we have a Ratch script called '(((.*?)))'" do |file, text|
|
|
18
|
-
File.open(file, 'w'){ |f| f << text }
|
|
19
|
-
end
|
|
20
|
-
|
data/test/case_batch.rb
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
require 'ratch/batch'
|
|
2
|
-
|
|
3
|
-
KO.case Ratch::Batch do
|
|
4
|
-
|
|
5
|
-
def initialize
|
|
6
|
-
stage_clear
|
|
7
|
-
stage_fake %w{a.txt b.txt d/x.txt d/y.txt}
|
|
8
|
-
|
|
9
|
-
@batch1 = Ratch::Batch.new('.')
|
|
10
|
-
@batch2 = Ratch::Batch.new('.', '*')
|
|
11
|
-
@batch3 = Ratch::Batch.new('.', '**/*')
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
test :local do
|
|
15
|
-
@batch1.local == Pathname.new('.')
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
test :list do
|
|
19
|
-
@batch1.list.is_a?(Array)
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
test :file_list do
|
|
23
|
-
@batch1.file_list.is_a?(Ratch::FileList)
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
test :each do
|
|
27
|
-
r = []
|
|
28
|
-
@batch2.each{ |pn| r << pn }
|
|
29
|
-
r.map(&:to_s).sort == %w{a.txt b.txt d}
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
test "passes #each thru to Enumerable methods" do
|
|
33
|
-
@batch2.all?{ |pn| pn.is_a? Pathname }
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
test :size do
|
|
37
|
-
batch = Ratch::Batch.new('.', '*')
|
|
38
|
-
batch.size == 3
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
test :directory? do
|
|
42
|
-
batch = Ratch::Batch.new('.', '*')
|
|
43
|
-
not batch.directory?
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
test :file? do
|
|
47
|
-
not @batch2.file?
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
test :directory! do
|
|
51
|
-
batch = Ratch::Batch.new('.', '*')
|
|
52
|
-
batch.directory!
|
|
53
|
-
batch.filenames == %w{d}
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
test :file! do
|
|
57
|
-
batch = Ratch::Batch.new('.', '*')
|
|
58
|
-
batch.file!
|
|
59
|
-
batch.filenames.sort == %w{a.txt b.txt}
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
end
|
|
63
|
-
|
data/test/case_shell.rb
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
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
|
|
@@ -1,361 +0,0 @@
|
|
|
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
|
-
|
data/test/helper.rb
DELETED
data/test/utils/case_cli.rb
DELETED
data/test/utils/case_config.rb
DELETED
data/test/utils/case_email.rb
DELETED
data/test/utils/case_ftp.rb
DELETED
data/test/utils/case_pom.rb
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
require 'ratch'
|
|
2
|
-
|
|
3
|
-
KO.case "Ratch::POMUtils" do
|
|
4
|
-
|
|
5
|
-
def initialize
|
|
6
|
-
stage_copy 'fixtures/pom_sample'
|
|
7
|
-
|
|
8
|
-
@shell = Ratch::Shell.new
|
|
9
|
-
@shell.extend(Ratch::POMUtils)
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
test :project do
|
|
13
|
-
@shell.project.is_a?(::POM::Project)
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
end
|
|
17
|
-
|
data/test/utils/case_rdoc.rb
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
require 'ratch'
|
|
2
|
-
|
|
3
|
-
KO.case "Ratch::RDocUtils" do
|
|
4
|
-
|
|
5
|
-
def initialize #before :all do
|
|
6
|
-
@shell = Ratch::Shell.new
|
|
7
|
-
@shell.extend(Ratch::RDocUtils)
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
setup do
|
|
11
|
-
stage_copy 'fixtures/rdoc_sample'
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
test "#rdoc" do
|
|
15
|
-
@shell.rdoc('README.rdoc', 'lib')
|
|
16
|
-
File.directory?('doc') &&
|
|
17
|
-
File.directory?('doc/classes') &&
|
|
18
|
-
File.directory?('doc/files') &&
|
|
19
|
-
File.file?('doc/classes/RDocSample.html')
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
end
|
|
23
|
-
|