facets 3.2.2 → 4.0.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.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +44 -15
- data/HISTORY.md +99 -0
- data/LICENSE.txt +1 -1
- data/README.md +50 -219
- data/lib/core/facets/array/nonuniq.rb +2 -2
- data/lib/core/facets/array/standard_deviation.rb +1 -1
- data/lib/core/facets/array/uniq_by.rb +5 -1
- data/lib/core/facets/array.rb +5 -1
- data/lib/core/facets/binding/self.rb +2 -1
- data/lib/core/facets/comparable/clip.rb +2 -1
- data/lib/core/facets/dir/recurse.rb +17 -4
- data/lib/core/facets/enumerable/compact_map.rb +1 -1
- data/lib/core/facets/enumerable/defer.rb +1 -1
- data/lib/core/facets/enumerable/frequency.rb +1 -1
- data/lib/core/facets/enumerable/hashify.rb +2 -2
- data/lib/core/facets/enumerable/hinge.rb +1 -1
- data/lib/core/facets/enumerable/map_with_index.rb +1 -1
- data/lib/core/facets/enumerable/mash.rb +2 -1
- data/lib/core/facets/enumerable/uniq_by.rb +3 -1
- data/lib/core/facets/essentials.rb +4 -1
- data/lib/core/facets/exception/error_print.rb +4 -2
- data/lib/core/facets/file/null.rb +2 -1
- data/lib/core/facets/file/read_binary.rb +2 -1
- data/lib/core/facets/file.rb +1 -1
- data/lib/core/facets/hash/fetch_nested.rb +2 -1
- data/lib/core/facets/hash/update_keys.rb +2 -1
- data/lib/core/facets/hash/update_values.rb +2 -1
- data/lib/core/facets/hash.rb +6 -4
- data/lib/core/facets/kernel/eigenclass.rb +2 -1
- data/lib/core/facets/kernel/extension.rb +2 -1
- data/lib/core/facets/kernel/instance_class.rb +2 -1
- data/lib/core/facets/kernel/instance_send.rb +2 -1
- data/lib/core/facets/kernel/like.rb +7 -2
- data/lib/core/facets/kernel/load_relative.rb +2 -1
- data/lib/core/facets/kernel/memo.rb +2 -1
- data/lib/core/facets/kernel/meta.rb +1 -1
- data/lib/core/facets/kernel/object_class.rb +2 -1
- data/lib/core/facets/kernel/object_send.rb +2 -1
- data/lib/core/facets/kernel/qua_class.rb +2 -1
- data/lib/core/facets/kernel/returning.rb +3 -1
- data/lib/core/facets/kernel/silence.rb +38 -30
- data/lib/core/facets/kernel/tee.rb +3 -0
- data/lib/core/facets/kernel/try.rb +25 -14
- data/lib/core/facets/kernel/with.rb +15 -9
- data/lib/core/facets/kernel.rb +1 -1
- data/lib/core/facets/module/alias_method_chain.rb +3 -1
- data/lib/core/facets/module/alias_module_function.rb +4 -1
- data/lib/core/facets/module/can.rb +2 -1
- data/lib/core/facets/objectspace/op_fetch.rb +2 -1
- data/lib/core/facets/proc/compose.rb +4 -2
- data/lib/core/facets/rails_bridge.rb +27 -0
- data/lib/core/facets/string/camelcase.rb +6 -0
- data/lib/core/facets/string/similarity.rb +3 -2
- data/lib/core/facets/struct/attributes.rb +1 -1
- data/lib/core/facets/time/to_time.rb +7 -2
- data/lib/core/facets/time/trunc.rb +2 -1
- data/lib/core/facets/unboundmethod/arguments.rb +1 -1
- data/lib/core/facets/version.rb +1 -1
- data/lib/rails/facets/hash/to_options.rb +14 -0
- data/lib/{core → rails}/facets/module/mattr.rb +30 -30
- data/lib/standard/facets/cloneable.rb +2 -1
- data/lib/standard/facets/continuation.rb +2 -1
- data/lib/standard/facets/enumargs.rb +14 -2
- data/lib/standard/facets/getoptlong.rb +2 -1
- data/lib/standard/facets/interval.rb +4 -3
- data/lib/standard/facets/load_monitor.rb +2 -1
- data/lib/standard/facets/pathname/null.rb +2 -1
- data/lib/standard/facets/random.rb +8 -4
- metadata +14 -12
- data/lib/core/facets/hash/to_options.rb +0 -1
- /data/lib/{core → rails}/facets/array/extract_options.rb +0 -0
- /data/lib/{core → rails}/facets/cattr.rb +0 -0
- /data/lib/{core → rails}/facets/class/cattr.rb +0 -0
- /data/lib/{standard → rails}/facets/date.rb +0 -0
- /data/lib/{core → rails}/facets/file/atomic_write.rb +0 -0
- /data/lib/{core → rails}/facets/hash/slice.rb +0 -0
- /data/lib/{core → rails}/facets/hash/stringify_keys.rb +0 -0
- /data/lib/{core → rails}/facets/hash/symbolize_keys.rb +0 -0
- /data/lib/{core → rails}/facets/module/cattr.rb +0 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module Facets
|
|
2
|
+
|
|
3
|
+
# Until 2027-09-30, `require 'facets'` still provides a few Rails-compatible
|
|
4
|
+
# methods that now live in lib/rails. Each is defined here as a stub that
|
|
5
|
+
# warns on first use, loads the real file (which replaces the stub), and
|
|
6
|
+
# retries the call. Requiring the file directly skips the stub and the
|
|
7
|
+
# warning. Methods that are already defined, e.g. by ActiveSupport, are
|
|
8
|
+
# left alone.
|
|
9
|
+
#
|
|
10
|
+
# Facets.rails_bridge(Hash, 'facets/hash/slice', :slice!)
|
|
11
|
+
#
|
|
12
|
+
def self.rails_bridge(owner, file, *names)
|
|
13
|
+
names.each do |name|
|
|
14
|
+
next if owner.method_defined?(name)
|
|
15
|
+
owner.send(:define_method, name) do |*args, &block|
|
|
16
|
+
warn "#{owner}##{name} will no longer be loaded by `require 'facets'` after 2027-09-30. " \
|
|
17
|
+
"Add `require '#{file}'` to keep using it.", uplevel: 1
|
|
18
|
+
require file
|
|
19
|
+
if owner.instance_method(name).source_location&.first == __FILE__
|
|
20
|
+
raise NoMethodError, "#{file} did not define #{owner}##{name}"
|
|
21
|
+
end
|
|
22
|
+
__send__(name, *args, &block)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
end
|
|
@@ -52,8 +52,11 @@ class String
|
|
|
52
52
|
#
|
|
53
53
|
# @deprecated
|
|
54
54
|
# Use `#camelcase(:upper)` instead.
|
|
55
|
+
# Scheduled for removal after 2027-09-30.
|
|
55
56
|
#
|
|
56
57
|
def upper_camelcase(*separators)
|
|
58
|
+
warn "String#upper_camelcase is deprecated. Use String#camelcase(:upper) instead. " \
|
|
59
|
+
"It will be removed after 2027-09-30.", uplevel: 1
|
|
57
60
|
camelcase(:upper, *separators)
|
|
58
61
|
end
|
|
59
62
|
|
|
@@ -64,8 +67,11 @@ class String
|
|
|
64
67
|
#
|
|
65
68
|
# @deprecated
|
|
66
69
|
# Use `#camelcase(:lower)` instead.
|
|
70
|
+
# Scheduled for removal after 2027-09-30.
|
|
67
71
|
#
|
|
68
72
|
def lower_camelcase(*separators)
|
|
73
|
+
warn "String#lower_camelcase is deprecated. Use String#camelcase(:lower) instead. " \
|
|
74
|
+
"It will be removed after 2027-09-30.", uplevel: 1
|
|
69
75
|
camelcase(:lower, *separators)
|
|
70
76
|
end
|
|
71
77
|
|
|
@@ -82,8 +82,9 @@ class String
|
|
|
82
82
|
|
|
83
83
|
score = 0.0
|
|
84
84
|
matches.each{ |mm| score += mm.length }
|
|
85
|
-
|
|
86
|
-
return
|
|
85
|
+
largest = [self.length, str_in.length].max
|
|
86
|
+
return 0.0 if largest.zero? # e.g. an empty Symbol or Array
|
|
87
|
+
return score/largest
|
|
87
88
|
end
|
|
88
89
|
|
|
89
90
|
end
|
|
@@ -6,7 +6,7 @@ class Struct
|
|
|
6
6
|
# This will eventually be deprecated in favor of #to_h.
|
|
7
7
|
|
|
8
8
|
def attributes
|
|
9
|
-
warn "Struct#attributes is deprecated. Use Struct#to_h instead.", uplevel: 1
|
|
9
|
+
warn "Struct#attributes is deprecated. Use Struct#to_h instead. It will be removed after 2027-09-30.", uplevel: 1
|
|
10
10
|
to_h
|
|
11
11
|
end
|
|
12
12
|
|
|
@@ -4,9 +4,14 @@ class Time
|
|
|
4
4
|
|
|
5
5
|
# To be able to keep Dates and Times interchangeable
|
|
6
6
|
# on conversions.
|
|
7
|
-
|
|
7
|
+
#
|
|
8
|
+
# @deprecated Ruby defines Time#to_time once 'date' is loaded.
|
|
9
|
+
# Scheduled for removal after 2027-09-30.
|
|
10
|
+
#
|
|
8
11
|
def to_time
|
|
9
|
-
|
|
12
|
+
warn "Facets' Time#to_time is deprecated. Require 'date' for Ruby's own Time#to_time. " \
|
|
13
|
+
"It will be removed after 2027-09-30.", uplevel: 1
|
|
14
|
+
getlocal
|
|
10
15
|
end
|
|
11
16
|
|
|
12
17
|
# A method to keep Time, Date and DateTime instances interchangeable
|
|
@@ -14,8 +14,9 @@ class Time
|
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
# @deprecated Use Time#floor_to instead.
|
|
17
|
+
# Scheduled for removal after 2027-09-30.
|
|
17
18
|
def trunc(seconds)
|
|
18
|
-
warn "Time#trunc is deprecated. Use Time#floor_to instead.", uplevel: 1
|
|
19
|
+
warn "Time#trunc is deprecated. Use Time#floor_to instead. It will be removed after 2027-09-30.", uplevel: 1
|
|
19
20
|
floor_to(seconds)
|
|
20
21
|
end
|
|
21
22
|
|
|
@@ -19,7 +19,7 @@ class UnboundMethod
|
|
|
19
19
|
# CREDIT: Trans
|
|
20
20
|
|
|
21
21
|
def arguments
|
|
22
|
-
warn "UnboundMethod#arguments is deprecated. Use UnboundMethod#parameters instead.", uplevel: 1
|
|
22
|
+
warn "UnboundMethod#arguments is deprecated. Use UnboundMethod#parameters instead. It will be removed after 2027-09-30.", uplevel: 1
|
|
23
23
|
ar = arity
|
|
24
24
|
case ar <=> 0
|
|
25
25
|
when 1
|
data/lib/core/facets/version.rb
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require 'facets/hash/symbolize_keys'
|
|
2
|
+
|
|
3
|
+
class Hash
|
|
4
|
+
|
|
5
|
+
# Rails' name for #symbolize_keys.
|
|
6
|
+
#
|
|
7
|
+
# {'a'=>1}.to_options #=> {:a=>1}
|
|
8
|
+
#
|
|
9
|
+
alias_method :to_options, :symbolize_keys
|
|
10
|
+
|
|
11
|
+
# Rails' name for #symbolize_keys!.
|
|
12
|
+
alias_method :to_options!, :symbolize_keys!
|
|
13
|
+
|
|
14
|
+
end
|
|
@@ -19,13 +19,13 @@ class Module
|
|
|
19
19
|
# @uncommon
|
|
20
20
|
# require 'facets/module/cattr'
|
|
21
21
|
#
|
|
22
|
-
def cattr(*syms)
|
|
22
|
+
def cattr(*syms, &block)
|
|
23
23
|
writers, readers = syms.flatten.partition{ |a| a.to_s =~ /=$/ }
|
|
24
24
|
writers = writers.map{ |e| e.to_s.chomp('=').to_sym }
|
|
25
25
|
##readers.concat( writers ) # writers also get readers
|
|
26
26
|
|
|
27
|
-
cattr_reader(*readers)
|
|
28
|
-
cattr_writer(*writers)
|
|
27
|
+
cattr_reader(*readers, &block)
|
|
28
|
+
cattr_writer(*writers, &block)
|
|
29
29
|
|
|
30
30
|
return readers + writers
|
|
31
31
|
end
|
|
@@ -49,13 +49,13 @@ class Module
|
|
|
49
49
|
# @uncommon
|
|
50
50
|
# require 'facets/module/cattr'
|
|
51
51
|
#
|
|
52
|
-
def cattr_reader(*syms)
|
|
52
|
+
def cattr_reader(*syms, &block)
|
|
53
53
|
syms.flatten.each do |sym|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
end
|
|
54
|
+
unless class_variable_defined?("@@#{sym}")
|
|
55
|
+
class_variable_set("@@#{sym}", block ? block.call : nil)
|
|
56
|
+
end
|
|
58
57
|
|
|
58
|
+
module_eval(<<-EOS, __FILE__, __LINE__)
|
|
59
59
|
def self.#{sym}
|
|
60
60
|
@@#{sym}
|
|
61
61
|
end
|
|
@@ -91,13 +91,13 @@ class Module
|
|
|
91
91
|
# @uncommon
|
|
92
92
|
# require 'facets/module/cattr'
|
|
93
93
|
#
|
|
94
|
-
def cattr_writer(*syms)
|
|
94
|
+
def cattr_writer(*syms, &block)
|
|
95
95
|
syms.flatten.each do |sym|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
end
|
|
96
|
+
unless class_variable_defined?("@@#{sym}")
|
|
97
|
+
class_variable_set("@@#{sym}", block ? block.call : nil)
|
|
98
|
+
end
|
|
100
99
|
|
|
100
|
+
module_eval(<<-EOS, __FILE__, __LINE__)
|
|
101
101
|
def self.#{sym}=(obj)
|
|
102
102
|
@@#{sym} = obj
|
|
103
103
|
end
|
|
@@ -130,8 +130,8 @@ class Module
|
|
|
130
130
|
# @uncommon
|
|
131
131
|
# require 'facets/module/cattr'
|
|
132
132
|
#
|
|
133
|
-
def cattr_accessor(*syms)
|
|
134
|
-
cattr_reader(*syms) + cattr_writer(*syms)
|
|
133
|
+
def cattr_accessor(*syms, &block)
|
|
134
|
+
cattr_reader(*syms, &block) + cattr_writer(*syms)
|
|
135
135
|
end
|
|
136
136
|
|
|
137
137
|
# Creates a class-variable attribute that can
|
|
@@ -159,13 +159,13 @@ class Module
|
|
|
159
159
|
# @uncommon
|
|
160
160
|
# require 'facets/module/mattr'
|
|
161
161
|
#
|
|
162
|
-
def mattr(*syms)
|
|
162
|
+
def mattr(*syms, &block)
|
|
163
163
|
writers, readers = syms.flatten.partition{ |a| a.to_s =~ /=$/ }
|
|
164
164
|
writers = writers.collect{ |e| e.to_s.chomp('=').to_sym }
|
|
165
165
|
##readers.concat( writers ) # writers also get readers
|
|
166
166
|
|
|
167
|
-
mattr_writer( *writers )
|
|
168
|
-
mattr_reader( *readers )
|
|
167
|
+
mattr_writer( *writers, &block )
|
|
168
|
+
mattr_reader( *readers, &block )
|
|
169
169
|
|
|
170
170
|
return readers + writers
|
|
171
171
|
end
|
|
@@ -189,13 +189,13 @@ class Module
|
|
|
189
189
|
# @uncommon
|
|
190
190
|
# require 'facets/module/mattr'
|
|
191
191
|
#
|
|
192
|
-
def mattr_reader( *syms )
|
|
192
|
+
def mattr_reader( *syms, &block )
|
|
193
193
|
syms.flatten.each do |sym|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
end
|
|
194
|
+
unless class_variable_defined?("@@#{sym}")
|
|
195
|
+
class_variable_set("@@#{sym}", block ? block.call : nil)
|
|
196
|
+
end
|
|
198
197
|
|
|
198
|
+
module_eval(<<-EOS, __FILE__, __LINE__)
|
|
199
199
|
def self.#{sym}
|
|
200
200
|
@@#{sym}
|
|
201
201
|
end
|
|
@@ -232,13 +232,13 @@ class Module
|
|
|
232
232
|
# @uncommon
|
|
233
233
|
# require 'facets/module/mattr'
|
|
234
234
|
#
|
|
235
|
-
def mattr_writer(*syms)
|
|
235
|
+
def mattr_writer(*syms, &block)
|
|
236
236
|
syms.flatten.each do |sym|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
end
|
|
237
|
+
unless class_variable_defined?("@@#{sym}")
|
|
238
|
+
class_variable_set("@@#{sym}", block ? block.call : nil)
|
|
239
|
+
end
|
|
241
240
|
|
|
241
|
+
module_eval(<<-EOS, __FILE__, __LINE__)
|
|
242
242
|
def self.#{sym}=(obj)
|
|
243
243
|
@@#{sym} = obj
|
|
244
244
|
end
|
|
@@ -272,8 +272,8 @@ class Module
|
|
|
272
272
|
# @uncommon
|
|
273
273
|
# require 'facets/module/mattr'
|
|
274
274
|
#
|
|
275
|
-
def mattr_accessor(*syms)
|
|
276
|
-
mattr_reader(*syms) + mattr_writer(*syms)
|
|
275
|
+
def mattr_accessor(*syms, &block)
|
|
276
|
+
mattr_reader(*syms, &block) + mattr_writer(*syms)
|
|
277
277
|
end
|
|
278
278
|
|
|
279
279
|
end
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# @deprecated Use deep_dup/deep_clone instead, or define your own
|
|
2
2
|
# initialize_copy method.
|
|
3
|
-
|
|
3
|
+
# Scheduled for removal after 2027-09-30.
|
|
4
|
+
warn "facets/cloneable is deprecated. Use deep_dup/deep_clone instead. It will be removed after 2027-09-30.", uplevel: 1
|
|
4
5
|
|
|
5
6
|
module Cloneable
|
|
6
7
|
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
# @deprecated callcc is obsolete in Ruby. Use Fiber instead.
|
|
2
|
-
|
|
2
|
+
# Scheduled for removal after 2027-09-30.
|
|
3
|
+
warn "facets/continuation is deprecated. callcc is obsolete; use Fiber instead. It will be removed after 2027-09-30.", uplevel: 1
|
|
@@ -54,8 +54,8 @@ module Enumerable
|
|
|
54
54
|
# this branch is used when the method has a variable number of arguments
|
|
55
55
|
# resulting in an arity of -1. Right now this is bugged as it does
|
|
56
56
|
# not pass the argument to the each, and always passes the argument
|
|
57
|
-
# to the method.
|
|
58
|
-
#
|
|
57
|
+
# to the method. #min and #max are defined explicitly below for
|
|
58
|
+
# this reason.
|
|
59
59
|
class_eval %{
|
|
60
60
|
def #{m}( *args, &yld )
|
|
61
61
|
enum_for(:each).#{m}( *args, &yld )
|
|
@@ -76,6 +76,18 @@ module Enumerable
|
|
|
76
76
|
enum_for(:each, *args).to_a
|
|
77
77
|
end
|
|
78
78
|
|
|
79
|
+
# Support for #min and #max. Ruby's own versions take an optional
|
|
80
|
+
# count, so the generic wrapper would pass the argument to them
|
|
81
|
+
# instead of to #each.
|
|
82
|
+
#
|
|
83
|
+
def min(*args, &yld)
|
|
84
|
+
enum_for(:each, *args).min(&yld)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def max(*args, &yld)
|
|
88
|
+
enum_for(:each, *args).max(&yld)
|
|
89
|
+
end
|
|
90
|
+
|
|
79
91
|
# Make exception for #find (a negative arity method) to accept
|
|
80
92
|
# keyword argument.
|
|
81
93
|
#
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
# @deprecated GetoptLong is a bundled gem heading for removal.
|
|
2
2
|
# Consider using OptionParser or a modern CLI library instead.
|
|
3
|
-
|
|
3
|
+
# Scheduled for removal after 2027-09-30.
|
|
4
|
+
warn "facets/getoptlong is deprecated. Consider OptionParser instead. It will be removed after 2027-09-30.", uplevel: 1
|
|
@@ -189,11 +189,12 @@ class Interval
|
|
|
189
189
|
# 1..5.each(2) { |e| ... } #=> 1 3 5
|
|
190
190
|
# 1..5.each(1,2) { |e| ... } #=> 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0
|
|
191
191
|
#
|
|
192
|
-
# @
|
|
192
|
+
# @deprecated The +n+ and +d+ arguments. Use +interval.step(n,d).each+ instead.
|
|
193
|
+
# Scheduled for removal after 2027-09-30.
|
|
193
194
|
def each(n=nil, d=nil) # :yield:
|
|
194
195
|
if n
|
|
195
|
-
warn "
|
|
196
|
-
"
|
|
196
|
+
warn "Interval#each(n, d) is deprecated. Use interval.step(n, d).each instead. " \
|
|
197
|
+
"It will be removed after 2027-09-30.", uplevel: 1
|
|
197
198
|
else
|
|
198
199
|
n = 1
|
|
199
200
|
end
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
# @deprecated Monkey-patching require/load globally is dangerous.
|
|
2
|
-
|
|
2
|
+
# Scheduled for removal after 2027-09-30.
|
|
3
|
+
warn "facets/load_monitor is deprecated. It monkey-patches require/load globally. It will be removed after 2027-09-30.", uplevel: 1
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
class Pathname
|
|
2
2
|
|
|
3
3
|
# @deprecated Use Pathname.new(File::NULL) instead.
|
|
4
|
+
# Scheduled for removal after 2027-09-30.
|
|
4
5
|
def self.null
|
|
5
|
-
warn "Pathname.null is deprecated. Use Pathname.new(File::NULL) instead.", uplevel: 1
|
|
6
|
+
warn "Pathname.null is deprecated. Use Pathname.new(File::NULL) instead. It will be removed after 2027-09-30.", uplevel: 1
|
|
6
7
|
new(File::NULL)
|
|
7
8
|
end
|
|
8
9
|
|
|
@@ -117,26 +117,30 @@ class Random
|
|
|
117
117
|
end
|
|
118
118
|
|
|
119
119
|
# @deprecated Use Array#sample instead.
|
|
120
|
+
# Scheduled for removal after 2027-09-30.
|
|
120
121
|
def at_rand
|
|
121
|
-
warn "Array#at_rand is deprecated. Use Array#sample instead.", uplevel: 1
|
|
122
|
+
warn "Array#at_rand is deprecated. Use Array#sample instead. It will be removed after 2027-09-30.", uplevel: 1
|
|
122
123
|
sample
|
|
123
124
|
end
|
|
124
125
|
|
|
125
126
|
# @deprecated Use Array#sample! instead.
|
|
127
|
+
# Scheduled for removal after 2027-09-30.
|
|
126
128
|
def at_rand!
|
|
127
|
-
warn "Array#at_rand! is deprecated. Use Array#sample! instead.", uplevel: 1
|
|
129
|
+
warn "Array#at_rand! is deprecated. Use Array#sample! instead. It will be removed after 2027-09-30.", uplevel: 1
|
|
128
130
|
sample!
|
|
129
131
|
end
|
|
130
132
|
|
|
131
133
|
# @deprecated Use Array#sample instead.
|
|
134
|
+
# Scheduled for removal after 2027-09-30.
|
|
132
135
|
def pick(n=nil)
|
|
133
|
-
warn "Array#pick is deprecated. Use Array#sample instead.", uplevel: 1
|
|
136
|
+
warn "Array#pick is deprecated. Use Array#sample instead. It will be removed after 2027-09-30.", uplevel: 1
|
|
134
137
|
n ? sample(n) : sample
|
|
135
138
|
end
|
|
136
139
|
|
|
137
140
|
# @deprecated Use Array#sample! instead.
|
|
141
|
+
# Scheduled for removal after 2027-09-30.
|
|
138
142
|
def pick!(n=nil)
|
|
139
|
-
warn "Array#pick! is deprecated. Use Array#sample! instead.", uplevel: 1
|
|
143
|
+
warn "Array#pick! is deprecated. Use Array#sample! instead. It will be removed after 2027-09-30.", uplevel: 1
|
|
140
144
|
sample!(n)
|
|
141
145
|
end
|
|
142
146
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: facets
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 4.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Thomas Sawyer
|
|
@@ -46,7 +46,6 @@ files:
|
|
|
46
46
|
- lib/core/facets/array/each_pair.rb
|
|
47
47
|
- lib/core/facets/array/each_value.rb
|
|
48
48
|
- lib/core/facets/array/entropy.rb
|
|
49
|
-
- lib/core/facets/array/extract_options.rb
|
|
50
49
|
- lib/core/facets/array/first.rb
|
|
51
50
|
- lib/core/facets/array/from.rb
|
|
52
51
|
- lib/core/facets/array/indexable.rb
|
|
@@ -98,9 +97,7 @@ files:
|
|
|
98
97
|
- lib/core/facets/binding/self.rb
|
|
99
98
|
- lib/core/facets/binding/with.rb
|
|
100
99
|
- lib/core/facets/boolean.rb
|
|
101
|
-
- lib/core/facets/cattr.rb
|
|
102
100
|
- lib/core/facets/class.rb
|
|
103
|
-
- lib/core/facets/class/cattr.rb
|
|
104
101
|
- lib/core/facets/class/descendants.rb
|
|
105
102
|
- lib/core/facets/class/hierarchically.rb
|
|
106
103
|
- lib/core/facets/class/methodize.rb
|
|
@@ -179,7 +176,6 @@ files:
|
|
|
179
176
|
- lib/core/facets/file/append.rb
|
|
180
177
|
- lib/core/facets/file/atomic_id.rb
|
|
181
178
|
- lib/core/facets/file/atomic_open.rb
|
|
182
|
-
- lib/core/facets/file/atomic_write.rb
|
|
183
179
|
- lib/core/facets/file/common_path.rb
|
|
184
180
|
- lib/core/facets/file/create.rb
|
|
185
181
|
- lib/core/facets/file/ext.rb
|
|
@@ -243,13 +239,9 @@ files:
|
|
|
243
239
|
- lib/core/facets/hash/revalue.rb
|
|
244
240
|
- lib/core/facets/hash/reverse_merge.rb
|
|
245
241
|
- lib/core/facets/hash/setter.rb
|
|
246
|
-
- lib/core/facets/hash/slice.rb
|
|
247
|
-
- lib/core/facets/hash/stringify_keys.rb
|
|
248
242
|
- lib/core/facets/hash/subset.rb
|
|
249
243
|
- lib/core/facets/hash/swap.rb
|
|
250
|
-
- lib/core/facets/hash/symbolize_keys.rb
|
|
251
244
|
- lib/core/facets/hash/to_mod.rb
|
|
252
|
-
- lib/core/facets/hash/to_options.rb
|
|
253
245
|
- lib/core/facets/hash/to_struct.rb
|
|
254
246
|
- lib/core/facets/hash/traverse.rb
|
|
255
247
|
- lib/core/facets/hash/update.rb
|
|
@@ -369,7 +361,6 @@ files:
|
|
|
369
361
|
- lib/core/facets/module/attr_validator.rb
|
|
370
362
|
- lib/core/facets/module/basename.rb
|
|
371
363
|
- lib/core/facets/module/can.rb
|
|
372
|
-
- lib/core/facets/module/cattr.rb
|
|
373
364
|
- lib/core/facets/module/class.rb
|
|
374
365
|
- lib/core/facets/module/class_accessor.rb
|
|
375
366
|
- lib/core/facets/module/class_def.rb
|
|
@@ -392,7 +383,6 @@ files:
|
|
|
392
383
|
- lib/core/facets/module/is.rb
|
|
393
384
|
- lib/core/facets/module/lastname.rb
|
|
394
385
|
- lib/core/facets/module/let.rb
|
|
395
|
-
- lib/core/facets/module/mattr.rb
|
|
396
386
|
- lib/core/facets/module/memoize.rb
|
|
397
387
|
- lib/core/facets/module/method_clash.rb
|
|
398
388
|
- lib/core/facets/module/method_space.rb
|
|
@@ -445,6 +435,7 @@ files:
|
|
|
445
435
|
- lib/core/facets/proc/update.rb
|
|
446
436
|
- lib/core/facets/proc/wrap.rb
|
|
447
437
|
- lib/core/facets/process.rb
|
|
438
|
+
- lib/core/facets/rails_bridge.rb
|
|
448
439
|
- lib/core/facets/range.rb
|
|
449
440
|
- lib/core/facets/range/combine.rb
|
|
450
441
|
- lib/core/facets/range/intersection.rb
|
|
@@ -574,6 +565,17 @@ files:
|
|
|
574
565
|
- lib/core/facets/unboundmethod.rb
|
|
575
566
|
- lib/core/facets/unboundmethod/arguments.rb
|
|
576
567
|
- lib/core/facets/version.rb
|
|
568
|
+
- lib/rails/facets/array/extract_options.rb
|
|
569
|
+
- lib/rails/facets/cattr.rb
|
|
570
|
+
- lib/rails/facets/class/cattr.rb
|
|
571
|
+
- lib/rails/facets/date.rb
|
|
572
|
+
- lib/rails/facets/file/atomic_write.rb
|
|
573
|
+
- lib/rails/facets/hash/slice.rb
|
|
574
|
+
- lib/rails/facets/hash/stringify_keys.rb
|
|
575
|
+
- lib/rails/facets/hash/symbolize_keys.rb
|
|
576
|
+
- lib/rails/facets/hash/to_options.rb
|
|
577
|
+
- lib/rails/facets/module/cattr.rb
|
|
578
|
+
- lib/rails/facets/module/mattr.rb
|
|
577
579
|
- lib/standard/facets/against.rb
|
|
578
580
|
- lib/standard/facets/argvector.rb
|
|
579
581
|
- lib/standard/facets/binding/block_exec.rb
|
|
@@ -585,7 +587,6 @@ files:
|
|
|
585
587
|
- lib/standard/facets/cloneable.rb
|
|
586
588
|
- lib/standard/facets/continuation.rb
|
|
587
589
|
- lib/standard/facets/crypt3.rb
|
|
588
|
-
- lib/standard/facets/date.rb
|
|
589
590
|
- lib/standard/facets/date/cmp.rb
|
|
590
591
|
- lib/standard/facets/digest.rb
|
|
591
592
|
- lib/standard/facets/digest/salted_digest.rb
|
|
@@ -740,6 +741,7 @@ rdoc_options: []
|
|
|
740
741
|
require_paths:
|
|
741
742
|
- lib/core
|
|
742
743
|
- lib/standard
|
|
744
|
+
- lib/rails
|
|
743
745
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
744
746
|
requirements:
|
|
745
747
|
- - ">="
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
require 'facets/hash/symbolize_keys'
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|