string_proc 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/string_proc.rb +6 -4
  3. metadata +6 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c438fb3ed85ad080f84f08b8170866088df4ed7d612d2a878efcd2ef271bcaaf
4
- data.tar.gz: d0e502e2013ad7ff9473f3e7d79b8300616abcacd0ae524325c16b4693ec10a2
3
+ metadata.gz: b29afb2092992a1a24076dd636f00c20239a83eb09ea1f95c87ac63be37ee04a
4
+ data.tar.gz: f4f8222c5a9b18afe76c161ae004dd435170a68cf3532e4ec549f37e57ef3529
5
5
  SHA512:
6
- metadata.gz: f22f68e25a56a4d24d96e8b0ddb93ea8d307fb163920da6cf206a4084ae5c9ac676bfa4a62a4a98c073a341a1c2fa98f8746523ac4964d9d7504e51f24ca1e5a
7
- data.tar.gz: c3f1447490224a8ed91f368ad637ffb28f42281e4d70152ba8ad39ecc583a937c3d170f7b55aa6e9811838a89d3c32dbbac47a69a7ead5175323942c983739df
6
+ metadata.gz: 985779642be9abf16bf6f724fa6be5029fd02e6c365b5c049ce319e909b12756ff074aefb9b1bf9a7f2632d134b8d4d67b3c3fefa942e5397049a234706b7c11
7
+ data.tar.gz: 97c8536ee2e6685a76dd939b025d935214307b619eb49f5ff66a014a6fcaf0b525e6bdb05d1e387287d5eb420612b0c916faaf12921f5d411fb8663591cf12dc
data/lib/string_proc.rb CHANGED
@@ -1,15 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Adds `String#to_proc` to allow multiple method chain calls on each element of an enumerable using the `&` shorthand
4
+ # The default separator is `.` but can be changed with the `String.proc_separator=` setter
3
5
  class String
4
- @@proc_separator ||= '.'
6
+ @proc_separator = '.'
5
7
 
6
- def self.proc_separator=(separator_string)
7
- @@proc_separator = separator_string
8
+ class << self
9
+ attr_accessor :proc_separator
8
10
  end
9
11
 
10
12
  def to_proc
11
13
  proc do |object|
12
- split(@@proc_separator).inject(object) { |obj, method| obj.send(method) }
14
+ split(self.class.proc_separator).reduce(object) { |obj, method| obj.send(method) }
13
15
  end
14
16
  end
15
17
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: string_proc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Rosenberg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-08 00:00:00.000000000 Z
11
+ date: 2024-08-04 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Adds `String#to_proc`.
14
14
  email: aarongrosenberg@gmail.com
@@ -20,7 +20,8 @@ files:
20
20
  homepage: https://github.com/agrberg/string_proc
21
21
  licenses:
22
22
  - MIT
23
- metadata: {}
23
+ metadata:
24
+ rubygems_mfa_required: 'true'
24
25
  post_install_message:
25
26
  rdoc_options: []
26
27
  require_paths:
@@ -29,14 +30,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
29
30
  requirements:
30
31
  - - ">="
31
32
  - !ruby/object:Gem::Version
32
- version: '0'
33
+ version: '2.0'
33
34
  required_rubygems_version: !ruby/object:Gem::Requirement
34
35
  requirements:
35
36
  - - ">="
36
37
  - !ruby/object:Gem::Version
37
38
  version: '0'
38
39
  requirements: []
39
- rubygems_version: 3.1.2
40
+ rubygems_version: 3.5.17
40
41
  signing_key:
41
42
  specification_version: 4
42
43
  summary: Turn a string into proc of a series of methods to be called on an object.