core_ex 0.4.0 → 0.5.1.1
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.
- data/ChangeLog +251 -0
- data/NEWS +29 -0
- data/README +1 -1
- data/SPEC.yml +10 -10
- data/lib/core_ex/dependencies_ext/constant_load_path.rb +1 -1
- data/lib/core_ex/embedded_tests.rb +1 -1
- data/lib/core_ex/enumerable.rb +87 -5
- data/lib/core_ex/exception.rb +1 -1
- data/lib/core_ex/file_utils.rb +1 -1
- data/lib/core_ex/lazy_loading.rb +159 -0
- data/lib/core_ex/module/attr_once.rb +1 -1
- data/lib/core_ex/module/import.rb +4 -6
- data/lib/core_ex/module/in_place.rb +1 -1
- data/lib/core_ex/module/mix_in_with_args.rb +1 -1
- data/lib/core_ex/numeric.rb +46 -0
- data/lib/core_ex/object/instance_eval_with_args.rb +1 -1
- data/lib/core_ex/object/singleton_class.rb +1 -1
- data/lib/core_ex/object/the_first_time.rb +1 -1
- data/lib/core_ex/pathname.rb +17 -11
- data/lib/core_ex/proc.rb +80 -1
- data/lib/core_ex/rakefile_base.rf +192 -296
- data/lib/core_ex/require.rb +1 -1
- data/lib/core_ex/string.rb +11 -2
- data/lib/core_ex/time.rb +1 -1
- data/lib/core_ex/try_dup.rb +1 -1
- data/lib/core_ex/yaml.rb +101 -79
- data/lib/core_ex.rb +129 -128
- data/lib/d_time.rb +225 -53
- data/lib/dumpable_proc.rb +1 -10
- data/lib/path_list.rb +18 -7
- data/lib/temp_path.rb +3 -3
- data/lib/test/unit/u_i/yaml/test_runner.rb +1 -1
- data/lib/version.rb +309 -69
- data/lib/yaml_extension.rb +1 -1
- data/test/fixtures/lazy_loading/a_b/a/c.rb +6 -0
- data/test/fixtures/lazy_loading/a_b/a.rb +2 -0
- data/test/fixtures/lazy_loading/a_b/b/c.rb +4 -0
- data/test/fixtures/lazy_loading/a_b/b.rb +2 -0
- data/test/fixtures/lazy_loading/double/a/bouhou.rb +2 -0
- data/test/fixtures/lazy_loading/double/a/foo_bar.rb +5 -0
- data/test/fixtures/lazy_loading/double/a/sub/a/suba.rb +7 -0
- data/test/fixtures/lazy_loading/double/b/root/sub/b.rb +6 -0
- data/test/fixtures/lazy_loading/double/b/root/sub.rb +4 -0
- data/test/fixtures/lazy_loading/double/b/root.rb +2 -0
- data/test/fixtures/lazy_loading/foo_bars/foo_bar.rb +4 -0
- data/test/fixtures/lazy_loading/foo_bars/mods/mod.rb +6 -0
- data/test/fixtures/lazy_loading/foo_bars/mods/sub_mod.rb +6 -0
- data/test/fixtures/lazy_loading/foo_bars/mods/sub_sub_mod.rb +7 -0
- data/test/fixtures/lazy_loading/foo_bars/mods.rb +4 -0
- data/test/fixtures/lazy_loading/foo_bars/sub_foo_bar.rb +5 -0
- data/test/fixtures/lazy_loading/foo_bars/titis/tutu.rb +6 -0
- data/test/fixtures/lazy_loading/foo_bars/totos.rb +6 -0
- data/test/fixtures/lazy_loading/foo_bars.rb +4 -0
- data/test/lazy_loading/test_already_present_name_absolute.rb +6 -0
- data/test/lazy_loading/test_already_present_name_relative.rb +11 -0
- data/test/lazy_loading/test_inside_another_module.rb +5 -0
- data/test/lazy_loading/test_lazy_loading.rb +179 -0
- data/test/sanity/multiple-requires.yml +22 -4
- data/test/unit-suite.yml +5 -4
- metadata +119 -80
- data/SPEC.dyn.yml +0 -10
- data/SPEC.gemspec +0 -13
- data/test/test-unit-setup.rb +0 -19
- /data/test/{resources → fixtures}/require/test_require +0 -0
- /data/test/{resources → fixtures}/require/test_require_rb.rb +0 -0
- /data/test/{resources → fixtures}/require/test_require_so.so +0 -0
- /data/test/{resources → fixtures}/use-from-gems.rb +0 -0
- /data/test/{resources → fixtures}/yaml_testrunner/unit_test.rb +0 -0
data/lib/d_time.rb
CHANGED
@@ -1,78 +1,196 @@
|
|
1
1
|
# Copyright:: Copyright (c) 2004 Nicolas Despres. All rights reserved.
|
2
2
|
# Author:: Nicolas Despres <polrop@lrde.epita.fr>.
|
3
3
|
# License:: Gnu General Public License.
|
4
|
-
# Revision:: $Id: d_time.rb
|
4
|
+
# Revision:: $Id: /w/fey/ruby_ex/trunk/core_ex/lib/d_time.rb 21961 2006-02-19T19:47:14.158917Z pouillar $
|
5
5
|
|
6
|
+
class Numeric
|
6
7
|
|
8
|
+
def to_dtime
|
9
|
+
DTime.new self
|
10
|
+
end
|
11
|
+
|
12
|
+
alias_method :second, :to_dtime
|
7
13
|
|
14
|
+
end # class Numeric
|
8
15
|
|
9
16
|
class DTime
|
10
|
-
|
17
|
+
include Comparable
|
18
|
+
|
19
|
+
have YamlExtension, :dtime, :d_time
|
11
20
|
|
12
21
|
def initialize(delta)
|
13
|
-
@delta = delta.to_f
|
14
|
-
@min, @sec = @delta.divmod(60)
|
15
|
-
@hour, @min = @min.floor.divmod(60)
|
16
|
-
@day, @hour = @hour.divmod(24)
|
22
|
+
@delta = delta.to_f
|
17
23
|
end
|
18
24
|
|
19
|
-
attr_reader :delta
|
25
|
+
attr_reader :delta
|
20
26
|
|
21
|
-
def
|
22
|
-
|
27
|
+
def coerce ( lhs )
|
28
|
+
[lhs.to_dtime, self]
|
23
29
|
end
|
24
30
|
|
25
|
-
def
|
26
|
-
|
27
|
-
res << "#@day days" unless @day.zero?
|
28
|
-
res << "#@hour hours" unless @hour.zero?
|
29
|
-
res << "#@min mins" unless @min.zero?
|
30
|
-
res << "#@sec secs" if res.empty? or not @sec.zero?
|
31
|
-
res.join ' '
|
31
|
+
def <=> ( rhs )
|
32
|
+
@delta <=> rhs.to_f
|
32
33
|
end
|
33
34
|
|
34
|
-
|
35
|
-
|
35
|
+
%w[ / * - + % ].each do |op|
|
36
|
+
class_eval "
|
37
|
+
def #{op} ( rhs )
|
38
|
+
DTime.new(@delta #{op} rhs.to_f)
|
39
|
+
end
|
40
|
+
"
|
36
41
|
end
|
37
42
|
|
38
|
-
def
|
39
|
-
|
43
|
+
def -@
|
44
|
+
DTime.new(-@delta)
|
45
|
+
end
|
46
|
+
|
47
|
+
def +@
|
48
|
+
self
|
40
49
|
end
|
41
50
|
|
51
|
+
alias_method :to_f, :delta
|
52
|
+
|
42
53
|
def to_i
|
43
54
|
@delta.to_i
|
44
55
|
end
|
45
56
|
|
46
|
-
|
57
|
+
def floor
|
58
|
+
@delta.floor
|
59
|
+
end
|
60
|
+
|
61
|
+
def round
|
62
|
+
@delta.round
|
63
|
+
end
|
47
64
|
|
48
65
|
def hash
|
49
66
|
@delta.hash
|
50
67
|
end
|
51
68
|
|
52
|
-
|
53
|
-
|
69
|
+
class TimeUnit
|
70
|
+
def initialize ( unit_name, value_in_seconds )
|
71
|
+
@name = unit_name
|
72
|
+
@plural = unit_name.to_s.pluralize.to_sym
|
73
|
+
@value_in_seconds = value_in_seconds
|
74
|
+
end
|
75
|
+
attr_reader :name, :plural, :value_in_seconds
|
76
|
+
end # class TimeUnit
|
77
|
+
|
78
|
+
def self.time_unit ( unit_name, value_in_seconds )
|
79
|
+
value_in_seconds = value_in_seconds.to_f
|
80
|
+
unit = TimeUnit.new unit_name, value_in_seconds
|
81
|
+
@@time_units << unit
|
82
|
+
current_size = @@time_units.size
|
83
|
+
to_unit_name = "to_#{unit_name}"
|
84
|
+
to_unit_plural = "to_#{unit.plural}"
|
85
|
+
|
86
|
+
# Conversion method
|
87
|
+
unless method_defined? to_unit_name
|
88
|
+
define_method(to_unit_name) { delta / value_in_seconds }
|
89
|
+
end
|
90
|
+
unless method_defined? to_unit_plural
|
91
|
+
alias_method to_unit_plural, to_unit_name
|
92
|
+
end
|
93
|
+
|
94
|
+
# Component extraction method
|
95
|
+
unless method_defined? unit_name
|
96
|
+
define_method(unit_name) do
|
97
|
+
next_unit = @@time_units[current_size]
|
98
|
+
modulo = (next_unit.nil?)? 1 : next_unit.value_in_seconds
|
99
|
+
((delta.abs % modulo) / value_in_seconds).to_i
|
100
|
+
end
|
101
|
+
end
|
102
|
+
unless method_defined? unit.plural
|
103
|
+
alias_method unit.plural, unit_name
|
104
|
+
end
|
105
|
+
|
106
|
+
# Numeric extension
|
107
|
+
unless Numeric.method_defined? unit_name
|
108
|
+
Numeric.send(:define_method, unit_name) { DTime.new(self * value_in_seconds) }
|
109
|
+
end
|
110
|
+
unless Numeric.method_defined? unit.plural
|
111
|
+
Numeric.send(:alias_method, unit.plural, unit_name)
|
112
|
+
end
|
54
113
|
end
|
55
114
|
|
56
|
-
def
|
57
|
-
|
115
|
+
def second
|
116
|
+
delta.abs % 60
|
117
|
+
end
|
118
|
+
alias_method :sec, :second
|
119
|
+
alias_method :to_second, :delta
|
120
|
+
alias_method :to_sec, :delta
|
121
|
+
|
122
|
+
# Time units
|
123
|
+
|
124
|
+
@@time_units = []
|
125
|
+
|
126
|
+
time_unit :second, 1
|
127
|
+
time_unit :minute, 60.seconds
|
128
|
+
time_unit :hour, 60.minutes
|
129
|
+
time_unit :day, 24.hours
|
130
|
+
time_unit :week, 7.days
|
131
|
+
# time_unit :month, 30.days
|
132
|
+
time_unit :year, 365.25.days
|
133
|
+
# time_unit :..., 10.years
|
134
|
+
time_unit :century, 100.years
|
135
|
+
|
136
|
+
alias_method :min, :minutes
|
137
|
+
alias_method :to_min, :to_minutes
|
138
|
+
|
139
|
+
# Warning: Values are spawned from the largest unit to the finest
|
140
|
+
# (e.g. days, hours, minutes...).
|
141
|
+
# Warning: This method does not give you the sign of the DTime.
|
142
|
+
def each ( &block )
|
143
|
+
accu = @delta.abs
|
144
|
+
@@time_units.reverse_each do |unit|
|
145
|
+
if unit.name == :second
|
146
|
+
block[accu, unit]
|
147
|
+
else
|
148
|
+
x, accu = accu.divmod(unit.value_in_seconds)
|
149
|
+
next if x.zero? and accu == @delta.abs
|
150
|
+
block[x.to_i, unit]
|
151
|
+
end
|
152
|
+
end
|
58
153
|
end
|
59
154
|
|
60
|
-
|
61
|
-
|
155
|
+
# Warning: This method does not give you the sign of the DTime.
|
156
|
+
def to_a
|
157
|
+
result = []
|
158
|
+
each { |x, unit| result << x }
|
159
|
+
result
|
62
160
|
end
|
63
161
|
|
64
|
-
def
|
65
|
-
|
66
|
-
|
67
|
-
|
162
|
+
def to_s
|
163
|
+
result = []
|
164
|
+
each do |x, unit|
|
165
|
+
case x
|
166
|
+
when 0
|
167
|
+
when 1 then result << "1 #{unit.name}"
|
168
|
+
else result << "#{x} #{unit.plural}"
|
169
|
+
end
|
170
|
+
end
|
171
|
+
result << '0' if result.empty?
|
172
|
+
(((@delta < 0)? '-' : '') + result.join(' ')).freeze
|
173
|
+
end
|
174
|
+
|
175
|
+
def inspect
|
176
|
+
to_s + ':DTime'
|
177
|
+
end
|
178
|
+
|
179
|
+
def to_yaml_string
|
180
|
+
to_s
|
68
181
|
end
|
69
182
|
|
70
|
-
|
71
|
-
|
183
|
+
# Warning: This method does not give you the sign of the DTime.
|
184
|
+
def to_hash
|
185
|
+
result = {}
|
186
|
+
each { |x, unit| result[unit.name] = x }
|
187
|
+
result.freeze
|
72
188
|
end
|
73
189
|
|
74
|
-
def
|
75
|
-
|
190
|
+
def self.diff ( *args, &block )
|
191
|
+
start = Time.now
|
192
|
+
block[*args]
|
193
|
+
return Time.now - start
|
76
194
|
end
|
77
195
|
|
78
196
|
attr_once :to_s, :inspect, :to_a, :to_i, :hash, :to_hash, :floor,
|
@@ -89,10 +207,19 @@ class DTimeTest < Test::Unit::TestCase
|
|
89
207
|
def test_simple
|
90
208
|
d = DTime.new(260.33)
|
91
209
|
assert_equal(260, d.delta.floor)
|
210
|
+
assert_equal(20, d.seconds.floor)
|
211
|
+
assert_equal(20, d.second.floor)
|
92
212
|
assert_equal(20, d.sec.floor)
|
213
|
+
assert_equal(4, d.minutes)
|
214
|
+
assert_equal(4, d.minute)
|
93
215
|
assert_equal(4, d.min)
|
216
|
+
assert_equal(0, d.hours)
|
94
217
|
assert_equal(0, d.hour)
|
218
|
+
assert_equal(0, d.days)
|
95
219
|
assert_equal(0, d.day)
|
220
|
+
assert_equal(0, d.week)
|
221
|
+
assert_equal(0, d.year)
|
222
|
+
assert_equal(0, d.century)
|
96
223
|
end
|
97
224
|
|
98
225
|
def test_complex
|
@@ -102,19 +229,19 @@ class DTimeTest < Test::Unit::TestCase
|
|
102
229
|
assert_equal(47, d.min)
|
103
230
|
assert_equal(1, d.hour)
|
104
231
|
assert_equal(3, d.day)
|
105
|
-
assert_equal([ 3, 1, 47 ], d.to_a
|
106
|
-
assert_equal(58, d.to_a[3].floor)
|
232
|
+
assert_equal([ 3, 1, 47, 58 ], d.to_a.map { |x| x.to_i })
|
107
233
|
h = d.to_hash
|
108
|
-
assert_equal(3, h[:
|
109
|
-
assert_equal(1, h[:
|
110
|
-
assert_equal(47, h[:
|
111
|
-
assert_equal(58, h[:
|
234
|
+
assert_equal(3, h[:day])
|
235
|
+
assert_equal(1, h[:hour])
|
236
|
+
assert_equal(47, h[:minute])
|
237
|
+
assert_equal(58, h[:second].floor)
|
112
238
|
end
|
113
239
|
|
114
240
|
def test_conversion
|
115
241
|
d = DTime.new(260.75)
|
116
|
-
assert_equal('260.75', d.to_s)
|
117
|
-
assert_equal('4
|
242
|
+
assert_equal('260.75', d.to_f.to_s)
|
243
|
+
assert_equal('4 minutes 20.75 seconds', d.to_s)
|
244
|
+
assert_equal('4 minutes 20.75 seconds:DTime', d.inspect)
|
118
245
|
assert_equal(260, d.to_f.floor)
|
119
246
|
assert_equal(260, d.to_i)
|
120
247
|
assert_equal(260, d.floor)
|
@@ -123,7 +250,7 @@ class DTimeTest < Test::Unit::TestCase
|
|
123
250
|
|
124
251
|
def test_negative
|
125
252
|
d = DTime.new(-265678.42000)
|
126
|
-
assert_equal(
|
253
|
+
assert_equal(-265679, d.delta.floor)
|
127
254
|
assert_equal(58, d.sec.floor)
|
128
255
|
assert_equal(47, d.min)
|
129
256
|
assert_equal(1, d.hour)
|
@@ -137,13 +264,13 @@ class DTimeTest < Test::Unit::TestCase
|
|
137
264
|
|
138
265
|
def test_to_yaml
|
139
266
|
d = DTime.new(265678.42000)
|
140
|
-
assert_yaml_dump(d, '
|
267
|
+
assert_yaml_dump(d, '!dtime 3 days 1 hour 47 minutes 58.4199999999837 seconds')
|
141
268
|
d = DTime.new(5678.42000)
|
142
|
-
assert_yaml_dump(d, '
|
269
|
+
assert_yaml_dump(d, '!dtime 1 hour 34 minutes 38.4200000000001 seconds')
|
143
270
|
d = DTime.new(158.42000)
|
144
|
-
assert_yaml_dump(d, '
|
271
|
+
assert_yaml_dump(d, '!dtime 2 minutes 38.42 seconds')
|
145
272
|
d = DTime.new(58.42000)
|
146
|
-
assert_yaml_dump(d, '
|
273
|
+
assert_yaml_dump(d, '!dtime 58.42 seconds')
|
147
274
|
end
|
148
275
|
|
149
276
|
def test_diff
|
@@ -151,7 +278,7 @@ class DTimeTest < Test::Unit::TestCase
|
|
151
278
|
d = DTime.diff(42, 43) do |*args|
|
152
279
|
assert_equal([42, 43], args)
|
153
280
|
@foo = 2
|
154
|
-
sleep 0.
|
281
|
+
sleep 0.3
|
155
282
|
@foo = 3
|
156
283
|
end
|
157
284
|
assert_kind_of(DTime, d)
|
@@ -170,10 +297,55 @@ class DTimeTest < Test::Unit::TestCase
|
|
170
297
|
assert_equal(0, d.day)
|
171
298
|
end
|
172
299
|
|
173
|
-
def
|
174
|
-
|
175
|
-
|
176
|
-
|
300
|
+
def test_stricly_greater
|
301
|
+
assert(DTime.new(4.5) > 2)
|
302
|
+
end
|
303
|
+
|
304
|
+
def test_stricly_lesser
|
305
|
+
assert(DTime.new(4.5) < 4.6)
|
306
|
+
end
|
307
|
+
|
308
|
+
def test_greater_or_equal
|
309
|
+
assert(DTime.new(4.5) >= 4.5)
|
310
|
+
end
|
311
|
+
|
312
|
+
def test_lesser_or_equal
|
313
|
+
assert(DTime.new(4.5) <= 4.5)
|
314
|
+
end
|
315
|
+
|
316
|
+
def test_equal
|
317
|
+
assert(DTime.new(4.5) == 4.5)
|
318
|
+
end
|
319
|
+
|
320
|
+
def test_divide
|
321
|
+
d = DTime.new(4.5)
|
322
|
+
assert_equal(2.25, d / 2)
|
323
|
+
end
|
324
|
+
|
325
|
+
def test_multiple
|
326
|
+
d = DTime.new(4.5)
|
327
|
+
assert_equal(9, d * 2)
|
328
|
+
end
|
329
|
+
|
330
|
+
def test_add
|
331
|
+
d = DTime.new(4.5)
|
332
|
+
assert_equal(6.5, d + 2)
|
333
|
+
end
|
334
|
+
|
335
|
+
def test_sub
|
336
|
+
d = DTime.new(4.5)
|
337
|
+
assert_kind_of(DTime, d - 2)
|
338
|
+
assert_equal(2.5, d - 2)
|
339
|
+
end
|
340
|
+
|
341
|
+
def test_uadd
|
342
|
+
d = DTime.new(4.5)
|
343
|
+
assert_equal(4.5, +d)
|
344
|
+
end
|
345
|
+
|
346
|
+
def test_usub
|
347
|
+
d = DTime.new(2.5)
|
348
|
+
assert_equal(-2.5, -d)
|
177
349
|
end
|
178
350
|
|
179
351
|
end # class DTimeTest
|
data/lib/dumpable_proc.rb
CHANGED
@@ -1,21 +1,12 @@
|
|
1
1
|
# Copyright:: Copyright (c) 2005 Nicolas Pouillard. All rights reserved.
|
2
2
|
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
3
3
|
# License:: Gnu General Public License.
|
4
|
-
# Revision:: $Id: dumpable_proc.rb
|
4
|
+
# Revision:: $Id: /w/fey/ruby_ex/trunk/core_ex/lib/dumpable_proc.rb 8014 2005-10-26T12:35:42.562387Z ertai $
|
5
5
|
|
6
6
|
|
7
7
|
class DumpableProc < Proc
|
8
8
|
|
9
9
|
def self.new ( str )
|
10
|
-
# FIXME imporve prevent from ruby injections
|
11
|
-
if str =~ /[{}]/
|
12
|
-
str = str.gsub(/[^{}]/, '')
|
13
|
-
while str.gsub!(/\{\}/, '')
|
14
|
-
end
|
15
|
-
unless str.empty?
|
16
|
-
raise ArgumentError, "Bad block: bad `{' `}' equilibration"
|
17
|
-
end
|
18
|
-
end
|
19
10
|
pr = super(&eval("proc { #{str} }"))
|
20
11
|
pr.instance_eval { @str = str.freeze }
|
21
12
|
pr
|
data/lib/path_list.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Copyright:: Copyright (c) 2005 Nicolas Pouillard. All rights reserved.
|
2
2
|
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
3
3
|
# License:: Gnu General Public License.
|
4
|
-
# Revision:: $Id: path_list.rb
|
4
|
+
# Revision:: $Id: /w/fey/ruby_ex/trunk/core_ex/lib/path_list.rb 21866 2006-02-18T17:15:58.449667Z pouillar $
|
5
5
|
#--
|
6
6
|
# Copyright (c) 2003, 2004 Jim Weirich
|
7
7
|
#
|
@@ -380,8 +380,10 @@ class PathList
|
|
380
380
|
# <<<<
|
381
381
|
pattern = pattern.to_s
|
382
382
|
re = Regexp.quote(pattern)
|
383
|
-
re
|
384
|
-
|
383
|
+
while re =~ /\\\{/
|
384
|
+
re.gsub!(/\\\{([^{}]+)\\\}/) do
|
385
|
+
'(?:' + $1.gsub(/,/, '|') + ')'
|
386
|
+
end
|
385
387
|
end
|
386
388
|
re.gsub!(/\\\*\\\*\//, '(?:.+/)?')
|
387
389
|
re.gsub!(/\\\*/, '[^/]*')
|
@@ -495,31 +497,40 @@ test_section __FILE__ do
|
|
495
497
|
@l = PathList[]
|
496
498
|
@args = []
|
497
499
|
@mo = lambda { |*a| @args << a }
|
498
|
-
%w[ foo barbar bazfoo foo/a foo/b ].each do |x|
|
500
|
+
%w[ foo barbar bazfoo foo/a foo/b bu bi ].each do |x|
|
499
501
|
(@r/x).mkpath
|
500
502
|
@l << @r/x
|
501
503
|
end
|
502
504
|
@l2 = PathList[@r/'(f?o)', @r/'b(a*)', @r/'fo,',
|
503
505
|
@r/'f.o', @r/'**/({a,b})']
|
504
506
|
@l3 = PathList[@r/'ba{rbar,zfoo}']
|
507
|
+
@l4 = PathList[@r/'(b{a{rbar,zfoo},u,i})']
|
505
508
|
end
|
506
509
|
|
507
510
|
def test_each
|
508
511
|
@l.each(&@mo)
|
509
512
|
@l2.each(&@mo)
|
510
513
|
@l3.each(&@mo)
|
514
|
+
@l4.each(&@mo)
|
511
515
|
assert_equal([
|
512
516
|
[@r/'foo'], [@r/'barbar'], [@r/'bazfoo'], [@r/'foo/a'], [@r/'foo/b'],
|
517
|
+
[@r/'bu'], [@r/'bi'],
|
518
|
+
|
513
519
|
[@r/'foo', 'foo'], [@r/'barbar', 'arbar'], [@r/'bazfoo', 'azfoo'],
|
514
520
|
[@r/'fo,'], [@r/'f.o'], [@r/'foo/a', 'a'], [@r/'foo/b', 'b'],
|
515
|
-
|
521
|
+
|
522
|
+
[@r/'barbar'], [@r/'bazfoo'],
|
523
|
+
|
524
|
+
[@r/'barbar', 'barbar'], [@r/'bazfoo', 'bazfoo'], [@r/'bu', 'bu'],
|
525
|
+
[@r/'bi', 'bi']
|
516
526
|
], @args)
|
517
527
|
end
|
518
528
|
|
519
529
|
def test_pathlist
|
520
530
|
ls = __FILE__.to_path.dirname + '*.rb'
|
521
|
-
assert_yaml_load "
|
522
|
-
assert_yaml_dump @val,
|
531
|
+
assert_yaml_load "!filelist #{ls}", PathList, PathList[ls]
|
532
|
+
assert_yaml_dump @val.to_a, /.*/
|
533
|
+
assert_yaml_dump @val, @str
|
523
534
|
end
|
524
535
|
|
525
536
|
end # class PathListTest
|
data/lib/temp_path.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# License: Gnu General Public License.
|
4
4
|
|
5
5
|
# $LastChangedBy: ertai $
|
6
|
-
# $Id: temp_path.rb
|
6
|
+
# $Id: /w/fey/ruby_ex/trunk/core_ex/lib/temp_path.rb 8004 2005-10-09T19:51:28.097991Z ertai $
|
7
7
|
|
8
8
|
require 'tempfile'
|
9
9
|
require 'tmpdir'
|
@@ -184,8 +184,8 @@ test_section __FILE__ do
|
|
184
184
|
end
|
185
185
|
|
186
186
|
def test_interface
|
187
|
-
assert_match(/\.#{$$}\/foo
|
188
|
-
assert_match(/\.#{$$}\/foo
|
187
|
+
assert_match(/\.#{$$}\/foo\.-?\d+$/, @foo.to_s)
|
188
|
+
assert_match(/\.#{$$}\/foo\.-?\d+\.bar$/, @foobar.to_s)
|
189
189
|
assert_nothing_raised { @foo.open('w') { |f| f.puts 'FooFoo' } }
|
190
190
|
end
|
191
191
|
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# License:: Ruby license.
|
4
4
|
|
5
5
|
# $LastChangedBy: ertai $
|
6
|
-
# $Id: test_runner.rb
|
6
|
+
# $Id: /w/fey/ruby_ex/trunk/core_ex/lib/test/unit/u_i/yaml/test_runner.rb 7956 2005-09-14T08:33:42.463064Z ertai $
|
7
7
|
|
8
8
|
|
9
9
|
require 'test/unit/autorunner'
|