facets 2.0.2 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +3 -3
- data/README +6 -7
- data/lib/core/facets.rb +1 -46
- data/lib/core/facets/array.rb +3 -0
- data/lib/core/facets/array/indexable.rb +6 -1
- data/lib/core/facets/array/only.rb +20 -0
- data/lib/core/facets/dir/multiglob.rb +12 -1
- data/lib/core/facets/enumerable.rb +0 -1
- data/lib/core/facets/enumerable/collect.rb +1 -0
- data/lib/core/facets/enumerable/combination.rb +44 -90
- data/lib/core/facets/facets.rb +46 -0
- data/lib/core/facets/file/write.rb +46 -58
- data/lib/core/facets/hash.rb +2 -0
- data/lib/core/facets/hash/select.rb +14 -0
- data/lib/core/facets/integer/multiples.rb +12 -55
- data/lib/core/facets/kernel/val.rb +14 -0
- data/lib/core/facets/module/alias.rb +28 -9
- data/lib/core/facets/module/methods.rb +18 -0
- data/lib/core/facets/module/traits.rb +65 -70
- data/lib/core/facets/proc/compose.rb +15 -12
- data/lib/core/facets/stackable.rb +3 -2
- data/lib/core/facets/string/format.rb +4 -6
- data/lib/core/facets/string/tabs.rb +34 -0
- data/lib/core/facets/symbol.rb +1 -0
- data/lib/core/facets/symbol/succ.rb +1 -42
- data/lib/core/facets/symbol/to_proc.rb +34 -0
- data/lib/methods/facets/array/contains.rb +1 -0
- data/lib/methods/facets/facets/require_core.rb +1 -0
- data/lib/methods/facets/file/writelines.rb +1 -0
- data/lib/methods/facets/io/writelines.rb +1 -0
- data/lib/methods/facets/kernel/not_nil.rb +1 -0
- data/lib/methods/facets/module/conflict.rb +1 -0
- data/lib/methods/facets/module/instance_method_defined.rb +1 -0
- data/lib/methods/facets/module/module_method_defined.rb +1 -0
- data/lib/methods/facets/module/private_conflict.rb +1 -0
- data/lib/methods/facets/module/protected_conflict.rb +1 -0
- data/lib/methods/facets/module/public_conflict.rb +1 -0
- data/lib/methods/facets/string/expand_tabs.rb +1 -0
- data/lib/methods/facets/string/outdent.rb +1 -0
- data/lib/methods/facets/string/taballto.rb +1 -0
- data/lib/more/facets/arguments.rb +1 -1
- data/lib/more/facets/association.rb +0 -46
- data/lib/more/facets/autoarray.rb +0 -28
- data/lib/more/facets/command.rb +341 -8
- data/lib/more/facets/dictionary.rb +25 -131
- data/lib/more/facets/downloader.rb +1 -1
- data/lib/more/facets/infinity.rb +3 -3
- data/lib/more/facets/interval.rb +0 -161
- data/lib/more/facets/multiton.rb +16 -12
- data/lib/more/facets/namespace.rb +1 -1
- data/lib/more/facets/ostruct.rb +46 -10
- data/lib/more/facets/overload.rb +0 -51
- data/lib/more/facets/paramix.rb +0 -97
- data/lib/more/facets/pp_s.rb +30 -0
- data/lib/more/facets/progressbar.rb +18 -10
- data/lib/more/facets/prototype.rb +1 -40
- data/lib/more/facets/random.rb +1 -0
- data/lib/more/facets/rbsystem.rb +4 -1
- data/lib/more/facets/snapshot.rb +8 -1
- data/lib/more/facets/stylize.rb +2 -0
- data/meta/{project.yaml → facets-2.0.3.roll} +22 -14
- data/meta/manifest.txt +38 -8
- data/task/{config.yaml → config/general.yaml} +7 -2
- data/task/{rdoc.yaml → config/rdoc.yaml} +1 -1
- data/task/crosstest +309 -0
- data/task/isotest +293 -0
- data/task/loadtest +28 -0
- data/task/methods +4 -4
- data/task/prepare +5 -0
- data/task/publish +2 -2
- data/task/rdoc +1 -0
- data/task/syntax +29 -0
- data/task/test +0 -1
- data/task/testeach +42 -0
- data/task/testpairs +50 -0
- data/test/lib/rq.rb +15 -0
- data/test/unit/array/test_merge.rb +21 -43
- data/test/unit/array/test_only.rb +21 -0
- data/test/unit/enumerable/test_collect.rb +1 -21
- data/test/unit/enumerable/test_combination.rb +50 -44
- data/test/unit/file/test_topath.rb +48 -57
- data/test/unit/file/test_write.rb +82 -0
- data/test/unit/hash/test_select.rb +43 -0
- data/test/unit/integer/test_multiples.rb +28 -32
- data/test/unit/kernel/test_report.rb +9 -12
- data/test/unit/kernel/test_val.rb +50 -45
- data/test/unit/module/test_include.rb +56 -57
- data/test/unit/module/test_name.rb +42 -55
- data/test/unit/module/test_traits.rb +46 -47
- data/test/unit/string/test_filter.rb +19 -34
- data/test/unit/string/test_format.rb +87 -96
- data/test/unit/string/test_regesc.rb +18 -26
- data/test/unit/string/test_tabs.rb +226 -119
- data/test/unit/symbol/test_succ.rb +14 -23
- data/test/unit/symbol/test_to_proc.rb +41 -0
- data/test/unit/test_association.rb +38 -47
- data/test/unit/test_attributes.rb +24 -33
- data/test/unit/test_autoarray.rb +23 -32
- data/test/unit/test_command.rb +26 -0
- data/test/unit/test_dictionary.rb +123 -117
- data/test/unit/test_infinity.rb +41 -47
- data/test/unit/test_inheritor.rb +133 -142
- data/test/unit/test_interval.rb +129 -93
- data/test/unit/test_ostruct.rb +148 -101
- data/test/unit/test_overload.rb +8 -15
- data/test/unit/test_paramix.rb +67 -73
- data/test/unit/test_pp_s.rb +23 -0
- data/test/unit/test_prototype.rb +28 -38
- metadata +47 -11
- data/lib/core/facets/enumerable/instance_map.rb +0 -0
- data/lib/more/facets/command_options.rb +0 -328
- data/meta/version.txt +0 -1
- data/task/load +0 -39
- data/test/unit/test_command_options.rb +0 -29
data/test/unit/test_ostruct.rb
CHANGED
@@ -1,130 +1,177 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
#
|
9
|
-
# Extracted Mon Sep 03 16:23:07 -0700 2007
|
10
|
-
# w/ Test Extraction Ratchet
|
11
|
-
#
|
1
|
+
# _____ _
|
2
|
+
# |_ _|__ ___| |_
|
3
|
+
# | |/ _ \/ __| __|
|
4
|
+
# | | __/\__ \ |
|
5
|
+
# |_|\___||___/\__|
|
6
|
+
#
|
7
|
+
# for lib/facets/ostruct.rb
|
12
8
|
|
13
|
-
|
9
|
+
require 'facets/ostruct.rb'
|
10
|
+
require 'test/unit'
|
14
11
|
|
12
|
+
class TestOpenStruct < Test::Unit::TestCase
|
15
13
|
|
14
|
+
def setup
|
15
|
+
@o = OpenStruct.new(:q => 1)
|
16
|
+
end
|
16
17
|
|
17
|
-
|
18
|
+
def test_update
|
19
|
+
o = OpenStruct.new( { :a => 1 } )
|
20
|
+
h = { :b => 2 }
|
21
|
+
assert_nothing_raised { o.__update__( h ) }
|
22
|
+
assert_equal( 2, o.b )
|
23
|
+
end
|
18
24
|
|
19
|
-
|
25
|
+
def test_merge_1
|
26
|
+
o = OpenStruct.new( { :a => 1 } )
|
27
|
+
h = { :b => 2 }
|
28
|
+
q = o.__merge__( h )
|
29
|
+
assert_equal( 1, q.a )
|
30
|
+
assert_equal( 2, q.b )
|
31
|
+
end
|
20
32
|
|
21
|
-
|
22
|
-
|
23
|
-
|
33
|
+
def test_merge_2
|
34
|
+
o1 = OpenStruct.new( { :a => 1 } )
|
35
|
+
o2 = OpenStruct.new( { :b => 2 } )
|
36
|
+
q = o1.__merge__( o2 )
|
37
|
+
assert_equal( 1, q.a )
|
38
|
+
assert_equal( 2, q.b )
|
39
|
+
end
|
24
40
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
assert_equal( 2, o.b )
|
30
|
-
end
|
41
|
+
def test_store
|
42
|
+
@o.instance_delegate.store(:a,1)
|
43
|
+
assert_equal( 1, @o.a )
|
44
|
+
end
|
31
45
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
assert_equal( 1, q.a )
|
37
|
-
assert_equal( 2, q.b )
|
38
|
-
end
|
46
|
+
def test_update
|
47
|
+
@o.instance_delegate.update(:a=>1)
|
48
|
+
assert_equal( 1, @o.a )
|
49
|
+
end
|
39
50
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
assert_equal( 1, q.a )
|
45
|
-
assert_equal( 2, q.b )
|
46
|
-
end
|
51
|
+
def test_op_fetch
|
52
|
+
o = OpenStruct.new( { :a => 1 } )
|
53
|
+
assert_equal( 1, o[:a] )
|
54
|
+
end
|
47
55
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
56
|
+
def test_op_store
|
57
|
+
o = OpenStruct.new( { :a => 1 } )
|
58
|
+
assert_nothing_raised { o[:b] = 2 }
|
59
|
+
assert_equal( 2, o.b )
|
60
|
+
end
|
52
61
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
62
|
+
def test_update
|
63
|
+
o = OpenStruct.new( { :a => 1 } )
|
64
|
+
h = { :b => 2 }
|
65
|
+
assert_nothing_raised { o.__update__( h ) }
|
66
|
+
assert_equal( 2, o.b )
|
67
|
+
end
|
57
68
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
69
|
+
def test_merge_1
|
70
|
+
o = OpenStruct.new( { :a => 1 } )
|
71
|
+
h = { :b => 2 }
|
72
|
+
q = o.__merge__( h )
|
73
|
+
assert_equal( 1, q.a )
|
74
|
+
assert_equal( 2, q.b )
|
75
|
+
end
|
62
76
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
77
|
+
def test_merge_2
|
78
|
+
o1 = OpenStruct.new( { :a => 1 } )
|
79
|
+
o2 = OpenStruct.new( { :b => 2 } )
|
80
|
+
q = o1.__merge__( o2 )
|
81
|
+
assert_equal( 1, q.a )
|
82
|
+
assert_equal( 2, q.b )
|
83
|
+
end
|
68
84
|
|
69
|
-
|
70
|
-
o = OpenStruct.new( { :a => 1 } )
|
71
|
-
h = { :b => 2 }
|
72
|
-
assert_nothing_raised { o.__update__( h ) }
|
73
|
-
assert_equal( 2, o.b )
|
74
|
-
end
|
85
|
+
end
|
75
86
|
|
76
|
-
|
77
|
-
o = OpenStruct.new( { :a => 1 } )
|
78
|
-
h = { :b => 2 }
|
79
|
-
q = o.__merge__( h )
|
80
|
-
assert_equal( 1, q.a )
|
81
|
-
assert_equal( 2, q.b )
|
82
|
-
end
|
87
|
+
class TestOpenStructInitialize < Test::Unit::TestCase
|
83
88
|
|
84
|
-
|
85
|
-
o1 = OpenStruct.new( { :a => 1 } )
|
86
|
-
o2 = OpenStruct.new( { :b => 2 } )
|
87
|
-
q = o1.__merge__( o2 )
|
88
|
-
assert_equal( 1, q.a )
|
89
|
-
assert_equal( 2, q.b )
|
90
|
-
end
|
89
|
+
class Person < OpenStruct; end
|
91
90
|
|
91
|
+
def test_1_old_functionality
|
92
|
+
o = OpenStruct.new
|
93
|
+
assert_nil(o.foo)
|
94
|
+
o.foo = :bar
|
95
|
+
assert_equal(:bar, o.foo)
|
96
|
+
o.delete_field(:foo)
|
97
|
+
assert_nil(o.foo)
|
98
|
+
o1 = OpenStruct.new(:x => 1, :y => 2)
|
99
|
+
assert_equal(1, o1.x)
|
100
|
+
assert_equal(2, o1.y)
|
101
|
+
o2 = OpenStruct.new(:x => 1, :y => 2)
|
102
|
+
assert(o1 == o2)
|
92
103
|
end
|
93
104
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
ao = a.to_ostruct
|
100
|
-
assert_equal( a[:a], ao.a )
|
101
|
-
assert_equal( a[:b], ao.b )
|
102
|
-
assert_equal( a[:c], ao.c )
|
105
|
+
def test_2_new_functionality
|
106
|
+
person = OpenStruct.new do |p|
|
107
|
+
p.name = 'John Smith'
|
108
|
+
p.gender = :M
|
109
|
+
p.age = 71
|
103
110
|
end
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
assert_equal( a[:c][:x], ao.c.x )
|
111
|
+
assert_equal('John Smith', person.name)
|
112
|
+
assert_equal(:M, person.gender)
|
113
|
+
assert_equal(71, person.age)
|
114
|
+
assert_equal(nil, person.address)
|
115
|
+
person = OpenStruct.new(:gender => :M, :age => 71) do |p|
|
116
|
+
p.name = 'John Smith'
|
111
117
|
end
|
118
|
+
assert_equal('John Smith', person.name)
|
119
|
+
assert_equal(:M, person.gender)
|
120
|
+
assert_equal(71, person.age)
|
121
|
+
assert_equal(nil, person.address)
|
122
|
+
end
|
112
123
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
124
|
+
def test_3_subclass
|
125
|
+
person = Person.new do |p|
|
126
|
+
p.name = 'John Smith'
|
127
|
+
p.gender = :M
|
128
|
+
p.age = 71
|
118
129
|
end
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
130
|
+
assert_equal('John Smith', person.name)
|
131
|
+
assert_equal(:M, person.gender)
|
132
|
+
assert_equal(71, person.age)
|
133
|
+
assert_equal(nil, person.address)
|
134
|
+
person = Person.new(:gender => :M, :age => 71) do |p|
|
135
|
+
p.name = 'John Smith'
|
125
136
|
end
|
137
|
+
assert_equal('John Smith', person.name)
|
138
|
+
assert_equal(:M, person.gender)
|
139
|
+
assert_equal(71, person.age)
|
140
|
+
assert_equal(nil, person.address)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
class TestHashToOpenStruct < Test::Unit::TestCase
|
145
|
+
|
146
|
+
def test_to_ostruct
|
147
|
+
a = { :a => 1, :b => 2, :c => 3 }
|
148
|
+
ao = a.to_ostruct
|
149
|
+
assert_equal( a[:a], ao.a )
|
150
|
+
assert_equal( a[:b], ao.b )
|
151
|
+
assert_equal( a[:c], ao.c )
|
152
|
+
end
|
153
|
+
|
154
|
+
def test_to_ostruct_recurse
|
155
|
+
a = { :a => 1, :b => 2, :c => { :x => 4 } }
|
156
|
+
ao = a.to_ostruct_recurse
|
157
|
+
assert_equal( a[:a], ao.a )
|
158
|
+
assert_equal( a[:b], ao.b )
|
159
|
+
assert_equal( a[:c][:x], ao.c.x )
|
160
|
+
end
|
126
161
|
|
162
|
+
def test_to_ostruct_recurse_with_recursion
|
163
|
+
a = {}
|
164
|
+
a[:a] = a
|
165
|
+
ao = a.to_ostruct_recurse
|
166
|
+
assert_equal( ao, ao.a )
|
127
167
|
end
|
128
168
|
|
169
|
+
def test_to_ostruct_advanced
|
170
|
+
h = { 'a' => { 'b' => 1 } }
|
171
|
+
o = h.to_ostruct_recurse( { h['a'] => h['a'] } )
|
172
|
+
assert_equal( 1, o.a['b'] )
|
173
|
+
assert( Hash === o.a )
|
174
|
+
end
|
129
175
|
|
176
|
+
end
|
130
177
|
|
data/test/unit/test_overload.rb
CHANGED
@@ -1,18 +1,11 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
# Extracted Mon Sep 03 16:23:07 -0700 2007
|
10
|
-
# w/ Test Extraction Ratchet
|
11
|
-
#
|
12
|
-
|
13
|
-
require 'facets/overload.rb'
|
14
|
-
|
15
|
-
|
1
|
+
# _____ _
|
2
|
+
# |_ _|__ ___| |_
|
3
|
+
# | |/ _ \/ __| __|
|
4
|
+
# | | __/\__ \ |
|
5
|
+
# |_|\___||___/\__|
|
6
|
+
#
|
7
|
+
|
8
|
+
require 'facets/overload.rb'
|
16
9
|
|
17
10
|
require 'test/unit'
|
18
11
|
|
data/test/unit/test_paramix.rb
CHANGED
@@ -1,98 +1,92 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
#
|
9
|
-
# Extracted Mon Sep 03 16:23:07 -0700 2007
|
10
|
-
# w/ Test Extraction Ratchet
|
11
|
-
#
|
1
|
+
# _____ _
|
2
|
+
# |_ _|__ ___| |_
|
3
|
+
# | |/ _ \/ __| __|
|
4
|
+
# | | __/\__ \ |
|
5
|
+
# |_|\___||___/\__|
|
6
|
+
#
|
7
|
+
# for facets/paramix.rb
|
12
8
|
|
13
|
-
|
9
|
+
require 'facets/paramix.rb'
|
14
10
|
|
11
|
+
require 'test/unit'
|
15
12
|
|
13
|
+
class TC_Paramix_01 < Test::Unit::TestCase
|
16
14
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
def self.included_with_parameters( base, parms )
|
26
|
-
base.class_eval do
|
27
|
-
define_method :check do
|
28
|
-
parms
|
29
|
-
end
|
15
|
+
module M
|
16
|
+
def f
|
17
|
+
M(:p)
|
18
|
+
end
|
19
|
+
def self.included_with_parameters( base, parms )
|
20
|
+
base.class_eval do
|
21
|
+
define_method :check do
|
22
|
+
parms
|
30
23
|
end
|
31
24
|
end
|
32
25
|
end
|
26
|
+
end
|
33
27
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
class D
|
39
|
-
include M, :p => "steak"
|
40
|
-
end
|
28
|
+
class C
|
29
|
+
include M, :p => "check"
|
30
|
+
end
|
41
31
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
assert_equal( "check", c.f )
|
46
|
-
end
|
32
|
+
class D
|
33
|
+
include M, :p => "steak"
|
34
|
+
end
|
47
35
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
36
|
+
def test_01_001
|
37
|
+
c = C.new
|
38
|
+
assert_equal( "check", c.M(:p) )
|
39
|
+
assert_equal( "check", c.f )
|
40
|
+
end
|
53
41
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
42
|
+
def test_01_002
|
43
|
+
d = D.new
|
44
|
+
assert_equal( "steak", d.M(:p) )
|
45
|
+
assert_equal( "steak", d.f )
|
46
|
+
end
|
58
47
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
assert_equal( {:p => "steak"}, d.check )
|
64
|
-
end
|
48
|
+
def test_01_003
|
49
|
+
assert_equal( {M=>{:p => "check"}}, C.mixin_parameters )
|
50
|
+
assert_equal( {M=>{:p => "steak"}}, D.mixin_parameters )
|
51
|
+
end
|
65
52
|
|
53
|
+
def test_01_004
|
54
|
+
c = C.new
|
55
|
+
assert_equal( {:p => "check"}, c.check )
|
56
|
+
d = D.new
|
57
|
+
assert_equal( {:p => "steak"}, d.check )
|
66
58
|
end
|
67
59
|
|
60
|
+
end
|
68
61
|
|
69
|
-
class TC02 < Test::Unit::TestCase
|
70
62
|
|
71
|
-
|
72
|
-
def f
|
73
|
-
M(:p)
|
74
|
-
end
|
75
|
-
end
|
63
|
+
class TC_Paramix_02 < Test::Unit::TestCase
|
76
64
|
|
77
|
-
|
78
|
-
|
65
|
+
module M
|
66
|
+
def f
|
67
|
+
M(:p)
|
79
68
|
end
|
69
|
+
end
|
80
70
|
|
81
|
-
|
82
|
-
|
83
|
-
|
71
|
+
class C
|
72
|
+
extend M, :p => "mosh"
|
73
|
+
end
|
84
74
|
|
85
|
-
|
86
|
-
|
87
|
-
|
75
|
+
class D
|
76
|
+
extend M, :p => "many"
|
77
|
+
end
|
88
78
|
|
89
|
-
|
90
|
-
|
91
|
-
|
79
|
+
def test_02_001
|
80
|
+
assert_equal( "mosh", C.f )
|
81
|
+
end
|
92
82
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
end
|
83
|
+
def test_02_002
|
84
|
+
assert_equal( "many", D.f )
|
85
|
+
end
|
97
86
|
|
87
|
+
def test_02_003
|
88
|
+
assert_equal( {M=>{:p => "mosh"}}, (class << C; self; end).mixin_parameters )
|
89
|
+
assert_equal( {M=>{:p => "many"}}, (class << D; self; end).mixin_parameters )
|
98
90
|
end
|
91
|
+
|
92
|
+
end
|