coalescer 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 42de40baf5b552ad6a980d2f29080e9cbf3007c150e991948db00414424d111d
4
+ data.tar.gz: c20daa2b6903e26e0c7a55c40bc0bd9b553992a82b5cb502c7a835e819e02350
5
+ SHA512:
6
+ metadata.gz: 84a0cb6c331cc7c25ce5c507ffcf94f43d5a8135c01b5a617dc10062552f761e407402e2cdce67b8410d738c4ddafe2c93698e3e1941c16010cf9ba050dbafeb
7
+ data.tar.gz: 9099d62a2afabeda45e86df6372ca1a69f704082ad5adcf89ceef99fc9ccef88f40f414ac6dac4d66720b102020f621be4735403a5a5e6df175f0217c93feacc
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Willian Girhad
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,2 @@
1
+ # coalescer
2
+ Enables coalesce chaining values on Ruby
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Coalescer
4
+ module Array
5
+ def coalesce!
6
+ nil.coalesce(*self)
7
+ end
8
+
9
+ alias coal! coalesce!
10
+ end
11
+
12
+ ::Array.prepend Array
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Coalescer
4
+ module NilClass
5
+ def coalesce(*args)
6
+ args.empty? ? super : args.shift.coalesce(*args)
7
+ end
8
+
9
+ alias coal coalesce
10
+ end
11
+
12
+ ::NilClass.prepend NilClass
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Coalescer
4
+ module Object
5
+ def coalesce(*)
6
+ self
7
+ end
8
+
9
+ alias coal coalesce
10
+ end
11
+
12
+ ::Object.prepend Object
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Coalescer
4
+ module Proc
5
+ def coalesce(*args)
6
+ call.coalesce(*args)
7
+ end
8
+
9
+ alias coal coalesce
10
+ end
11
+
12
+ ::Proc.prepend Proc
13
+ end
data/lib/coalescer.rb ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Coalescer
4
+ VERSION = '0.1.0'
5
+ end
6
+
7
+ require_relative 'coalescer/array.rb'
8
+ require_relative 'coalescer/nil_class.rb'
9
+ require_relative 'coalescer/object.rb'
10
+ require_relative 'coalescer/proc.rb'
metadata ADDED
@@ -0,0 +1,50 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: coalescer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Willian Girhad
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-11-11 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Enables coalesce chaining values
14
+ email: willianmonts@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - LICENSE
20
+ - README.md
21
+ - lib/coalescer.rb
22
+ - lib/coalescer/array.rb
23
+ - lib/coalescer/nil_class.rb
24
+ - lib/coalescer/object.rb
25
+ - lib/coalescer/proc.rb
26
+ homepage: https://github.com/wgirhad/coalescer
27
+ licenses:
28
+ - MIT
29
+ metadata:
30
+ rubygems_mfa_required: 'true'
31
+ post_install_message:
32
+ rdoc_options: []
33
+ require_paths:
34
+ - lib
35
+ required_ruby_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '2.7'
40
+ required_rubygems_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ requirements: []
46
+ rubygems_version: 3.1.6
47
+ signing_key:
48
+ specification_version: 4
49
+ summary: Tired of doing `foo || foo.bar || foo.bar.baz`? Try this
50
+ test_files: []