File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -89,6 +89,8 @@ Changes:
8989 * Redefine ` Comparable#bound ` as alias for ` clamp ` .
9090 * Add ` Dir.find ` as convenience wrapper around Ruby's ` Find.find ` .
9191 * Deprecate ` Dir.recurse ` / ` Dir.ls_r ` (use ` Dir.find ` or ` Find.find ` instead).
92+ * Deprecate ` Proc#compose ` and ` Proc#* ` (use ` Proc#<< ` for right-to-left composition, Ruby 2.6+).
93+ * Fix dead requires for removed ` kernel/singleton_class ` in Proc and Kernel.
9294 * Remove misplaced ` applique/file_helpers ` from core (test infrastructure).
9395 * Drop unused ` test_files ` directive from gemspec. (PR #301 )
9496
Original file line number Diff line number Diff line change 4747require_relative 'kernel/object_class.rb'
4848require_relative 'kernel/object_hexid.rb'
4949require_relative 'kernel/object_send.rb'
50- require_relative 'kernel/p.rb'
5150require_relative 'kernel/presence.rb'
5251require_relative 'kernel/present.rb'
5352require_relative 'kernel/qua_class.rb'
5655require_relative 'kernel/returning.rb'
5756require_relative 'kernel/silence.rb'
5857require_relative 'kernel/silence_warnings.rb'
59- require_relative 'kernel/singleton_class.rb'
6058require_relative 'kernel/super_method.rb'
6159require_relative 'kernel/tap.rb'
6260require_relative 'kernel/temporarily.rb'
6967#require_relative 'kernel/y.rb' # uncommon
7068require_relative 'kernel/yes.rb'
7169require_relative 'kernel/__class__.rb'
72- require_relative 'kernel/__dir__.rb'
70+ # require_relative 'kernel/__dir__.rb' # removed, use Ruby's built-in __dir__
7371require_relative 'kernel/__get__.rb'
7472require_relative 'kernel/__set__.rb'
7573
Original file line number Diff line number Diff line change 1- require 'facets/kernel/singleton_class'
2-
31class Proc
42
53 # Bind a Proc to an object returning a Method.
Original file line number Diff line number Diff line change 11class Proc
22
3- # Returns a new proc that is the functional
4- # composition of two procs, in order.
5- #
6- # a = lambda { |x| x + 4 }
7- # b = lambda { |y| y / 2 }
8- #
9- # a.compose(b).call(4) #=> 6
10- # b.compose(a).call(4) #=> 4
11- #
12- # CREDIT: Dave
13-
3+ # @deprecated Use Proc#>> or Proc#<< instead (built-in since Ruby 2.6).
144 def compose ( g )
15- raise ArgumentError , "arity count mismatch" unless arity == g . arity
16- lambda { |* a | self [ * g [ * a ] ] }
5+ warn "Proc#compose is deprecated. Use Proc#<< instead (right-to-left composition)." , uplevel : 1
6+ self << g
177 end
188
19- # Operator for Proc#compose and Integer#times_collect/of.
20- #
21- # a = lambda { |x| x + 4 }
22- # b = lambda { |y| y / 2 }
23- #
24- # (a * b).call(4) #=> 6
25- # (b * a).call(4) #=> 4
26- #
27- # CREDIT: Dave
28-
9+ # @deprecated Use Proc#>> or Proc#<< for composition (built-in since Ruby 2.6).
2910 def *( x )
30- if Integer === x
31- # collect times
11+ warn "Proc#* is deprecated. Use Proc#<< for composition (right-to-left)." , uplevel : 1
12+ if Integer === x
3213 c = [ ]
3314 x . times { |i | c << call ( i ) }
3415 c
3516 else
36- # compose procs
37- lambda { |*a | self [ x [ *a ] ] }
17+ self << x
3818 end
3919 end
4020
4121end
42-
Original file line number Diff line number Diff line change 11require 'facets/proc/bind'
2- require 'facets/kernel/singleton_class'
32
43class Proc
54
Original file line number Diff line number Diff line change 11class Proc
22
3- # Use a Proc as an observable.
3+ # Alias for #call, allowing a Proc to be used as an Observer.
4+ #
5+ # Ruby's Observable module (now the `observer` gem, removed from
6+ # stdlib in Ruby 3.2) calls #update on observers. This alias
7+ # lets a Proc serve as an observer directly.
8+ #
9+ # TODO: Consider submitting a PR to the observer gem to include
10+ # this extension there instead.
411 #
512 # CREDIT: Tim Pease
613
You can’t perform that action at this time.
0 commit comments