facets 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/core/facets/array/delete.rb +1 -45
- data/lib/core/facets/array/indexable.rb +0 -142
- data/lib/core/facets/array/merge.rb +0 -50
- data/lib/core/facets/array/rotate.rb +6 -37
- data/lib/core/facets/array/select.rb +0 -26
- data/lib/core/facets/array/unzip.rb +6 -7
- data/lib/methods/facets/filetest/root.rb +1 -1
- data/meta/manifest.txt +0 -67
- data/meta/version.txt +1 -1
- data/task/methods +6 -3
- data/test/unit/array/test_delete.rb +33 -40
- data/test/unit/array/test_indexable.rb +118 -128
- data/test/unit/array/test_rotate.rb +22 -30
- data/test/unit/array/test_select.rb +14 -25
- metadata +2 -69
- data/lib/methods/facets/array/conjoin.rb +0 -1
- data/lib/methods/facets/array/merge.rb +0 -1
- data/lib/methods/facets/array/pad.rb +0 -1
- data/lib/methods/facets/array/rotate.rb +0 -1
- data/lib/methods/facets/array/select.rb +0 -1
- data/lib/methods/facets/array/splice.rb +0 -1
- data/lib/methods/facets/array/unzip.rb +0 -1
- data/lib/methods/facets/binding/eval.rb +0 -1
- data/lib/methods/facets/class/descendents.rb +0 -1
- data/lib/methods/facets/class/initializer.rb +0 -1
- data/lib/methods/facets/comparable/bound.rb +0 -1
- data/lib/methods/facets/comparable/cmp.rb +0 -1
- data/lib/methods/facets/dir/multiglob.rb +0 -1
- data/lib/methods/facets/enumerable/collate.rb +0 -1
- data/lib/methods/facets/enumerable/collect_with_counter.rb +0 -1
- data/lib/methods/facets/enumerable/count.rb +0 -1
- data/lib/methods/facets/enumerable/each_with_counter.rb +0 -1
- data/lib/methods/facets/enumerable/map_with_counter.rb +0 -1
- data/lib/methods/facets/enumerable/permutation.rb +0 -1
- data/lib/methods/facets/enumerable/probability.rb +0 -1
- data/lib/methods/facets/file/write.rb +0 -1
- data/lib/methods/facets/hash/at.rb +0 -1
- data/lib/methods/facets/hash/has_keys.rb +0 -1
- data/lib/methods/facets/hash/insert.rb +0 -1
- data/lib/methods/facets/hash/inverse.rb +0 -1
- data/lib/methods/facets/hash/rekey.rb +0 -1
- data/lib/methods/facets/hash/traverse.rb +0 -1
- data/lib/methods/facets/hash/weave.rb +0 -1
- data/lib/methods/facets/integer/bitmask.rb +0 -1
- data/lib/methods/facets/integer/factorial.rb +0 -1
- data/lib/methods/facets/integer/of.rb +0 -1
- data/lib/methods/facets/kernel/ask.rb +0 -1
- data/lib/methods/facets/kernel/constant.rb +0 -1
- data/lib/methods/facets/kernel/op_esc.rb +0 -1
- data/lib/methods/facets/kernel/populate.rb +0 -1
- data/lib/methods/facets/kernel/require_esc.rb +0 -1
- data/lib/methods/facets/kernel/respond.rb +0 -1
- data/lib/methods/facets/kernel/tap.rb +0 -1
- data/lib/methods/facets/kernel/val.rb +0 -1
- data/lib/methods/facets/matchdata/matchset.rb +0 -1
- data/lib/methods/facets/module/abstract.rb +0 -1
- data/lib/methods/facets/nilclass/ergo.rb +0 -1
- data/lib/methods/facets/nilclass/status.rb +0 -1
- data/lib/methods/facets/proc/bind.rb +0 -1
- data/lib/methods/facets/proc/compose.rb +0 -1
- data/lib/methods/facets/range/combine.rb +0 -1
- data/lib/methods/facets/range/overlap.rb +0 -1
- data/lib/methods/facets/regexp/arity.rb +0 -1
- data/lib/methods/facets/string/blank.rb +0 -1
- data/lib/methods/facets/string/bracket.rb +0 -1
- data/lib/methods/facets/string/crypt.rb +0 -1
- data/lib/methods/facets/string/interpolate.rb +0 -1
- data/lib/methods/facets/string/natcmp.rb +0 -1
- data/lib/methods/facets/string/nchar.rb +0 -1
- data/lib/methods/facets/string/range.rb +0 -1
- data/lib/methods/facets/string/regesc.rb +0 -1
- data/lib/methods/facets/string/splice.rb +0 -1
- data/lib/methods/facets/symbol/chomp.rb +0 -1
- data/lib/methods/facets/symbol/generate.rb +0 -1
- data/lib/methods/facets/symbol/not.rb +0 -1
- data/lib/methods/facets/symbol/shadow.rb +0 -1
- data/lib/methods/facets/symbol/succ.rb +0 -1
- data/lib/methods/facets/time/change.rb +0 -1
- data/lib/methods/facets/time/elapse.rb +0 -1
- data/lib/methods/facets/unboundmethod/arguments.rb +0 -1
- data/lib/methods/facets/unboundmethod/name.rb +0 -1
data/meta/version.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.
|
1
|
+
2.0.2 stable (2007-10-03)
|
data/task/methods
CHANGED
@@ -16,9 +16,9 @@ require 'facets/module/require'
|
|
16
16
|
|
17
17
|
config = configuration['methods']
|
18
18
|
|
19
|
-
source = config['source']
|
20
|
-
folder = config['folder']
|
21
|
-
ignore = config['ignore']
|
19
|
+
source = config['source'] # from where
|
20
|
+
folder = config['folder'] # to where
|
21
|
+
ignore = config['ignore'] # classes/modules to ignore
|
22
22
|
|
23
23
|
REDIRECT_WRITE = []
|
24
24
|
|
@@ -30,6 +30,9 @@ main :methods => [ :generate_redirects, :remove_redirects ] do
|
|
30
30
|
meth = meth.chomp('!').chomp('=').chomp('?')
|
31
31
|
meth = op_esc(meth)
|
32
32
|
meth_file = "#{folder}/#{klass.to_s.downcase}/#{meth}.rb"
|
33
|
+
# if the the redirect has the same name as the original, don't botther.
|
34
|
+
next if file == "facets/#{klass.to_s.downcase}/#{meth}.rb"
|
35
|
+
# create redirection file
|
33
36
|
meth_dir = File.dirname(meth_file)
|
34
37
|
mkdir_p(meth_dir) unless File.directory?(meth_dir)
|
35
38
|
if noharm?
|
@@ -1,45 +1,38 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
# for lib/facets/array/delete.rb
|
8
|
-
#
|
9
|
-
# Extracted Mon Sep 03 16:23:07 -0700 2007
|
10
|
-
# w/ Test Extraction Ratchet
|
11
|
-
#
|
12
|
-
|
13
|
-
require 'facets/array/delete.rb'
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
require 'test/unit'
|
18
|
-
|
19
|
-
class TestArray < Test::Unit::TestCase
|
20
|
-
|
21
|
-
def test_delete_unless
|
22
|
-
a = [1,2,3]
|
23
|
-
a.delete_unless{ |e| e == 2 }
|
24
|
-
assert_equal( [2], a )
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_delete_values
|
28
|
-
a = [1,2,3,4]
|
29
|
-
assert_equal( [1,2], a.delete_values(1,2) )
|
30
|
-
assert_equal( [3,4], a )
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_delete_values_at
|
34
|
-
a = [1,2,3,4]
|
35
|
-
assert_equal( [2,3], a.delete_values_at(1,2) )
|
36
|
-
assert_equal( [1,4], a )
|
37
|
-
a = [1,2,3,4]
|
38
|
-
assert_equal( [1,2,3], a.delete_values_at(0..2) )
|
39
|
-
assert_equal( [4], a )
|
40
|
-
end
|
1
|
+
# _____ _
|
2
|
+
# |_ _|__ ___| |_
|
3
|
+
# | |/ _ \/ __| __|
|
4
|
+
# | | __/\__ \ |
|
5
|
+
# |_|\___||___/\__|
|
6
|
+
#
|
41
7
|
|
8
|
+
require 'facets/array/delete.rb'
|
9
|
+
|
10
|
+
require 'test/unit'
|
11
|
+
|
12
|
+
class TestArray < Test::Unit::TestCase
|
13
|
+
|
14
|
+
def test_delete_unless
|
15
|
+
a = [1,2,3]
|
16
|
+
a.delete_unless{ |e| e == 2 }
|
17
|
+
assert_equal( [2], a )
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_delete_values
|
21
|
+
a = [1,2,3,4]
|
22
|
+
assert_equal( [1,2], a.delete_values(1,2) )
|
23
|
+
assert_equal( [3,4], a )
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_delete_values_at
|
27
|
+
a = [1,2,3,4]
|
28
|
+
assert_equal( [2,3], a.delete_values_at(1,2) )
|
29
|
+
assert_equal( [1,4], a )
|
30
|
+
a = [1,2,3,4]
|
31
|
+
assert_equal( [1,2,3], a.delete_values_at(0..2) )
|
32
|
+
assert_equal( [4], a )
|
42
33
|
end
|
43
34
|
|
35
|
+
end
|
36
|
+
|
44
37
|
|
45
38
|
|
@@ -1,136 +1,126 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
1
|
+
# _____ _
|
2
|
+
# |_ _|__ ___| |_
|
3
|
+
# | |/ _ \/ __| __|
|
4
|
+
# | | __/\__ \ |
|
5
|
+
# |_|\___||___/\__|
|
6
|
+
#
|
7
|
+
|
8
|
+
require 'facets/array/indexable.rb'
|
9
|
+
|
10
|
+
require 'test/unit'
|
11
|
+
|
12
|
+
class TestArray < Test::Unit::TestCase
|
13
|
+
|
14
|
+
#def test_op_mod
|
15
|
+
# a = [:A,:B,:C]
|
16
|
+
# assert_equal( a[1], a/1 )
|
17
|
+
# assert_equal( :B, a/1 )
|
18
|
+
#end
|
8
19
|
#
|
9
|
-
#
|
10
|
-
#
|
20
|
+
#def test_op_div
|
21
|
+
# a = [:A,:B,:C]
|
22
|
+
# assert_equal( a[1], a/1 )
|
23
|
+
# assert_equal( :B, a/1 )
|
24
|
+
#end
|
25
|
+
|
26
|
+
def test_head
|
27
|
+
a = [1,2,3,4,5]
|
28
|
+
assert_equal( [1], a.head )
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_tail
|
32
|
+
a = [1,2,3,4,5]
|
33
|
+
assert_equal( [2,3,4,5], a.tail )
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_foot
|
37
|
+
a = [1,2,3,4,5]
|
38
|
+
assert_equal( [5], a.foot )
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_body
|
42
|
+
a = [1,2,3,4,5]
|
43
|
+
assert_equal( [1,2,3,4], a.body )
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_mid
|
47
|
+
a = [1,2,3,4,5]
|
48
|
+
b = [1,2,3,4,5,6]
|
49
|
+
assert_equal( 3, a.mid )
|
50
|
+
assert_equal( 4, b.mid )
|
51
|
+
assert_equal( 4, a.mid(1) )
|
52
|
+
assert_equal( 5, b.mid(1) )
|
53
|
+
assert_equal( 6, b.mid(2) )
|
54
|
+
assert_equal( 3, b.mid(-1) )
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_middle
|
58
|
+
a = [1,2,3,4,5]
|
59
|
+
b = [1,2,3,4,5,6]
|
60
|
+
assert_equal( 3, a.middle )
|
61
|
+
assert_equal( [3,4], b.middle )
|
62
|
+
end
|
63
|
+
|
64
|
+
#def test_op_fetch
|
65
|
+
# a = ['a','b','c','d','e','f']
|
66
|
+
# assert_equal( ['b','f'], a[[1,-1]] )
|
67
|
+
#end
|
11
68
|
#
|
69
|
+
#def test_op_store
|
70
|
+
# a = ['a','o','z']
|
71
|
+
# a[[0,2]] = ['A','Z']
|
72
|
+
# assert_equal( ['A','o','Z'], a )
|
73
|
+
# a[[0,-1]] = ['W','Y']
|
74
|
+
# assert_equal( ['W','o','Y'], a )
|
75
|
+
#end
|
76
|
+
|
77
|
+
def test_thru
|
78
|
+
assert_equal( [2,3,4], [0,1,2,3,4,5].thru(2,4) )
|
79
|
+
assert_equal( [0,1], [0,1,2,3,4,5].thru(0,1) )
|
80
|
+
end
|
12
81
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
class TestArray < Test::Unit::TestCase
|
20
|
-
|
21
|
-
def test_head
|
22
|
-
a = [1,2,3,4,5]
|
23
|
-
assert_equal( [1], a.head )
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_tail
|
27
|
-
a = [1,2,3,4,5]
|
28
|
-
assert_equal( [2,3,4,5], a.tail )
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_foot
|
32
|
-
a = [1,2,3,4,5]
|
33
|
-
assert_equal( [5], a.foot )
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_body
|
37
|
-
a = [1,2,3,4,5]
|
38
|
-
assert_equal( [1,2,3,4], a.body )
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_mid
|
42
|
-
a = [1,2,3,4,5]
|
43
|
-
b = [1,2,3,4,5,6]
|
44
|
-
assert_equal( 3, a.mid )
|
45
|
-
assert_equal( 4, b.mid )
|
46
|
-
assert_equal( 4, a.mid(1) )
|
47
|
-
assert_equal( 5, b.mid(1) )
|
48
|
-
assert_equal( 6, b.mid(2) )
|
49
|
-
assert_equal( 3, b.mid(-1) )
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_middle
|
53
|
-
a = [1,2,3,4,5]
|
54
|
-
b = [1,2,3,4,5,6]
|
55
|
-
assert_equal( 3, a.middle )
|
56
|
-
assert_equal( [3,4], b.middle )
|
57
|
-
end
|
58
|
-
|
59
|
-
#def test_op_mod
|
60
|
-
# a = [:A,:B,:C]
|
61
|
-
# assert_equal( a[1], a/1 )
|
62
|
-
# assert_equal( :B, a/1 )
|
63
|
-
#end
|
64
|
-
#
|
65
|
-
#def test_op_div
|
66
|
-
# a = [:A,:B,:C]
|
67
|
-
# assert_equal( a[1], a/1 )
|
68
|
-
# assert_equal( :B, a/1 )
|
69
|
-
#end
|
70
|
-
|
71
|
-
#def test_op_fetch
|
72
|
-
# a = ['a','b','c','d','e','f']
|
73
|
-
# assert_equal( ['b','f'], a[[1,-1]] )
|
74
|
-
#end
|
75
|
-
#
|
76
|
-
#def test_op_store
|
77
|
-
# a = ['a','o','z']
|
78
|
-
# a[[0,2]] = ['A','Z']
|
79
|
-
# assert_equal( ['A','o','Z'], a )
|
80
|
-
# a[[0,-1]] = ['W','Y']
|
81
|
-
# assert_equal( ['W','o','Y'], a )
|
82
|
-
#end
|
83
|
-
|
84
|
-
def test_thru
|
85
|
-
assert_equal( [2,3,4], [0,1,2,3,4,5].thru(2,4) )
|
86
|
-
assert_equal( [0,1], [0,1,2,3,4,5].thru(0,1) )
|
87
|
-
end
|
88
|
-
|
89
|
-
def test_first_eq
|
90
|
-
a = [1,2]
|
91
|
-
a.first = 0
|
92
|
-
assert_equal( [0,2], a )
|
93
|
-
end
|
94
|
-
|
95
|
-
def test_last_eq
|
96
|
-
a = [1,2]
|
97
|
-
a.last = 3
|
98
|
-
assert_equal( [1,3], a )
|
99
|
-
end
|
100
|
-
|
101
|
-
def test_ends
|
102
|
-
assert_equal( [1,2,3,4,5].ends, 4 )
|
103
|
-
end
|
104
|
-
|
105
|
-
def test_pos
|
106
|
-
a = [1,2,3,4,5]
|
107
|
-
assert_equal( 0, a.pos(1) )
|
108
|
-
assert_equal( 4, a.pos(-1) )
|
109
|
-
end
|
110
|
-
|
111
|
-
def test_range
|
112
|
-
a = [1,2,3,4,5]
|
113
|
-
b = [1,2,3,4,5,6]
|
114
|
-
assert_equal( (0..4), a.range )
|
115
|
-
assert_equal( (0..5), b.range )
|
116
|
-
assert_equal( (1..3), a.range(2,4) )
|
117
|
-
assert_equal( (1..2), b.range(2,3) )
|
118
|
-
assert_equal( (3..1), b.range(4,2) )
|
119
|
-
end
|
120
|
-
|
121
|
-
def test_first!
|
122
|
-
a = [1,2,3]
|
123
|
-
assert_equal( 1, a.first! )
|
124
|
-
assert_equal( [2,3], a )
|
125
|
-
end
|
126
|
-
|
127
|
-
def test_last!
|
128
|
-
a = [1,2,3]
|
129
|
-
assert_equal( 3, a.last! )
|
130
|
-
assert_equal( [1,2], a )
|
131
|
-
end
|
82
|
+
def test_first_eq
|
83
|
+
a = [1,2]
|
84
|
+
a.first = 0
|
85
|
+
assert_equal( [0,2], a )
|
86
|
+
end
|
132
87
|
|
88
|
+
def test_last_eq
|
89
|
+
a = [1,2]
|
90
|
+
a.last = 3
|
91
|
+
assert_equal( [1,3], a )
|
133
92
|
end
|
134
93
|
|
94
|
+
def test_ends
|
95
|
+
assert_equal( [1,2,3,4,5].ends, 4 )
|
96
|
+
end
|
135
97
|
|
98
|
+
def test_pos
|
99
|
+
a = [1,2,3,4,5]
|
100
|
+
assert_equal( 0, a.pos(1) )
|
101
|
+
assert_equal( 4, a.pos(-1) )
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_range
|
105
|
+
a = [1,2,3,4,5]
|
106
|
+
b = [1,2,3,4,5,6]
|
107
|
+
assert_equal( (0..4), a.range )
|
108
|
+
assert_equal( (0..5), b.range )
|
109
|
+
assert_equal( (1..3), a.range(2,4) )
|
110
|
+
assert_equal( (1..2), b.range(2,3) )
|
111
|
+
assert_equal( (3..1), b.range(4,2) )
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_first!
|
115
|
+
a = [1,2,3]
|
116
|
+
assert_equal( 1, a.first! )
|
117
|
+
assert_equal( [2,3], a )
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_last!
|
121
|
+
a = [1,2,3]
|
122
|
+
assert_equal( 3, a.last! )
|
123
|
+
assert_equal( [1,2], a )
|
124
|
+
end
|
136
125
|
|
126
|
+
end
|
@@ -1,39 +1,31 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
# for lib/facets/array/rotate.rb
|
8
|
-
#
|
9
|
-
# Extracted Mon Sep 03 16:23:07 -0700 2007
|
10
|
-
# w/ Test Extraction Ratchet
|
11
|
-
#
|
1
|
+
# _____ _
|
2
|
+
# |_ _|__ ___| |_
|
3
|
+
# | |/ _ \/ __| __|
|
4
|
+
# | | __/\__ \ |
|
5
|
+
# |_|\___||___/\__|
|
6
|
+
#
|
12
7
|
|
13
|
-
|
8
|
+
require 'facets/array/rotate.rb'
|
14
9
|
|
10
|
+
require 'test/unit'
|
15
11
|
|
12
|
+
class TestArrayRotate < Test::Unit::TestCase
|
16
13
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
def test_rotate
|
23
|
-
a = [1,2,3]
|
24
|
-
assert_equal( [3,1,2], a.rotate, 'clockwise' )
|
25
|
-
assert_equal( [2,3,1], a.rotate(-1), 'counter-clockwise' )
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_rotate!
|
29
|
-
a = [1,2,3]
|
30
|
-
a.rotate!
|
31
|
-
assert_equal( [3,1,2], a, 'clockwise' )
|
32
|
-
a.rotate!(-1)
|
33
|
-
assert_equal( [1,2,3], a, 'counter-clockwise' )
|
34
|
-
end
|
14
|
+
def test_rotate
|
15
|
+
a = [1,2,3]
|
16
|
+
assert_equal( [3,1,2], a.rotate, 'clockwise' )
|
17
|
+
assert_equal( [2,3,1], a.rotate(-1), 'counter-clockwise' )
|
18
|
+
end
|
35
19
|
|
20
|
+
def test_rotate!
|
21
|
+
a = [1,2,3]
|
22
|
+
a.rotate!
|
23
|
+
assert_equal( [3,1,2], a, 'clockwise' )
|
24
|
+
a.rotate!(-1)
|
25
|
+
assert_equal( [1,2,3], a, 'counter-clockwise' )
|
36
26
|
end
|
37
27
|
|
28
|
+
end
|
29
|
+
|
38
30
|
|
39
31
|
|
@@ -1,31 +1,20 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
# for lib/facets/array/select.rb
|
8
|
-
#
|
9
|
-
# Extracted Mon Sep 03 16:23:07 -0700 2007
|
10
|
-
# w/ Test Extraction Ratchet
|
11
|
-
#
|
1
|
+
# _____ _
|
2
|
+
# |_ _|__ ___| |_
|
3
|
+
# | |/ _ \/ __| __|
|
4
|
+
# | | __/\__ \ |
|
5
|
+
# |_|\___||___/\__|
|
6
|
+
#
|
12
7
|
|
13
|
-
|
8
|
+
require 'facets/array/select.rb'
|
14
9
|
|
10
|
+
require 'test/unit'
|
15
11
|
|
12
|
+
class TestArray < Test::Unit::TestCase
|
16
13
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
def test_select!
|
23
|
-
a = [1,2,3,4,5,6,7,8,9,10]
|
24
|
-
a.select!{ |e| e % 2 == 0 }
|
25
|
-
assert_equal( [2,4,6,8,10], a)
|
26
|
-
end
|
27
|
-
|
14
|
+
def test_select!
|
15
|
+
a = [1,2,3,4,5,6,7,8,9,10]
|
16
|
+
a.select!{ |e| e % 2 == 0 }
|
17
|
+
assert_equal( [2,4,6,8,10], a)
|
28
18
|
end
|
29
19
|
|
30
|
-
|
31
|
-
|
20
|
+
end
|