facets 2.0.2 → 2.0.3

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