facets 3.2.2 → 4.0.1
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 +50 -15
- data/HISTORY.md +164 -0
- data/LICENSE.txt +1 -1
- data/README.md +54 -217
- 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/graph.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_by.rb +6 -2
- 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/deep_clone.rb +36 -8
- 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_class_method.rb +8 -3
- 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/module/module_def.rb +0 -11
- data/lib/core/facets/module/redefine_method.rb +12 -3
- 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/round_to.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 +5 -3
- data/lib/standard/facets/continuation.rb +2 -1
- data/lib/standard/facets/enumargs.rb +14 -2
- data/lib/standard/facets/find/select.rb +3 -1
- data/lib/standard/facets/getoptlong.rb +2 -1
- data/lib/standard/facets/interval.rb +5 -4
- data/lib/standard/facets/load_monitor.rb +2 -1
- data/lib/standard/facets/math/percentile.rb +9 -4
- data/lib/standard/facets/pathname/null.rb +2 -1
- data/lib/standard/facets/random.rb +8 -4
- data/lib/standard/facets/shellwords.rb +6 -10
- 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
|
@@ -16,19 +16,24 @@ module Math
|
|
|
16
16
|
# require 'facets/math/percentile'
|
|
17
17
|
#
|
|
18
18
|
def self.percentile(array, pcnt)
|
|
19
|
-
sorted_array = array.sort
|
|
20
|
-
|
|
21
19
|
return nil if array.length == 0
|
|
22
20
|
|
|
21
|
+
sorted_array = array.sort
|
|
22
|
+
|
|
23
23
|
rank = (pcnt.to_f / 100) * (array.length + 1)
|
|
24
24
|
whole = rank.truncate
|
|
25
|
-
|
|
25
|
+
|
|
26
|
+
# A rank below 1 or past the last value is clamped to the minimum or
|
|
27
|
+
# maximum, as NIST specifies.
|
|
28
|
+
return sorted_array.first if whole < 1
|
|
29
|
+
return sorted_array.last if whole >= array.length
|
|
30
|
+
|
|
26
31
|
# if has fractional part
|
|
27
32
|
if whole != rank
|
|
28
33
|
s0 = sorted_array[whole - 1]
|
|
29
34
|
s1 = sorted_array[whole]
|
|
30
35
|
|
|
31
|
-
f =
|
|
36
|
+
f = rank - whole
|
|
32
37
|
|
|
33
38
|
return (f * (s1 - s0)) + s0
|
|
34
39
|
else
|
|
@@ -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
|
|
|
@@ -4,21 +4,17 @@ module Shellwords
|
|
|
4
4
|
|
|
5
5
|
module_function
|
|
6
6
|
|
|
7
|
-
# Escape
|
|
8
|
-
#
|
|
7
|
+
# Escape backslash, tab, space, and the characters | & ` < > ( ) ' "
|
|
8
|
+
# with a backslash.
|
|
9
9
|
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
10
|
+
# Unlike Ruby's Shellwords.escape, this leaves other shell
|
|
11
|
+
# metacharacters alone, including $ (so shell variables still
|
|
12
|
+
# expand), ; * ? ~ and newlines. It is not safe for untrusted
|
|
13
|
+
# input: use Shellwords.escape for that.
|
|
12
14
|
def alt_escape(cmdline)
|
|
13
15
|
cmdline.gsub(/([\\\t\| &`<>)('"])/) { |s| '\\' << s }
|
|
14
16
|
end
|
|
15
17
|
|
|
16
|
-
unless method_defined?(:escape)
|
|
17
|
-
def escape(cmdline)
|
|
18
|
-
cmdline.gsub(/([\\\t\| &`<>)('"])\$/) { |s| '\\' << s }
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
18
|
# Escape special character used in DOS-based shells.
|
|
23
19
|
#
|
|
24
20
|
# TODO: How to integrate with rest of system?
|
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.1
|
|
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
|