facets 2.7.0 → 2.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY.rdoc +135 -294
- data/MANIFEST +40 -91
- data/NOTES +1 -1
- data/README.rdoc +10 -8
- data/Rakefile +11 -34
- data/demo/{hook.rd → hook.rdoc} +2 -0
- data/demo/{scenario_require.rd → scenario_require.rdoc} +3 -0
- data/lib/core/facets-live.rb +7 -5
- data/lib/core/facets.rb +379 -359
- data/lib/core/facets/array/conjoin.rb +2 -2
- data/lib/core/facets/array/pad.rb +1 -1
- data/lib/core/facets/array/recursively.rb +2 -2
- data/lib/core/facets/array/splice.rb +1 -1
- data/lib/core/facets/binding/caller.rb +2 -4
- data/lib/core/facets/comparable/comparable.rb +2 -2
- data/lib/core/facets/dir/ascend.rb +3 -0
- data/lib/core/facets/dir/recurse.rb +4 -0
- data/lib/core/facets/duplicable.rb +6 -8
- data/lib/core/facets/enumerable/count.rb +22 -13
- data/lib/core/facets/enumerable/map_detect.rb +28 -0
- data/lib/core/facets/enumerable/mash.rb +13 -5
- data/lib/core/facets/enumerable/per.rb +3 -1
- data/lib/core/facets/hash/count.rb +14 -0
- data/lib/core/facets/hash/data.rb +14 -0
- data/lib/core/facets/kernel/__method__.rb +1 -1
- data/lib/core/facets/kernel/d.rb +9 -8
- data/lib/core/facets/kernel/eigenclass.rb +20 -0
- data/lib/core/facets/kernel/extend.rb +10 -0
- data/lib/core/facets/kernel/instance_class.rb +1 -0
- data/lib/core/facets/kernel/instance_variables.rb +6 -6
- data/lib/core/facets/kernel/meta_alias.rb +18 -0
- data/lib/core/facets/kernel/meta_class.rb +17 -0
- data/lib/core/facets/kernel/meta_def.rb +18 -0
- data/lib/core/facets/kernel/meta_eval.rb +18 -0
- data/lib/core/facets/kernel/object_hexid.rb +21 -6
- data/lib/core/facets/kernel/object_state.rb +4 -2
- data/lib/core/facets/kernel/populate.rb +3 -1
- data/lib/core/facets/kernel/with.rb +1 -1
- data/lib/core/facets/metaid.rb +6 -93
- data/lib/core/facets/module/class_def.rb +2 -0
- data/lib/core/facets/module/extend.rb +10 -11
- data/lib/core/facets/module/is.rb +5 -5
- data/lib/core/facets/module/module_def.rb +31 -0
- data/lib/core/facets/string/camelcase.rb +14 -12
- data/lib/core/facets/string/cleanlines.rb +35 -0
- data/lib/core/facets/string/edit_distance.rb +62 -0
- data/lib/core/facets/string/indent.rb +86 -4
- data/lib/core/facets/string/index_all.rb +24 -0
- data/lib/core/facets/string/lines.rb +3 -6
- data/lib/core/facets/string/margin.rb +2 -1
- data/lib/core/facets/string/newlines.rb +35 -0
- data/lib/core/facets/string/op_div.rb +14 -0
- data/lib/core/facets/string/range.rb +2 -22
- data/lib/core/facets/string/range_all.rb +1 -0
- data/lib/core/facets/string/range_of_line.rb +1 -0
- data/lib/core/facets/string/similarity.rb +92 -0
- data/lib/core/facets/string/start_with.rb +6 -6
- data/lib/core/facets/string/titlecase.rb +1 -1
- data/lib/more/facets/basicobject.rb +16 -15
- data/lib/more/facets/blankslate.rb +8 -0
- data/lib/more/facets/class_extend.rb +126 -1
- data/lib/more/facets/continuation.rb +53 -54
- data/lib/more/facets/dictionary.rb +9 -63
- data/lib/more/facets/erb.rb +63 -0
- data/lib/more/facets/filelist.rb +5 -5
- data/lib/more/facets/hashbuilder.rb +101 -0
- data/lib/more/facets/inheritor.rb +36 -45
- data/lib/more/facets/ini.rb +267 -0
- data/lib/more/facets/instance_eval.rb +4 -4
- data/lib/more/facets/ioredirect.rb +7 -60
- data/lib/more/facets/linkedlist.rb +195 -0
- data/lib/more/facets/matcher.rb +140 -0
- data/lib/more/facets/memoizer.rb +64 -0
- data/lib/more/facets/methodspace.rb +9 -4
- data/lib/more/facets/module/class_extend.rb +2 -121
- data/lib/more/facets/ostruct.rb +9 -9
- data/lib/more/facets/pathlist.rb +1 -9
- data/lib/more/facets/pathname.rb +11 -4
- data/lib/more/facets/plugin_manager.rb +50 -0
- data/lib/more/facets/random.rb +25 -3
- data/lib/more/facets/roman.rb +174 -0
- data/lib/more/facets/semaphore.rb +92 -0
- data/lib/more/facets/shellwords.rb +21 -48
- data/lib/more/facets/succ.rb +1 -1
- data/meta/{modified → released} +0 -0
- data/meta/repository +1 -0
- data/meta/suite +1 -0
- data/meta/version +1 -1
- data/script/conflicts +63 -0
- data/script/methods +49 -0
- data/test/core/binding/test_caller.rb +11 -4
- data/test/core/enumerable/test_count.rb +19 -10
- data/test/core/enumerable/test_map_detect.rb +75 -0
- data/test/core/enumerable/test_take.rb +1 -1
- data/test/core/kernel/test_object_hexid.rb +2 -1
- data/test/core/proc/test_to_method.rb +1 -1
- data/test/core/string/test_cleanlines.rb +11 -0
- data/test/core/string/test_indent.rb +66 -4
- data/test/core/string/test_lines.rb +2 -1
- data/test/core/string/test_newlines.rb +13 -0
- data/test/core/time/test_change.rb +1 -1
- data/test/core/time/test_stamp.rb +4 -7
- data/test/core/unboundmethod/test_name.rb +1 -1
- data/test/more/test_basicobject.rb +1 -20
- data/test/more/test_class_extend.rb +7 -0
- data/test/more/test_continuation.rb +8 -6
- data/test/more/test_inheritor.rb +12 -6
- data/test/more/test_random.rb +19 -10
- data/test/more/test_shellwords.rb +33 -0
- metadata +60 -31
- data/TODO +0 -5
- data/doc/README.core +0 -102
- data/doc/README.more +0 -61
- data/doc/manual/about.rb +0 -47
- data/doc/manual/annotations.rdoc +0 -60
- data/doc/manual/associations.rdoc +0 -55
- data/doc/manual/blockups.rdoc +0 -101
- data/doc/manual/capsule.rdoc +0 -34
- data/doc/manual/command.rdoc +0 -177
- data/doc/manual/core.rdoc +0 -37
- data/doc/manual/faq.rdoc +0 -32
- data/doc/manual/typecast.html +0 -112
- data/lib/more/facets/capsule.rb +0 -258
- data/lib/more/facets/coroutine.rb +0 -159
- data/lib/more/facets/enumerablepass.rb +0 -3
- data/lib/more/facets/fileable.rb +0 -162
- data/lib/more/facets/progressbar.rb +0 -253
- data/lib/more/facets/recorder.rb +0 -108
- data/meta/releases +0 -14
- data/test/more/test_coroutine.rb +0 -46
data/lib/more/facets/recorder.rb
DELETED
@@ -1,108 +0,0 @@
|
|
1
|
-
# = Recorder
|
2
|
-
#
|
3
|
-
# == Synopsis
|
4
|
-
#
|
5
|
-
# Recorder is similar essentially a method probe. It records everthing
|
6
|
-
# that happens to it, building an internal parse tree. You can then
|
7
|
-
# pass a substitute object and apply the recoding to it. Or you can
|
8
|
-
# utilize the parse tree.
|
9
|
-
#
|
10
|
-
# The only limitation of Recorder is with special operators, like if, &&, ||, etc.
|
11
|
-
# Since they are not true methods they can't be recorded. (Too bad for Ruby.)
|
12
|
-
#
|
13
|
-
# == Usage
|
14
|
-
#
|
15
|
-
# class Z
|
16
|
-
# def name ; 'George' ; end
|
17
|
-
# def age ; 12 ; end
|
18
|
-
# end
|
19
|
-
#
|
20
|
-
# z = Z.new
|
21
|
-
#
|
22
|
-
# r = Recorder.new
|
23
|
-
# q = proc { |x| (x.name == 'George') & (x.age > 10) }
|
24
|
-
# x = q[r]
|
25
|
-
# x.__call__(z)
|
26
|
-
#
|
27
|
-
# produces
|
28
|
-
#
|
29
|
-
# true
|
30
|
-
#
|
31
|
-
# == Authors
|
32
|
-
#
|
33
|
-
# * Thomas Sawyer
|
34
|
-
#
|
35
|
-
# == Copying
|
36
|
-
#
|
37
|
-
# Copyright (c) 2006 Thomas Sawyer
|
38
|
-
#
|
39
|
-
# Ruby License
|
40
|
-
#
|
41
|
-
# This module is free software. You may use, modify, and/or redistribute this
|
42
|
-
# software under the same terms as Ruby.
|
43
|
-
#
|
44
|
-
# This program is distributed in the hope that it will be useful, but WITHOUT
|
45
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
46
|
-
# FOR A PARTICULAR PURPOSE.
|
47
|
-
|
48
|
-
require 'facets/kernel/object_class'
|
49
|
-
|
50
|
-
# = Recorder
|
51
|
-
#
|
52
|
-
# Recorder is similar essentially a method probe. It records everthing
|
53
|
-
# that happens to it, building an internal parse tree. You can then
|
54
|
-
# pass a substitute object and apply the recoding to it. Or you can
|
55
|
-
# utilize the parse tree.
|
56
|
-
#
|
57
|
-
# The only limitation of Recorder is with special operators, like if, &&, ||, etc.
|
58
|
-
# Since they are not true methods they can't be recorded. (Too bad for Ruby.)
|
59
|
-
#
|
60
|
-
# class Z
|
61
|
-
# def name ; 'George' ; end
|
62
|
-
# def age ; 12 ; end
|
63
|
-
# end
|
64
|
-
#
|
65
|
-
# z = Z.new
|
66
|
-
#
|
67
|
-
# r = Recorder.new
|
68
|
-
# q = proc { |x| (x.name == 'George') & (x.age > 10) }
|
69
|
-
# x = q[r]
|
70
|
-
# x.__call__(z)
|
71
|
-
#
|
72
|
-
# produces
|
73
|
-
#
|
74
|
-
# true
|
75
|
-
#
|
76
|
-
class Recorder
|
77
|
-
|
78
|
-
# Privatize all kernel methods.
|
79
|
-
|
80
|
-
instance_methods.each{ |m| private(m) unless /^__/ =~ m.to_s }
|
81
|
-
|
82
|
-
#
|
83
|
-
def initialize( msg=nil )
|
84
|
-
@msg = msg
|
85
|
-
end
|
86
|
-
|
87
|
-
def inspect
|
88
|
-
"<Recorder #{@msg.inspect}>"
|
89
|
-
end
|
90
|
-
|
91
|
-
def __call__( orig )
|
92
|
-
return orig unless @msg
|
93
|
-
|
94
|
-
sym = @msg[0]
|
95
|
-
args = @msg[1..-1].collect do |a|
|
96
|
-
Recorder === a ? a.__call__(orig) : a
|
97
|
-
end
|
98
|
-
obj = args.shift
|
99
|
-
|
100
|
-
obj.__send__( sym, *args )
|
101
|
-
end
|
102
|
-
|
103
|
-
def method_missing( sym, *args, &blk )
|
104
|
-
object_class.new( [ sym, self, *args ] )
|
105
|
-
end
|
106
|
-
|
107
|
-
end
|
108
|
-
|
data/meta/releases
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
facets 2.4.4 stable (2008-09-01)
|
2
|
-
facets 2.4.3 stable (2008-08-14)
|
3
|
-
facets 2.4.2 stable (2008-08-12)
|
4
|
-
facets 2.4.1 stable (2008-04-03)
|
5
|
-
facets 2.4.0 stable (2008-03-24)
|
6
|
-
facets 2.3.0 stable (2008-02-01)
|
7
|
-
facets 2.2.1 stable (2007-12-22)
|
8
|
-
facets 2.2.0 stable (2007-12-13)
|
9
|
-
facets 2.1.3 stable (2007-11-28)
|
10
|
-
facets 2.1.2 stable (2007-11-22)
|
11
|
-
facets 2.1.1 stable (2007-11-16)
|
12
|
-
facets 2.1.0 stable (2007-11-10)
|
13
|
-
facets 2.0.5 stable (2007-11-07)
|
14
|
-
|
data/test/more/test_coroutine.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
# Test facets/coroutine.rb
|
2
|
-
|
3
|
-
require 'facets/coroutine.rb'
|
4
|
-
require 'test/unit'
|
5
|
-
|
6
|
-
class TC_Coroutine < Test::Unit::TestCase
|
7
|
-
|
8
|
-
def test_run
|
9
|
-
assert_nothing_raised {
|
10
|
-
|
11
|
-
count = 100
|
12
|
-
input = (1..count).map { (rand * 10000).round.to_f / 100 }
|
13
|
-
|
14
|
-
@producer = Coroutine.new do |me|
|
15
|
-
loop do
|
16
|
-
1.upto(6) do
|
17
|
-
me[:last_input] = input.shift
|
18
|
-
me.resume(@printer)
|
19
|
-
end
|
20
|
-
input.shift # discard every seventh input number
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
@printer = Coroutine.new do |me|
|
25
|
-
loop do
|
26
|
-
1.upto(8) do
|
27
|
-
me.resume(@producer)
|
28
|
-
if @producer[:last_input]
|
29
|
-
@producer[:last_input] = nil
|
30
|
-
end
|
31
|
-
me.resume(@controller)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
@controller = Coroutine.new do |me|
|
37
|
-
until input.empty? do
|
38
|
-
me.resume(@printer)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
@controller.run
|
42
|
-
|
43
|
-
}
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|