refinements 7.11.0 → 7.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a5a299dfa7a3355d5cb068cc6638ed41ca9ac4980ed69f6aabb0e1608cc96e95
4
- data.tar.gz: 4b12b5237fc97f5609677b8f010156ef9a1d00d5004fe48d1cfa4d32df15f602
3
+ metadata.gz: 3df95fcb46ec44d2945b1eb3ab7dafd8ba6bb243973829d662e448ef74695302
4
+ data.tar.gz: 21d89890312770ec2c73387c05c44dc31b22de849e18c3db6b4248476ca8bbdf
5
5
  SHA512:
6
- metadata.gz: 248e66b7141e5e29f68c60aae0a3eac49934830053e9e5ce7082b0164e63b42ee9c536d8b46d4f86c7f570a85f1838415939b5955d66bd93f5df2eeefe66a5d7
7
- data.tar.gz: 399fc17b0857236d4d58668857d690ddb63deba8fd9de10c372f2d3618c93edb31a9574f166c01d6aee884d4d856f067dfc2b68eddedb80d90d70a656595d82d
6
+ metadata.gz: d0cb8fa10183e03737eab0ae1780b91e2e4ce994fd0945c7e2653bacd852dae85de474a073f4b1f6b8634e685059a54a0651b46ec567defd283cfb1491988e50
7
+ data.tar.gz: a3f2ea6940f0e8c74f41f43d28d34a71892d3ddcaaf295c64ce4761b120421f80c7833bd9b48d37a90e485c3b606c38adb71e8665cf9feecad35925da485628a
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -150,7 +150,7 @@ additional liability.
150
150
 
151
151
  END OF TERMS AND CONDITIONS
152
152
 
153
- Copyright link:https://www.alchemists.io[Alchemists].
153
+ Copyright 2015 link:https://www.alchemists.io/team/brooke_kuhlmann[Brooke Kuhlmann].
154
154
 
155
155
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
156
156
  compliance with the License. You may obtain a link:https://www.apache.org/licenses/LICENSE-2.0[copy]
@@ -35,8 +35,6 @@ Enhances the following objects:
35
35
 
36
36
  == Setup
37
37
 
38
- === Production
39
-
40
38
  To install, run:
41
39
 
42
40
  [source,bash]
@@ -51,24 +49,6 @@ Add the following to your Gemfile file:
51
49
  gem "refinements"
52
50
  ----
53
51
 
54
- === Development
55
-
56
- To contribute, run:
57
-
58
- [source,bash]
59
- ----
60
- git clone https://github.com/bkuhlmann/refinements.git
61
- cd refinements
62
- bin/setup
63
- ----
64
-
65
- You can also use the IRB console for direct access to all objects:
66
-
67
- [source,bash]
68
- ----
69
- bin/console
70
- ----
71
-
72
52
  == Usage
73
53
 
74
54
  === Requires
@@ -153,6 +133,17 @@ Adds given array or elements without mutating itself.
153
133
  [1, 2, 3].include 4, 5 # => [1, 2, 3, 4, 5]
154
134
  ----
155
135
 
136
+ ===== #intersperse
137
+
138
+ Inserts additional elements or array between all members of given array.
139
+
140
+ [source,ruby]
141
+ ----
142
+ [1, 2, 3].intersperse :a # => [1, :a, 2, :a, 3]
143
+ [1, 2, 3].intersperse :a, :b # => [1, :a, :b, 2, :a, :b, 3]
144
+ [1, 2, 3].intersperse %i[a b c] # => [1, :a, :b, :c, 2, :a, :b, :c, 3]
145
+ ----
146
+
156
147
  ===== #exclude
157
148
 
158
149
  Removes given array or elements without mutating itself.
@@ -163,6 +154,18 @@ Removes given array or elements without mutating itself.
163
154
  [1, 2, 3, 4, 5].exclude 4, 5 # => [1, 2, 3]
164
155
  ----
165
156
 
157
+ ===== #mean
158
+
159
+ Answers mean/average all elements within an array.
160
+
161
+ [source,ruby]
162
+ ----
163
+ [].mean # => 0
164
+ [5].mean # => 5
165
+ [1, 2, 3].mean # => 2
166
+ [1.25, 1.5, 1.75].mean # => 1.5
167
+ ----
168
+
166
169
  ===== #ring
167
170
 
168
171
  Answers a circular array which can enumerate before, current, after elements.
@@ -625,6 +628,17 @@ Pathname("/one").exist? # => true
625
628
  Pathname("/one/two").exist? # => false
626
629
  ----
627
630
 
631
+ ===== #mkdir
632
+
633
+ Modifies default behavior by always answering itself (even when directory exists) and not throwing
634
+ errors when directory exists.
635
+
636
+ [source,ruby]
637
+ ----
638
+ Pathname("/one").mkdir # => Pathname("/one")
639
+ Pathname("/one").mkdir.mkdir # => Pathname("/one")
640
+ ----
641
+
628
642
  ===== #rewrite
629
643
 
630
644
  When given a block, it provides the contents of the recently read file for manipulation and
@@ -766,6 +780,24 @@ io.reread(buffer: buffer)
766
780
  buffer # => "This is a test."
767
781
  ----
768
782
 
783
+ == Development
784
+
785
+ To contribute, run:
786
+
787
+ [source,bash]
788
+ ----
789
+ git clone https://github.com/bkuhlmann/refinements.git
790
+ cd refinements
791
+ bin/setup
792
+ ----
793
+
794
+ You can also use the IRB console for direct access to all objects:
795
+
796
+ [source,bash]
797
+ ----
798
+ bin/console
799
+ ----
800
+
769
801
  == Tests
770
802
 
771
803
  To test, run:
@@ -15,10 +15,18 @@ module Refinements
15
15
  self + elements.flatten
16
16
  end
17
17
 
18
+ def intersperse *elements
19
+ product([elements]).tap(&:pop).flatten.push last
20
+ end
21
+
18
22
  def exclude *elements
19
23
  self - elements.flatten
20
24
  end
21
25
 
26
+ def mean
27
+ size.zero? ? 0 : sum(0) / size
28
+ end
29
+
22
30
  def ring &block
23
31
  [last, *self, first].each_cons 3, &block
24
32
  end
@@ -5,7 +5,7 @@ module Refinements
5
5
  module Identity
6
6
  NAME = "refinements"
7
7
  LABEL = "Refinements"
8
- VERSION = "7.11.0"
8
+ VERSION = "7.12.0"
9
9
  VERSION_LABEL = "#{LABEL} #{VERSION}"
10
10
  end
11
11
  end
@@ -54,6 +54,12 @@ module Refinements
54
54
  self
55
55
  end
56
56
 
57
+ # rubocop:disable Style/RedundantSelf
58
+ def mkdir
59
+ self.exist? ? self : super and self
60
+ end
61
+ # rubocop:enable Style/RedundantSelf
62
+
57
63
  def rewrite
58
64
  read.then { |content| write yield(content) if block_given? }
59
65
  self
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: refinements
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.11.0
4
+ version: 7.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brooke Kuhlmann
@@ -28,7 +28,7 @@ cert_chain:
28
28
  2XV8FRa7/JimI07sPLC13eLY3xd/aYTi85Z782KIA4j0G8XEEWAX0ouBhlXPocZv
29
29
  QWc=
30
30
  -----END CERTIFICATE-----
31
- date: 2020-10-06 00:00:00.000000000 Z
31
+ date: 2020-11-04 00:00:00.000000000 Z
32
32
  dependencies:
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: bundler-audit
@@ -44,6 +44,20 @@ dependencies:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
46
  version: '0.6'
47
+ - !ruby/object:Gem::Dependency
48
+ name: bundler-leak
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '0.2'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '0.2'
47
61
  - !ruby/object:Gem::Dependency
48
62
  name: gemsmith
49
63
  requirement: !ruby/object:Gem::Requirement
metadata.gz.sig CHANGED
Binary file