utilrb 1.1 → 1.2
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/{Changes.txt → History.txt} +11 -0
- data/License.txt +2 -2
- data/Manifest.txt +10 -3
- data/README.txt +10 -13
- data/Rakefile +30 -13
- data/ext/extconf.rb +6 -1
- data/ext/{ruby_internals.h → ruby_internals-1.8.h} +0 -0
- data/ext/ruby_internals-1.9.h +48 -0
- data/ext/swap.cc +5 -1
- data/ext/{faster.cc → utilrb_ext.cc} +29 -2
- data/lib/utilrb/column_formatter.rb +1 -1
- data/lib/utilrb/common.rb +21 -18
- data/lib/utilrb/dir.rb +2 -0
- data/lib/utilrb/dir/empty.rb +3 -0
- data/lib/utilrb/enumerable/uniq.rb +1 -1
- data/lib/utilrb/kernel/options.rb +3 -2
- data/lib/utilrb/kernel/swap.rb +1 -1
- data/lib/utilrb/logger/hierarchy.rb +7 -7
- data/lib/utilrb/module/ancestor_p.rb +2 -2
- data/lib/utilrb/module/define_or_reuse.rb +29 -0
- data/lib/utilrb/module/include.rb +15 -12
- data/lib/utilrb/module/inherited_enumerable.rb +4 -0
- data/lib/utilrb/object/address.rb +3 -3
- data/lib/utilrb/object/attribute.rb +2 -2
- data/lib/utilrb/object/singleton_class.rb +40 -47
- data/lib/utilrb/socket/tcp_server.rb +7 -0
- data/lib/utilrb/socket/tcp_socket.rb +7 -0
- data/lib/utilrb/time/to_hms.rb +31 -16
- data/lib/utilrb/value_set.rb +1 -1
- data/test/test_dir.rb +22 -0
- data/test/test_enumerable.rb +2 -2
- data/test/test_kernel.rb +2 -2
- data/test/test_module.rb +61 -53
- data/test/test_object.rb +25 -4
- data/test/test_pkgconfig.rb +0 -1
- data/test/test_proc.rb +23 -20
- data/test/test_time.rb +15 -2
- metadata +86 -61
data/test/test_object.rb
CHANGED
@@ -1,13 +1,16 @@
|
|
1
1
|
require 'test_config'
|
2
2
|
|
3
3
|
require 'utilrb/object'
|
4
|
+
require 'utilrb/module/attr_predicate'
|
4
5
|
|
5
6
|
class TC_Object < Test::Unit::TestCase
|
6
7
|
def test_address
|
8
|
+
assert_equal("2aaaab38b398", Object.address_from_id(0x1555559c59cc).to_s(16))
|
9
|
+
|
7
10
|
foo = Object.new
|
8
|
-
foo.to_s =~ /#<Object:
|
11
|
+
foo.to_s =~ /#<Object:0x0*([0-9a-f]+)>/
|
9
12
|
foo_address = $1
|
10
|
-
assert_equal(foo_address, foo.address.to_s(16), "#{foo} #{foo.address} #{foo.object_id}")
|
13
|
+
assert_equal(foo_address, foo.address.to_s(16), "#{foo} #{foo.address.to_s(16)} #{foo.object_id.to_s(16)}")
|
11
14
|
end
|
12
15
|
|
13
16
|
def check_attribute(object)
|
@@ -53,13 +56,31 @@ class TC_Object < Test::Unit::TestCase
|
|
53
56
|
end
|
54
57
|
|
55
58
|
def test_singleton_class
|
56
|
-
klass = Class.new
|
59
|
+
klass = Class.new do
|
60
|
+
def bla; 0 end
|
61
|
+
end
|
62
|
+
|
57
63
|
object = klass.new
|
64
|
+
|
65
|
+
singleton = class << object
|
66
|
+
class << self
|
67
|
+
def bla
|
68
|
+
"a"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
self
|
72
|
+
end
|
73
|
+
|
58
74
|
assert(! object.has_singleton?)
|
59
75
|
assert_equal(object, object.singleton_class.singleton_instance)
|
60
76
|
assert(object.has_singleton?)
|
61
77
|
assert_equal(klass, object.singleton_class.superclass)
|
62
|
-
|
78
|
+
|
79
|
+
|
80
|
+
Utilrb.if_ext do
|
81
|
+
assert_equal([object.singleton_class, klass, Object], object.singleton_class.ancestors[0, 3])
|
82
|
+
assert_equal([klass, Object], klass.ancestors[0, 2])
|
83
|
+
end
|
63
84
|
end
|
64
85
|
|
65
86
|
def test_attr_predicate
|
data/test/test_pkgconfig.rb
CHANGED
@@ -13,7 +13,6 @@ class TC_PkgConfig < Test::Unit::TestCase
|
|
13
13
|
|
14
14
|
PkgConfig = Utilrb::PkgConfig
|
15
15
|
def test_find_package
|
16
|
-
STDERR.puts ENV['PKG_CONFIG_PATH']
|
17
16
|
assert_raises(PkgConfig::NotFound) { PkgConfig.new('does_not_exist') }
|
18
17
|
assert_nothing_raised { PkgConfig.new('test_pkgconfig') }
|
19
18
|
end
|
data/test/test_proc.rb
CHANGED
@@ -1,27 +1,30 @@
|
|
1
|
-
require '
|
1
|
+
require 'test_config'
|
2
|
+
|
2
3
|
require 'utilrb'
|
3
4
|
|
4
|
-
Utilrb.
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
5
|
+
Utilrb.require_ext('TC_Proc') do
|
6
|
+
if RUBY_VERSION =~ /^1\.8/
|
7
|
+
class TC_Proc < Test::Unit::TestCase
|
8
|
+
def block_to_proc_helper(&block); block end
|
9
|
+
def block_to_proc
|
10
|
+
[block_to_proc_helper { blo }, block_to_proc_helper { bla }]
|
11
|
+
end
|
12
|
+
def test_same_body
|
13
|
+
a1, a2 = block_to_proc
|
14
|
+
b1, b2 = block_to_proc
|
15
|
+
assert(a1.same_body?(b1))
|
16
|
+
assert(a2.same_body?(b2))
|
17
|
+
assert(!a1.same_body?(b2))
|
18
|
+
assert(!a2.same_body?(b1))
|
19
|
+
end
|
18
20
|
|
19
|
-
|
20
|
-
|
21
|
-
|
21
|
+
def test_line
|
22
|
+
assert_equal(10, block_to_proc.first.line)
|
23
|
+
end
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
+
def test_file
|
26
|
+
assert_equal(File.expand_path(__FILE__), File.expand_path(block_to_proc.first.file))
|
27
|
+
end
|
25
28
|
end
|
26
29
|
end
|
27
30
|
end
|
data/test/test_time.rb
CHANGED
@@ -10,12 +10,21 @@ class TC_Time < Test::Unit::TestCase
|
|
10
10
|
assert_equal("236:21:34.100", Time.at(236 * 3600 + 21 * 60 + 34.1).to_hms)
|
11
11
|
end
|
12
12
|
def test_from_hms
|
13
|
-
assert_equal(
|
14
|
-
assert_equal(
|
13
|
+
assert_equal([0, 0, 0, 1], Time.hms_decomposition('0:00:00.001'))
|
14
|
+
assert_equal([0, 0, 0, 10], Time.hms_decomposition('0:00:00.01'))
|
15
|
+
assert_equal([0, 0, 0, 10], Time.hms_decomposition('0:00:00.010'))
|
16
|
+
assert_equal([0, 0, 0, 100], Time.hms_decomposition('0:00:00.1'))
|
17
|
+
assert_equal([0, 0, 0, 100], Time.hms_decomposition('0:00:00.10'))
|
18
|
+
assert_equal([0, 0, 0, 100], Time.hms_decomposition('0:00:00.100'))
|
19
|
+
|
20
|
+
assert_equal([0, 0, 0, 0], Time.hms_decomposition("0:00:00.000"))
|
15
21
|
assert_equal(Time.at(34.1), Time.from_hms("0:00:34.100"))
|
16
22
|
assert_equal(Time.at(21 * 60 + 34.1), Time.from_hms("0:21:34.100"))
|
17
23
|
assert_equal(Time.at(236 * 3600 + 21 * 60 + 34.1), Time.from_hms("236:21:34.100"))
|
18
24
|
|
25
|
+
assert_equal([329991, 0, 10, 0], Time.hms_decomposition("329991:00:10"))
|
26
|
+
assert_equal([329991, 8, 8, 0], Time.hms_decomposition("329991:08:08"))
|
27
|
+
|
19
28
|
assert_equal(Time.at(0), Time.from_hms("0"))
|
20
29
|
assert_equal(Time.at(0), Time.from_hms(":0"))
|
21
30
|
assert_equal(Time.at(62), Time.from_hms("1:2"))
|
@@ -29,6 +38,10 @@ class TC_Time < Test::Unit::TestCase
|
|
29
38
|
assert_in_delta(0, Time.at(1.02) - Time.from_hms("1.02"), 0.001)
|
30
39
|
assert_in_delta(0, Time.at(121.03) - Time.from_hms("2:1.03"), 0.001)
|
31
40
|
assert_in_delta(0, Time.at(3723.04) - Time.from_hms("1:2:3.04"), 0.001)
|
41
|
+
assert_in_delta(0, Time.at(1.75) - Time.from_hms("1.75"), 0.001)
|
42
|
+
assert_in_delta(0, Time.at(121.75) - Time.from_hms("2:1.75"), 0.001)
|
43
|
+
assert_in_delta(0, Time.at(3723.75) - Time.from_hms("1:2:3.75"), 0.001)
|
44
|
+
assert_in_delta(0, Time.at(3723.243) - Time.from_hms("1:2:3.243"), 0.001)
|
32
45
|
end
|
33
46
|
end
|
34
47
|
|
metadata
CHANGED
@@ -1,36 +1,58 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.4
|
3
|
-
specification_version: 1
|
4
2
|
name: utilrb
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
version: "1.
|
7
|
-
date: 2007-06-19 00:00:00 +02:00
|
8
|
-
summary: Yet another Ruby toolkit
|
9
|
-
require_paths:
|
10
|
-
- lib
|
11
|
-
- ext
|
12
|
-
email: sylvain.joyeux@m4x.org
|
13
|
-
homepage: " http://utilrb.rubyforge.org"
|
14
|
-
rubyforge_project: utilrb
|
15
|
-
description: "== What is Utilrb ? Utilrb is yet another Ruby toolkit, in the spirit of facets. It includes all the standard class extensions I use in my own projects like Genom.rb. == Utilrb's C extension Utilrb includes a C extension in ext/. It is optional, but some of the functionalities will be disabled if it is not present. Trying to require a file in which there is a C-only feature will yield a warning on STDOUT. * some features have a Ruby version, but a C version is provided for performance: - Enumerable#each_uniq * some features are C-only - ValueSet class - Kernel#swap!"
|
16
|
-
autorequire:
|
17
|
-
default_executable:
|
18
|
-
bindir: bin
|
19
|
-
has_rdoc: true
|
20
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
21
|
-
requirements:
|
22
|
-
- - ">"
|
23
|
-
- !ruby/object:Gem::Version
|
24
|
-
version: 0.0.0
|
25
|
-
version:
|
4
|
+
version: "1.2"
|
26
5
|
platform: ruby
|
27
|
-
signing_key:
|
28
|
-
cert_chain:
|
29
|
-
post_install_message:
|
30
6
|
authors:
|
31
7
|
- Sylvain Joyeux
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-05-07 00:00:00 +02:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: facets
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 2.4.0
|
23
|
+
version:
|
24
|
+
- !ruby/object:Gem::Dependency
|
25
|
+
name: rake
|
26
|
+
version_requirement:
|
27
|
+
version_requirements: !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- - ">="
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: "0"
|
32
|
+
version:
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: hoe
|
35
|
+
version_requirement:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.5.1
|
41
|
+
version:
|
42
|
+
description: == What is Utilrb ? Utilrb is yet another Ruby toolkit, in the spirit of facets. It includes all the standard class extensions I use in my own projects like Genom.rb. == Installation The only dependency Utilrb has is flexmock if you want to run tests. It is available as a gem, so you can run gem install flexmock == Utilrb's C extension Utilrb includes a C extension in ext/. It is optional, but some of the functionalities will be disabled if it is not present. Trying to require a file in which there is a C-only feature will yield a warning on STDOUT.
|
43
|
+
email:
|
44
|
+
- sylvain.joyeux@m4x.org
|
45
|
+
executables: []
|
46
|
+
|
47
|
+
extensions:
|
48
|
+
- ext/extconf.rb
|
49
|
+
extra_rdoc_files:
|
50
|
+
- History.txt
|
51
|
+
- License.txt
|
52
|
+
- Manifest.txt
|
53
|
+
- README.txt
|
32
54
|
files:
|
33
|
-
-
|
55
|
+
- History.txt
|
34
56
|
- License.txt
|
35
57
|
- Manifest.txt
|
36
58
|
- README.txt
|
@@ -38,8 +60,9 @@ files:
|
|
38
60
|
- bm/allocation.rb
|
39
61
|
- bm/speed.rb
|
40
62
|
- ext/extconf.rb
|
41
|
-
- ext/
|
42
|
-
- ext/ruby_internals.h
|
63
|
+
- ext/utilrb_ext.cc
|
64
|
+
- ext/ruby_internals-1.8.h
|
65
|
+
- ext/ruby_internals-1.9.h
|
43
66
|
- ext/swap.cc
|
44
67
|
- ext/value_set.cc
|
45
68
|
- lib/utilrb.rb
|
@@ -47,6 +70,8 @@ files:
|
|
47
70
|
- lib/utilrb/array/to_s.rb
|
48
71
|
- lib/utilrb/column_formatter.rb
|
49
72
|
- lib/utilrb/common.rb
|
73
|
+
- lib/utilrb/dir.rb
|
74
|
+
- lib/utilrb/dir/empty.rb
|
50
75
|
- lib/utilrb/enumerable.rb
|
51
76
|
- lib/utilrb/enumerable/null.rb
|
52
77
|
- lib/utilrb/enumerable/random_element.rb
|
@@ -76,6 +101,7 @@ files:
|
|
76
101
|
- lib/utilrb/module/attr_predicate.rb
|
77
102
|
- lib/utilrb/module/cached_enum.rb
|
78
103
|
- lib/utilrb/module/define_method.rb
|
104
|
+
- lib/utilrb/module/define_or_reuse.rb
|
79
105
|
- lib/utilrb/module/include.rb
|
80
106
|
- lib/utilrb/module/inherited_enumerable.rb
|
81
107
|
- lib/utilrb/object.rb
|
@@ -86,6 +112,8 @@ files:
|
|
86
112
|
- lib/utilrb/pkgconfig.rb
|
87
113
|
- lib/utilrb/set.rb
|
88
114
|
- lib/utilrb/set/to_s.rb
|
115
|
+
- lib/utilrb/socket/tcp_server.rb
|
116
|
+
- lib/utilrb/socket/tcp_socket.rb
|
89
117
|
- lib/utilrb/time.rb
|
90
118
|
- lib/utilrb/time/to_hms.rb
|
91
119
|
- lib/utilrb/unbound_method.rb
|
@@ -94,6 +122,7 @@ files:
|
|
94
122
|
- test/data/test_pkgconfig.pc
|
95
123
|
- test/test_array.rb
|
96
124
|
- test/test_config.rb
|
125
|
+
- test/test_dir.rb
|
97
126
|
- test/test_enumerable.rb
|
98
127
|
- test/test_exception.rb
|
99
128
|
- test/test_gc.rb
|
@@ -108,7 +137,36 @@ files:
|
|
108
137
|
- test/test_set.rb
|
109
138
|
- test/test_time.rb
|
110
139
|
- test/test_unbound_method.rb
|
140
|
+
has_rdoc: true
|
141
|
+
homepage: " http://utilrb.rubyforge.org"
|
142
|
+
post_install_message:
|
143
|
+
rdoc_options:
|
144
|
+
- --main
|
145
|
+
- README.txt
|
146
|
+
require_paths:
|
147
|
+
- lib
|
148
|
+
- ext
|
149
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - ">="
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: "0"
|
154
|
+
version:
|
155
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: "0"
|
160
|
+
version:
|
161
|
+
requirements: []
|
162
|
+
|
163
|
+
rubyforge_project: utilrb
|
164
|
+
rubygems_version: 1.1.1
|
165
|
+
signing_key:
|
166
|
+
specification_version: 2
|
167
|
+
summary: Yet another Ruby toolkit
|
111
168
|
test_files:
|
169
|
+
- test/test_dir.rb
|
112
170
|
- test/test_proc.rb
|
113
171
|
- test/test_exception.rb
|
114
172
|
- test/test_set.rb
|
@@ -125,36 +183,3 @@ test_files:
|
|
125
183
|
- test/test_hash.rb
|
126
184
|
- test/test_objectstats.rb
|
127
185
|
- test/test_pkgconfig.rb
|
128
|
-
rdoc_options:
|
129
|
-
- --main
|
130
|
-
- README.txt
|
131
|
-
extra_rdoc_files:
|
132
|
-
- Changes.txt
|
133
|
-
- License.txt
|
134
|
-
- Manifest.txt
|
135
|
-
- README.txt
|
136
|
-
executables: []
|
137
|
-
|
138
|
-
extensions: []
|
139
|
-
|
140
|
-
requirements: []
|
141
|
-
|
142
|
-
dependencies:
|
143
|
-
- !ruby/object:Gem::Dependency
|
144
|
-
name: facets
|
145
|
-
version_requirement:
|
146
|
-
version_requirements: !ruby/object:Gem::Version::Requirement
|
147
|
-
requirements:
|
148
|
-
- - ">"
|
149
|
-
- !ruby/object:Gem::Version
|
150
|
-
version: 0.0.0
|
151
|
-
version:
|
152
|
-
- !ruby/object:Gem::Dependency
|
153
|
-
name: hoe
|
154
|
-
version_requirement:
|
155
|
-
version_requirements: !ruby/object:Gem::Version::Requirement
|
156
|
-
requirements:
|
157
|
-
- - ">="
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
version: 1.2.1
|
160
|
-
version:
|