facets 2.7.0 → 2.8.0

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.
Files changed (130) hide show
  1. data/HISTORY.rdoc +135 -294
  2. data/MANIFEST +40 -91
  3. data/NOTES +1 -1
  4. data/README.rdoc +10 -8
  5. data/Rakefile +11 -34
  6. data/demo/{hook.rd → hook.rdoc} +2 -0
  7. data/demo/{scenario_require.rd → scenario_require.rdoc} +3 -0
  8. data/lib/core/facets-live.rb +7 -5
  9. data/lib/core/facets.rb +379 -359
  10. data/lib/core/facets/array/conjoin.rb +2 -2
  11. data/lib/core/facets/array/pad.rb +1 -1
  12. data/lib/core/facets/array/recursively.rb +2 -2
  13. data/lib/core/facets/array/splice.rb +1 -1
  14. data/lib/core/facets/binding/caller.rb +2 -4
  15. data/lib/core/facets/comparable/comparable.rb +2 -2
  16. data/lib/core/facets/dir/ascend.rb +3 -0
  17. data/lib/core/facets/dir/recurse.rb +4 -0
  18. data/lib/core/facets/duplicable.rb +6 -8
  19. data/lib/core/facets/enumerable/count.rb +22 -13
  20. data/lib/core/facets/enumerable/map_detect.rb +28 -0
  21. data/lib/core/facets/enumerable/mash.rb +13 -5
  22. data/lib/core/facets/enumerable/per.rb +3 -1
  23. data/lib/core/facets/hash/count.rb +14 -0
  24. data/lib/core/facets/hash/data.rb +14 -0
  25. data/lib/core/facets/kernel/__method__.rb +1 -1
  26. data/lib/core/facets/kernel/d.rb +9 -8
  27. data/lib/core/facets/kernel/eigenclass.rb +20 -0
  28. data/lib/core/facets/kernel/extend.rb +10 -0
  29. data/lib/core/facets/kernel/instance_class.rb +1 -0
  30. data/lib/core/facets/kernel/instance_variables.rb +6 -6
  31. data/lib/core/facets/kernel/meta_alias.rb +18 -0
  32. data/lib/core/facets/kernel/meta_class.rb +17 -0
  33. data/lib/core/facets/kernel/meta_def.rb +18 -0
  34. data/lib/core/facets/kernel/meta_eval.rb +18 -0
  35. data/lib/core/facets/kernel/object_hexid.rb +21 -6
  36. data/lib/core/facets/kernel/object_state.rb +4 -2
  37. data/lib/core/facets/kernel/populate.rb +3 -1
  38. data/lib/core/facets/kernel/with.rb +1 -1
  39. data/lib/core/facets/metaid.rb +6 -93
  40. data/lib/core/facets/module/class_def.rb +2 -0
  41. data/lib/core/facets/module/extend.rb +10 -11
  42. data/lib/core/facets/module/is.rb +5 -5
  43. data/lib/core/facets/module/module_def.rb +31 -0
  44. data/lib/core/facets/string/camelcase.rb +14 -12
  45. data/lib/core/facets/string/cleanlines.rb +35 -0
  46. data/lib/core/facets/string/edit_distance.rb +62 -0
  47. data/lib/core/facets/string/indent.rb +86 -4
  48. data/lib/core/facets/string/index_all.rb +24 -0
  49. data/lib/core/facets/string/lines.rb +3 -6
  50. data/lib/core/facets/string/margin.rb +2 -1
  51. data/lib/core/facets/string/newlines.rb +35 -0
  52. data/lib/core/facets/string/op_div.rb +14 -0
  53. data/lib/core/facets/string/range.rb +2 -22
  54. data/lib/core/facets/string/range_all.rb +1 -0
  55. data/lib/core/facets/string/range_of_line.rb +1 -0
  56. data/lib/core/facets/string/similarity.rb +92 -0
  57. data/lib/core/facets/string/start_with.rb +6 -6
  58. data/lib/core/facets/string/titlecase.rb +1 -1
  59. data/lib/more/facets/basicobject.rb +16 -15
  60. data/lib/more/facets/blankslate.rb +8 -0
  61. data/lib/more/facets/class_extend.rb +126 -1
  62. data/lib/more/facets/continuation.rb +53 -54
  63. data/lib/more/facets/dictionary.rb +9 -63
  64. data/lib/more/facets/erb.rb +63 -0
  65. data/lib/more/facets/filelist.rb +5 -5
  66. data/lib/more/facets/hashbuilder.rb +101 -0
  67. data/lib/more/facets/inheritor.rb +36 -45
  68. data/lib/more/facets/ini.rb +267 -0
  69. data/lib/more/facets/instance_eval.rb +4 -4
  70. data/lib/more/facets/ioredirect.rb +7 -60
  71. data/lib/more/facets/linkedlist.rb +195 -0
  72. data/lib/more/facets/matcher.rb +140 -0
  73. data/lib/more/facets/memoizer.rb +64 -0
  74. data/lib/more/facets/methodspace.rb +9 -4
  75. data/lib/more/facets/module/class_extend.rb +2 -121
  76. data/lib/more/facets/ostruct.rb +9 -9
  77. data/lib/more/facets/pathlist.rb +1 -9
  78. data/lib/more/facets/pathname.rb +11 -4
  79. data/lib/more/facets/plugin_manager.rb +50 -0
  80. data/lib/more/facets/random.rb +25 -3
  81. data/lib/more/facets/roman.rb +174 -0
  82. data/lib/more/facets/semaphore.rb +92 -0
  83. data/lib/more/facets/shellwords.rb +21 -48
  84. data/lib/more/facets/succ.rb +1 -1
  85. data/meta/{modified → released} +0 -0
  86. data/meta/repository +1 -0
  87. data/meta/suite +1 -0
  88. data/meta/version +1 -1
  89. data/script/conflicts +63 -0
  90. data/script/methods +49 -0
  91. data/test/core/binding/test_caller.rb +11 -4
  92. data/test/core/enumerable/test_count.rb +19 -10
  93. data/test/core/enumerable/test_map_detect.rb +75 -0
  94. data/test/core/enumerable/test_take.rb +1 -1
  95. data/test/core/kernel/test_object_hexid.rb +2 -1
  96. data/test/core/proc/test_to_method.rb +1 -1
  97. data/test/core/string/test_cleanlines.rb +11 -0
  98. data/test/core/string/test_indent.rb +66 -4
  99. data/test/core/string/test_lines.rb +2 -1
  100. data/test/core/string/test_newlines.rb +13 -0
  101. data/test/core/time/test_change.rb +1 -1
  102. data/test/core/time/test_stamp.rb +4 -7
  103. data/test/core/unboundmethod/test_name.rb +1 -1
  104. data/test/more/test_basicobject.rb +1 -20
  105. data/test/more/test_class_extend.rb +7 -0
  106. data/test/more/test_continuation.rb +8 -6
  107. data/test/more/test_inheritor.rb +12 -6
  108. data/test/more/test_random.rb +19 -10
  109. data/test/more/test_shellwords.rb +33 -0
  110. metadata +60 -31
  111. data/TODO +0 -5
  112. data/doc/README.core +0 -102
  113. data/doc/README.more +0 -61
  114. data/doc/manual/about.rb +0 -47
  115. data/doc/manual/annotations.rdoc +0 -60
  116. data/doc/manual/associations.rdoc +0 -55
  117. data/doc/manual/blockups.rdoc +0 -101
  118. data/doc/manual/capsule.rdoc +0 -34
  119. data/doc/manual/command.rdoc +0 -177
  120. data/doc/manual/core.rdoc +0 -37
  121. data/doc/manual/faq.rdoc +0 -32
  122. data/doc/manual/typecast.html +0 -112
  123. data/lib/more/facets/capsule.rb +0 -258
  124. data/lib/more/facets/coroutine.rb +0 -159
  125. data/lib/more/facets/enumerablepass.rb +0 -3
  126. data/lib/more/facets/fileable.rb +0 -162
  127. data/lib/more/facets/progressbar.rb +0 -253
  128. data/lib/more/facets/recorder.rb +0 -108
  129. data/meta/releases +0 -14
  130. data/test/more/test_coroutine.rb +0 -46
@@ -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
-
@@ -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
-
@@ -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