utilrb 2.0.2.b2 → 2.1.0.rc1
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.
- checksums.yaml +4 -4
- data/.boring +40 -0
- data/.gitignore +13 -0
- data/.travis.yml +5 -0
- data/CMakeLists.txt +18 -0
- data/Gemfile +3 -0
- data/Makefile +8 -0
- data/Manifest.txt +0 -8
- data/{README.rd → README.md} +11 -7
- data/Rakefile +16 -63
- data/benchmarks/validate_options.rb +79 -0
- data/ext/utilrb/extconf.rb +1 -17
- data/ext/utilrb/utilrb.cc +0 -23
- data/lib/utilrb/column_formatter.rb +8 -5
- data/lib/utilrb/common.rb +1 -6
- data/lib/utilrb/enumerable/uniq.rb +2 -8
- data/lib/utilrb/event_loop.rb +5 -10
- data/lib/utilrb/kernel/load_dsl_file.rb +1 -2
- data/lib/utilrb/kernel/options.rb +25 -29
- data/lib/utilrb/logger/hierarchy.rb +0 -1
- data/lib/utilrb/logger/io.rb +3 -3
- data/lib/utilrb/logger/root.rb +12 -6
- data/lib/utilrb/module/ancestor_p.rb +0 -12
- data/lib/utilrb/module/is_singleton.rb +6 -0
- data/lib/utilrb/module/singleton_class_p.rb +14 -0
- data/lib/utilrb/object/attribute.rb +33 -65
- data/lib/utilrb/object/singleton_class.rb +1 -20
- data/lib/utilrb/pkgconfig.rb +21 -10
- data/lib/utilrb/socket/tcp_server.rb +2 -2
- data/lib/utilrb/spawn.rb +1 -1
- data/lib/utilrb/test.rb +65 -0
- data/lib/utilrb/thread_pool.rb +11 -13
- data/lib/utilrb/timepoints.rb +15 -0
- data/lib/utilrb/value_set.rb +10 -1
- data/lib/utilrb/version.rb +4 -0
- data/lib/utilrb/weakref.rb +11 -12
- data/lib/utilrb/yard.rb +0 -111
- data/lib/utilrb.rb +6 -1
- data/lib/yard-utilrb.rb +1 -0
- data/manifest.xml +19 -0
- data/package.xml +29 -0
- data/utilrb.gemspec +27 -0
- metadata +56 -107
- data/ext/utilrb/proc.c +0 -39
- data/ext/utilrb/readline.c +0 -52
- data/ext/utilrb/weakref.cc +0 -143
- data/lib/utilrb/models/inherited_enumerable.rb +0 -341
- data/lib/utilrb/models/registration.rb +0 -115
- data/lib/utilrb/module/inherited_enumerable.rb +0 -6
- data/lib/utilrb/objectstats.rb +0 -193
- data/lib/utilrb/ruby_object_graph.rb +0 -384
- data/test/data/test_pkgconfig.pc +0 -9
- data/test/data/test_pkgconfig_empty.pc +0 -10
- data/test/test_array.rb +0 -15
- data/test/test_config.rb +0 -4
- data/test/test_dir.rb +0 -22
- data/test/test_enumerable.rb +0 -119
- data/test/test_event_loop.rb +0 -407
- data/test/test_exception.rb +0 -38
- data/test/test_gc.rb +0 -34
- data/test/test_hash.rb +0 -102
- data/test/test_kernel.rb +0 -300
- data/test/test_logger.rb +0 -204
- data/test/test_misc.rb +0 -42
- data/test/test_models.rb +0 -212
- data/test/test_module.rb +0 -126
- data/test/test_object.rb +0 -77
- data/test/test_objectstats.rb +0 -26
- data/test/test_pkgconfig.rb +0 -84
- data/test/test_proc.rb +0 -31
- data/test/test_set.rb +0 -19
- data/test/test_thread_pool.rb +0 -409
- data/test/test_time.rb +0 -47
- data/test/test_unbound_method.rb +0 -23
- data/test/test_weakref.rb +0 -81
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25dfac5169ea1deb85644a81fce37e34b57fbe06
|
4
|
+
data.tar.gz: d294185b07a13167202368e519b3dbdf1be0a46f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d7ec758b7d5aa8854c828b5f5845fa92c0aad1c3e424879ec0866236f8f7c9c420cb01c22f6c15c547fc87b93d98b1d8b6fcb66b096ddaed0f45d1c9f2f8d3c
|
7
|
+
data.tar.gz: 543b63138464740343424f0e81b01fe0ac7a541b69e2cefeb5193546f0845db6a2e6d83b6bf6ee282b05184e4adbf2bd2dedcd2cd885cc42425de1bfafa97404
|
data/.boring
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# Boring file regexps:
|
2
|
+
\.hi$
|
3
|
+
\.o$
|
4
|
+
\.o\.cmd$
|
5
|
+
# *.ko files aren't boring by default because they might
|
6
|
+
# be Korean translations rather than kernel modules.
|
7
|
+
# \.ko$
|
8
|
+
\.ko\.cmd$
|
9
|
+
\.mod\.c$
|
10
|
+
(^|/)\.tmp_versions($|/)
|
11
|
+
(^|/)CVS($|/)
|
12
|
+
(^|/)RCS($|/)
|
13
|
+
~$
|
14
|
+
#(^|/)\.[^/]
|
15
|
+
(^|/)_darcs($|/)
|
16
|
+
\.bak$
|
17
|
+
\.BAK$
|
18
|
+
\.orig$
|
19
|
+
(^|/)vssver\.scc$
|
20
|
+
\.swp$
|
21
|
+
(^|/)MT($|/)
|
22
|
+
(^|/)\{arch\}($|/)
|
23
|
+
(^|/).arch-ids($|/)
|
24
|
+
(^|/),
|
25
|
+
\.class$
|
26
|
+
\.prof$
|
27
|
+
(^|/)\.DS_Store$
|
28
|
+
(^|/)BitKeeper($|/)
|
29
|
+
(^|/)ChangeSet($|/)
|
30
|
+
(^|/)\.svn($|/)
|
31
|
+
\.py[co]$
|
32
|
+
\#
|
33
|
+
\.cvsignore$
|
34
|
+
(^|/)Thumbs\.db$
|
35
|
+
(^|/)autom4te\.cache($|/)
|
36
|
+
^rcov
|
37
|
+
\.so$
|
38
|
+
^ext/(Makefile|mkmf.log)$
|
39
|
+
-stamp$
|
40
|
+
^(doc|html|pkg)$
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CMakeLists.txt
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
|
2
|
+
cmake_minimum_required(VERSION 2.6)
|
3
|
+
|
4
|
+
project(utilrb)
|
5
|
+
FIND_PACKAGE(Ruby REQUIRED)
|
6
|
+
|
7
|
+
ADD_CUSTOM_TARGET(utilrb_ext ALL
|
8
|
+
COMMAND rake
|
9
|
+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
10
|
+
|
11
|
+
STRING(REGEX REPLACE ".*lib(32|64)?/?" "lib/" RUBY_EXTENSIONS_INSTALL_DIR ${RUBY_ARCH_DIR})
|
12
|
+
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib/ DESTINATION ${RUBY_EXTENSIONS_INSTALL_DIR}
|
13
|
+
PATTERN "utilrb_ext.*" EXCLUDE )
|
14
|
+
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ext/ DESTINATION ${RUBY_EXTENSIONS_INSTALL_DIR}
|
15
|
+
FILES_MATCHING PATTERN "utilrb_ext.*"
|
16
|
+
PATTERN "*.o" EXCLUDE
|
17
|
+
PATTERN "*.cc" EXCLUDE
|
18
|
+
)
|
data/Gemfile
ADDED
data/Makefile
ADDED
data/Manifest.txt
CHANGED
@@ -8,7 +8,6 @@ bm/allocation.rb
|
|
8
8
|
bm/speed.rb
|
9
9
|
ext/utilrb/extconf.rb
|
10
10
|
ext/utilrb/proc.c
|
11
|
-
ext/utilrb/readline.c
|
12
11
|
ext/utilrb/ruby_allocator.hh
|
13
12
|
ext/utilrb/utilrb.cc
|
14
13
|
ext/utilrb/value_set.cc
|
@@ -57,8 +56,6 @@ lib/utilrb/logger/log_pp.rb
|
|
57
56
|
lib/utilrb/logger/root.rb
|
58
57
|
lib/utilrb/logger/silent.rb
|
59
58
|
lib/utilrb/marshal/load_with_missing_constants.rb
|
60
|
-
lib/utilrb/models/inherited_enumerable.rb
|
61
|
-
lib/utilrb/models/registration.rb
|
62
59
|
lib/utilrb/module.rb
|
63
60
|
lib/utilrb/module/ancestor_p.rb
|
64
61
|
lib/utilrb/module/attr_enumerable.rb
|
@@ -75,14 +72,12 @@ lib/utilrb/object/address.rb
|
|
75
72
|
lib/utilrb/object/attribute.rb
|
76
73
|
lib/utilrb/object/scoped_eval.rb
|
77
74
|
lib/utilrb/object/singleton_class.rb
|
78
|
-
lib/utilrb/objectstats.rb
|
79
75
|
lib/utilrb/pathname.rb
|
80
76
|
lib/utilrb/pathname/find_matching_parent.rb
|
81
77
|
lib/utilrb/pkgconfig.rb
|
82
78
|
lib/utilrb/qt/mime_data/mime_data.rb
|
83
79
|
lib/utilrb/qt/variant/from_ruby.rb
|
84
80
|
lib/utilrb/rake_common.rb
|
85
|
-
lib/utilrb/ruby_object_graph.rb
|
86
81
|
lib/utilrb/set.rb
|
87
82
|
lib/utilrb/set/to_s.rb
|
88
83
|
lib/utilrb/socket/tcp_server.rb
|
@@ -102,7 +97,6 @@ patches/gc_live_objects.patch
|
|
102
97
|
test/data/test_pkgconfig.pc
|
103
98
|
test/data/test_pkgconfig_empty.pc
|
104
99
|
test/test_array.rb
|
105
|
-
test/test_config.rb
|
106
100
|
test/test_dir.rb
|
107
101
|
test/test_enumerable.rb
|
108
102
|
test/test_event_loop.rb
|
@@ -112,10 +106,8 @@ test/test_hash.rb
|
|
112
106
|
test/test_kernel.rb
|
113
107
|
test/test_logger.rb
|
114
108
|
test/test_misc.rb
|
115
|
-
test/test_models.rb
|
116
109
|
test/test_module.rb
|
117
110
|
test/test_object.rb
|
118
|
-
test/test_objectstats.rb
|
119
111
|
test/test_pkgconfig.rb
|
120
112
|
test/test_proc.rb
|
121
113
|
test/test_set.rb
|
data/{README.rd → README.md}
RENAMED
@@ -1,18 +1,22 @@
|
|
1
|
-
=
|
1
|
+
[](https://travis-ci.org/orocos-toolchain/utilrb)
|
2
|
+
[](http://badge.fury.io/rb/utilrb)
|
3
|
+
[](http://rubydoc.info/gems/utilrb/frames)
|
4
|
+
|
5
|
+
Utilrb
|
6
|
+
------
|
2
7
|
|
3
8
|
homepage :: http://rock-robotics.org
|
4
9
|
mailing list :: http://www.dfki.de/mailman/cgi-bin/listinfo/rock-dev
|
5
|
-
bug tracker ::
|
6
|
-
rubygem page :: http://rubygems.org/gems/utilrb
|
7
|
-
git repository :: http://gitorious.org/orocos-toolchain/utilrb.git
|
8
|
-
API documentation :: http://rubydoc.info/gems/utilrb/1.6.6/frames
|
10
|
+
bug tracker :: https://github.com/orocos-toolchain/utilrb
|
9
11
|
|
10
|
-
|
12
|
+
DESCRIPTION
|
13
|
+
-----------
|
11
14
|
|
12
15
|
Utilrb is yet another Ruby toolkit, in the spirit of facets. It includes all
|
13
16
|
the standard class extensions I use in other projects.
|
14
17
|
|
15
|
-
|
18
|
+
LICENSE
|
19
|
+
-------
|
16
20
|
|
17
21
|
Copyright (c) 2006-2013
|
18
22
|
Sylvain Joyeux <sylvain.joyeux@m4x.org>
|
data/Rakefile
CHANGED
@@ -1,67 +1,20 @@
|
|
1
|
-
|
2
|
-
require
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
self.readme_file = 'README.rd'
|
12
|
-
|
13
|
-
|
14
|
-
extra_deps <<
|
15
|
-
['facets', '>= 2.4.0'] <<
|
16
|
-
['rake', '>= 0.9'] <<
|
17
|
-
["hoe", ">= 3.7.1"] <<
|
18
|
-
["hoe-yard", ">= 0.1.2"]
|
19
|
-
|
20
|
-
if RUBY_VERSION < '2.0'
|
21
|
-
spec_extras[:required_ruby_version] = '~> 1.9'
|
22
|
-
extra_deps << ["rake-compiler", '~> 0.8.0']
|
23
|
-
else
|
24
|
-
spec_extras[:required_ruby_version] = '>= 2.0'
|
25
|
-
extra_deps << ["rake-compiler"]
|
26
|
-
end
|
27
|
-
|
28
|
-
extra_dev_deps <<
|
29
|
-
['flexmock', '>= 0.8.6'] <<
|
30
|
-
['debugger-ruby_core_source', '>= 0']
|
31
|
-
|
32
|
-
licenses << 'BSD'
|
33
|
-
|
34
|
-
spec_extras[:extensions] = FileList["ext/**/extconf.rb"]
|
35
|
-
end
|
36
|
-
|
37
|
-
require 'rubygems/package_task'
|
38
|
-
Gem::PackageTask.new(hoe_spec.spec) do |pkg|
|
39
|
-
pkg.need_zip = true
|
40
|
-
pkg.need_tar = true
|
41
|
-
end
|
42
|
-
|
43
|
-
require 'rake/extensiontask'
|
44
|
-
utilrb_task = Rake::ExtensionTask.new('utilrb', hoe_spec.spec) do |ext|
|
45
|
-
ext.name = 'utilrb'
|
46
|
-
ext.ext_dir = 'ext/utilrb'
|
47
|
-
ext.lib_dir = 'lib/utilrb'
|
48
|
-
ext.source_pattern ="*.{c,cc,cpp}"
|
49
|
-
end
|
50
|
-
|
51
|
-
Rake.clear_tasks(/^default$/)
|
52
|
-
task :default => :compile
|
53
|
-
|
54
|
-
task :docs => :yard
|
55
|
-
task :redocs => :yard
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rake/testtask"
|
3
|
+
|
4
|
+
require 'rake/extensiontask'
|
5
|
+
Rake::ExtensionTask.new('utilrb') do |ext|
|
6
|
+
ext.name = 'utilrb'
|
7
|
+
ext.ext_dir = 'ext/utilrb'
|
8
|
+
ext.lib_dir = 'lib/utilrb'
|
9
|
+
ext.source_pattern ="*.{c,cc,cpp}"
|
10
|
+
end
|
56
11
|
|
12
|
+
task :default => :compile
|
57
13
|
|
58
|
-
|
59
|
-
|
14
|
+
Rake::TestTask.new(:test) do |t|
|
15
|
+
t.libs << "test"
|
16
|
+
t.libs << "lib"
|
17
|
+
t.test_files = FileList['test/**/test_*.rb']
|
60
18
|
end
|
61
19
|
|
62
|
-
task :
|
63
|
-
ENV.delete_if { |name,val| name == "UTILRB_EXT_MODE" }
|
64
|
-
system('testrb -I. test')
|
65
|
-
ENV['UTILRB_EXT_MODE'] = 'yes'
|
66
|
-
system('testrb -I. test')
|
67
|
-
end
|
20
|
+
task :gem => :build
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'benchmark'
|
2
|
+
require 'utilrb/kernel/options'
|
3
|
+
|
4
|
+
options = Hash[
|
5
|
+
test: 10,
|
6
|
+
other_test: 20]
|
7
|
+
|
8
|
+
TIMES = 100_000
|
9
|
+
|
10
|
+
def validate(options)
|
11
|
+
Kernel.validate_options options, :accept_opaques => false,
|
12
|
+
:accept_pointers => false,
|
13
|
+
:merge_skip_copy => true,
|
14
|
+
:remove_trailing_skips => true
|
15
|
+
end
|
16
|
+
|
17
|
+
def validate_with_new_style_hash(options)
|
18
|
+
Kernel.validate_options options, accept_opaques: false,
|
19
|
+
accept_pointers: false,
|
20
|
+
merge_skip_copy: true,
|
21
|
+
remove_trailing_skips: true
|
22
|
+
end
|
23
|
+
|
24
|
+
def validate_with_keyword_arguments(accept_opaques: false,
|
25
|
+
accept_pointers: false,
|
26
|
+
merge_skip_copy: true,
|
27
|
+
remove_trailing_skips: true)
|
28
|
+
Hash[accept_opaques: accept_opaques,
|
29
|
+
accept_pointers: accept_pointers,
|
30
|
+
merge_skip_copy: merge_skip_copy,
|
31
|
+
remove_trailing_skips: remove_trailing_skips]
|
32
|
+
end
|
33
|
+
|
34
|
+
Benchmark.bm do |x|
|
35
|
+
x.report("with empty options") do
|
36
|
+
TIMES.times do
|
37
|
+
validate(Hash.new)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
x.report("with empty options and new-style hash") do
|
41
|
+
TIMES.times do
|
42
|
+
validate_with_new_style_hash(Hash.new)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
x.report("with empty options and keyword arguments") do
|
46
|
+
TIMES.times do
|
47
|
+
validate_with_keyword_arguments(accept_opaques: false,
|
48
|
+
accept_pointers: false,
|
49
|
+
merge_skip_copy: true,
|
50
|
+
remove_trailing_skips: true)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
x.report("with all options set") do
|
54
|
+
options = Hash[]
|
55
|
+
TIMES.times do
|
56
|
+
validate(:accept_opaques => false,
|
57
|
+
:accept_pointers => false,
|
58
|
+
:merge_skip_copy => true,
|
59
|
+
:remove_trailing_skips => true)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
x.report("with all options set and new-style hash") do
|
63
|
+
TIMES.times do
|
64
|
+
validate_with_new_style_hash(accept_opaques: false,
|
65
|
+
accept_pointers: false,
|
66
|
+
merge_skip_copy: true,
|
67
|
+
remove_trailing_skips: true)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
x.report("with all options set and keyword arguments") do
|
71
|
+
TIMES.times do
|
72
|
+
validate_with_keyword_arguments(accept_opaques: false,
|
73
|
+
accept_pointers: false,
|
74
|
+
merge_skip_copy: true,
|
75
|
+
remove_trailing_skips: true)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
data/ext/utilrb/extconf.rb
CHANGED
@@ -5,23 +5,7 @@ if try_link("int main() { }", "-module")
|
|
5
5
|
$LDFLAGS += " -module"
|
6
6
|
end
|
7
7
|
|
8
|
-
|
9
|
-
if RUBY_VERSION < "1.9"
|
10
|
-
$CFLAGS += " -DRUBY_IS_18"
|
11
|
-
puts "not building with core source"
|
12
|
-
create_makefile("utilrb/utilrb")
|
13
|
-
else
|
14
|
-
begin
|
15
|
-
require 'debugger/ruby_core_source'
|
16
|
-
hdrs = lambda { try_compile("#include <vm_core.h>") }
|
17
|
-
$CFLAGS += " -DHAS_RUBY_SOURCE"
|
18
|
-
Debugger::RubyCoreSource.create_makefile_with_core(hdrs, "utilrb/utilrb")
|
19
|
-
rescue Exception
|
20
|
-
$CFLAGS.gsub!(/ -DHAS_RUBY_SOURCE/, '')
|
21
|
-
puts "not building with core source"
|
22
|
-
create_makefile("utilrb/utilrb")
|
23
|
-
end
|
24
|
-
end
|
8
|
+
create_makefile("utilrb/utilrb")
|
25
9
|
|
26
10
|
## WORKAROUND a problem with mkmf.rb
|
27
11
|
# It seems that the newest version do define an 'install' target. However, that
|
data/ext/utilrb/utilrb.cc
CHANGED
@@ -28,19 +28,6 @@ static VALUE enumerable_each_uniq(VALUE self)
|
|
28
28
|
return self;
|
29
29
|
}
|
30
30
|
|
31
|
-
/* call-seq:
|
32
|
-
* Kernel.is_singleton?(object)
|
33
|
-
*
|
34
|
-
* Returns true if +self+ is a singleton class
|
35
|
-
*/
|
36
|
-
static VALUE kernel_is_singleton_p(VALUE self)
|
37
|
-
{
|
38
|
-
if (BUILTIN_TYPE(self) == T_CLASS && FL_TEST(self, FL_SINGLETON))
|
39
|
-
return Qtrue;
|
40
|
-
else
|
41
|
-
return Qfalse;
|
42
|
-
}
|
43
|
-
|
44
31
|
static VALUE kernel_is_immediate(VALUE klass, VALUE object)
|
45
32
|
{ return IMMEDIATE_P(object) ? Qtrue : Qfalse; }
|
46
33
|
#endif
|
@@ -53,9 +40,6 @@ static VALUE kernel_crash(VALUE klass)
|
|
53
40
|
}
|
54
41
|
|
55
42
|
extern "C" void Init_value_set();
|
56
|
-
extern "C" void Init_weakref(VALUE mUtilrb);
|
57
|
-
extern "C" void Init_proc();
|
58
|
-
extern "C" void Init_utilrb_readline();
|
59
43
|
|
60
44
|
extern "C" void Init_utilrb()
|
61
45
|
{
|
@@ -63,17 +47,10 @@ extern "C" void Init_utilrb()
|
|
63
47
|
|
64
48
|
#ifndef RUBINIUS
|
65
49
|
rb_define_method(rb_mEnumerable, "each_uniq", RUBY_METHOD_FUNC(enumerable_each_uniq), 0);
|
66
|
-
rb_define_method(rb_mKernel, "is_singleton?", RUBY_METHOD_FUNC(kernel_is_singleton_p), 0);
|
67
|
-
|
68
50
|
rb_define_singleton_method(rb_mKernel, "crash!", RUBY_METHOD_FUNC(kernel_crash), 0);
|
69
51
|
rb_define_singleton_method(rb_mKernel, "immediate?", RUBY_METHOD_FUNC(kernel_is_immediate), 1);
|
70
|
-
|
71
|
-
Init_weakref(mUtilrb);
|
72
52
|
#endif
|
73
53
|
|
74
|
-
Init_proc();
|
75
|
-
|
76
54
|
Init_value_set();
|
77
|
-
Init_utilrb_readline();
|
78
55
|
}
|
79
56
|
|
@@ -1,3 +1,6 @@
|
|
1
|
+
puts "WARN: ColumnFormatter is deprecated, use the tty-table gem which provides"
|
2
|
+
puts "WARN: more functionality in a much nicer API"
|
3
|
+
|
1
4
|
# Displays a set of data into a column-formatted table
|
2
5
|
class ColumnFormatter
|
3
6
|
MARGIN = 1
|
@@ -53,18 +56,18 @@ class ColumnFormatter
|
|
53
56
|
# First, determine the columns width and height, and
|
54
57
|
# convert data into strings
|
55
58
|
data = data.map do |line_data|
|
56
|
-
line_data = line_data.inject({}) do |h, (label,
|
57
|
-
h[label.to_s] =
|
59
|
+
line_data = line_data.inject({}) do |h, (label, value)|
|
60
|
+
h[label.to_s] = value.to_s
|
58
61
|
h
|
59
62
|
end
|
60
63
|
|
61
|
-
line_data.each do |label,
|
64
|
+
line_data.each do |label, value|
|
62
65
|
unless width.has_key?(label)
|
63
66
|
width[label] = label.length
|
64
67
|
end
|
65
68
|
|
66
|
-
if width[label] <
|
67
|
-
width[label] =
|
69
|
+
if width[label] < value.length
|
70
|
+
width[label] = value.length
|
68
71
|
end
|
69
72
|
end
|
70
73
|
end
|
data/lib/utilrb/common.rb
CHANGED
@@ -1,11 +1,8 @@
|
|
1
|
+
require 'utilrb/version'
|
1
2
|
|
2
3
|
# Utilrb is yet another Ruby toolkit, in the spirit of facets. It includes all
|
3
4
|
# the standard class extensions used by www.rock-robotics.org projects.
|
4
5
|
module Utilrb
|
5
|
-
unless defined? Utilrb::VERSION
|
6
|
-
VERSION = "2.0.2.b2"
|
7
|
-
end
|
8
|
-
|
9
6
|
LIB_DIR = File.expand_path(File.dirname(__FILE__))
|
10
7
|
|
11
8
|
unless defined? UTILRB_EXT_MODE
|
@@ -14,8 +11,6 @@ module Utilrb
|
|
14
11
|
STDERR.puts "Utilrb: not loading the C extension"
|
15
12
|
else
|
16
13
|
begin
|
17
|
-
# We need readline
|
18
|
-
require 'readline'
|
19
14
|
require 'utilrb/utilrb'
|
20
15
|
UTILRB_EXT_MODE = true
|
21
16
|
STDERR.puts "Utilrb: loaded C extension" if ENV['UTILRB_EXT_MODE']
|
@@ -2,15 +2,9 @@ require 'utilrb/common'
|
|
2
2
|
require 'enumerator'
|
3
3
|
require 'set'
|
4
4
|
|
5
|
-
enumerator = if defined?(Enumerable::Enumerator)
|
6
|
-
Enumerable::Enumerator
|
7
|
-
else
|
8
|
-
Enumerator
|
9
|
-
end
|
10
|
-
|
11
5
|
# Enumerator object which removes duplicate entries.
|
12
6
|
# See also Object#enum_uniq and Enumerable#each_uniq
|
13
|
-
class UniqEnumerator <
|
7
|
+
class UniqEnumerator < Enumerator
|
14
8
|
# Creates the enumerator on +obj+ using the method +enum_with+ to
|
15
9
|
# enumerate. The method will be called with the arguments in +args+.
|
16
10
|
#
|
@@ -60,7 +54,7 @@ Utilrb.unless_ext do
|
|
60
54
|
# each_uniq { |obj| ... }
|
61
55
|
#
|
62
56
|
# Yields all unique values found in +enum+
|
63
|
-
def each_uniq
|
57
|
+
def each_uniq
|
64
58
|
seen = Set.new
|
65
59
|
each do |obj|
|
66
60
|
if !seen.include?(obj)
|
data/lib/utilrb/event_loop.rb
CHANGED
@@ -74,10 +74,6 @@ module Utilrb
|
|
74
74
|
@event_loop.cancel_timer self
|
75
75
|
end
|
76
76
|
|
77
|
-
def single_shot?
|
78
|
-
@single_shot
|
79
|
-
end
|
80
|
-
|
81
77
|
def stopped?
|
82
78
|
@stopped
|
83
79
|
end
|
@@ -364,7 +360,7 @@ module Utilrb
|
|
364
360
|
raise ArgumentError "no block given" unless block
|
365
361
|
if delay && delay > 0
|
366
362
|
timer = Timer.new(self,delay,true,&block)
|
367
|
-
timer.start
|
363
|
+
timer.start(timer.period, false)
|
368
364
|
else
|
369
365
|
add_event(Event.new(block))
|
370
366
|
end
|
@@ -579,7 +575,7 @@ module Utilrb
|
|
579
575
|
end
|
580
576
|
|
581
577
|
def reraise_error(error)
|
582
|
-
raise error, error.message, error.backtrace + caller(1)
|
578
|
+
raise error, error.message, (error.backtrace || []) + caller(1)
|
583
579
|
end
|
584
580
|
|
585
581
|
# Handles all current events and timers. If a code
|
@@ -594,7 +590,7 @@ module Utilrb
|
|
594
590
|
#copy all work otherwise it would not be allowed to
|
595
591
|
#call any event loop functions from a timer
|
596
592
|
timers,call = @mutex.synchronize do
|
597
|
-
@every_cylce_events.delete_if
|
593
|
+
@every_cylce_events.delete_if(&:ignore?)
|
598
594
|
@every_cylce_events.each do |event|
|
599
595
|
add_event event
|
600
596
|
end
|
@@ -897,7 +893,6 @@ module Utilrb
|
|
897
893
|
|
898
894
|
line_no = __LINE__; str = %Q{
|
899
895
|
def #{ali}(*args, &block)
|
900
|
-
options = Hash.new
|
901
896
|
accessor,error = #{if options[:known_errors]
|
902
897
|
%Q{
|
903
898
|
begin
|
@@ -923,7 +918,7 @@ module Utilrb
|
|
923
918
|
raise error
|
924
919
|
end
|
925
920
|
else
|
926
|
-
work = Proc.new do |*
|
921
|
+
work = Proc.new do |*callback_args|
|
927
922
|
acc,err = #{accessor} # cache accessor
|
928
923
|
if !acc
|
929
924
|
if err
|
@@ -932,7 +927,7 @@ module Utilrb
|
|
932
927
|
raise DesignatedObjectNotFound,'designated object is nil'
|
933
928
|
end
|
934
929
|
else
|
935
|
-
acc.__send__(:#{method}, *
|
930
|
+
acc.__send__(:#{method}, *callback_args, &block)
|
936
931
|
end
|
937
932
|
end
|
938
933
|
callback = #{filter ? "block.to_proc.arity == 2 ? Proc.new { |r,e| block.call(#{filter}(r),e)} : Proc.new {|r| block.call(#{filter}(r))}" : "block"}
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'utilrb/common'
|
2
|
-
require 'utilrb/object/singleton_class'
|
3
2
|
require 'utilrb/kernel/with_module'
|
4
3
|
|
5
4
|
module Kernel
|
@@ -67,7 +66,7 @@ module Kernel
|
|
67
66
|
|
68
67
|
filtered_backtrace = backtrace[0, backtrace.size - our_frame_pos].
|
69
68
|
map do |line|
|
70
|
-
line.gsub
|
69
|
+
line = line.gsub(/:in `.*dsl.*'/, '')
|
71
70
|
if line =~ /load_dsl_file.*(method_missing|send)/
|
72
71
|
next
|
73
72
|
end
|
@@ -1,6 +1,19 @@
|
|
1
1
|
require 'utilrb/hash/to_sym_keys'
|
2
2
|
require 'utilrb/hash/slice'
|
3
3
|
module Kernel
|
4
|
+
def filter_options_handle_single_entry(known_options, options, key)
|
5
|
+
key = key.to_sym
|
6
|
+
if options.has_key?(key)
|
7
|
+
known_options[key] = options.delete(key)
|
8
|
+
false
|
9
|
+
elsif options.has_key?(key_s = key.to_s)
|
10
|
+
known_options[key] = options.delete(key_s)
|
11
|
+
false
|
12
|
+
else
|
13
|
+
true
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
4
17
|
# Partitions an option hash between known arguments and unknown
|
5
18
|
# arguments, with default value support. All option keys are
|
6
19
|
# converted to symbols for consistency.
|
@@ -17,44 +30,27 @@ module Kernel
|
|
17
30
|
# filter_options(nil, known_options) -> default_options, {}
|
18
31
|
#
|
19
32
|
def filter_options(options, *user_option_spec)
|
20
|
-
|
33
|
+
options = options.dup
|
34
|
+
known_options = Hash.new
|
21
35
|
user_option_spec.each do |opt|
|
22
36
|
if opt.respond_to?(:to_hash)
|
23
|
-
|
37
|
+
opt.each do |key, value|
|
38
|
+
if filter_options_handle_single_entry(known_options, options, key)
|
39
|
+
if !value.nil?
|
40
|
+
known_options[key.to_sym] = value
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
24
44
|
elsif opt.respond_to?(:to_ary)
|
25
45
|
opt.each do |key|
|
26
|
-
|
46
|
+
filter_options_handle_single_entry(known_options, options, key)
|
27
47
|
end
|
28
48
|
else
|
29
|
-
|
49
|
+
filter_options_handle_single_entry(known_options, options, opt)
|
30
50
|
end
|
31
51
|
end
|
32
52
|
|
33
|
-
|
34
|
-
options = options.dup
|
35
|
-
options.delete_if do |key, value|
|
36
|
-
if !key.respond_to?(:to_sym)
|
37
|
-
unknown_options[key] = value
|
38
|
-
true
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
options = (options.to_hash || Hash.new).to_sym_keys
|
43
|
-
# cannot use #to_sym_keys as option_spec can be an array
|
44
|
-
option_spec = option_spec.inject({}) { |h, (k, v)| h[k.to_sym] = v; h }
|
45
|
-
|
46
|
-
unknown_options.merge!(options.slice(*(options.keys - option_spec.keys)))
|
47
|
-
known_options = options.slice(*option_spec.keys)
|
48
|
-
|
49
|
-
# Set default values defined in the spec
|
50
|
-
option_spec.each_key do |k|
|
51
|
-
value = option_spec[k]
|
52
|
-
if !known_options.has_key?(k) && !value.nil?
|
53
|
-
known_options[k] ||= value
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
return *[known_options, unknown_options]
|
53
|
+
return *[known_options, options]
|
58
54
|
end
|
59
55
|
|
60
56
|
# Normalizes all keys in the given option hash to symbol and returns the
|