existence 1.0.0 → 1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3b3e742aee1fda6f595b39205d527fe1d4c4505df30ec6052d6848bb96ec9837
4
- data.tar.gz: 9b0929bf2d05c18306c448a281e50f60a1e73bda70eb62850337049206329c67
3
+ metadata.gz: 81f1875a407c056d3c3e6223159aa8489004b7cda6cf83d1f3dca7cd0568d8b4
4
+ data.tar.gz: 5a8e8c6323099c0aef5677a4dcf6c2dfdb5c7d60dd9650e916330c612990a237
5
5
  SHA512:
6
- metadata.gz: 8d0a63807bf9e1d9a5a6f342d5e45e23a67b6415967158bffe56771a086643b4da18f75fca4e7db610ded6abb97d587c05b2393aad7e02d98bb0308f96701b2c
7
- data.tar.gz: eb82e262ca1ed7639f1980aea6e9538ead88fb71a55ef46befdd2040ce1f869d69022cef9d6d613ada5bea31574bcb8e2143945a2d0ce0ff3dfb5353acb61b37
6
+ metadata.gz: 32c3405943226b02af204c6acae118bb92f0da78f60f9fb369bdbf46dc6cf6789b0babec63bf055e0c52918df6515b0adecf8bf940ee9e308c23c780c02e09b7
7
+ data.tar.gz: 25d589e38019780d4aae338e22550cee80807df0b65c62264315784c12651f767fba8f22be34839ea1b966d350438f7fd6a24c500cf7b2a0a59376aa666a9dde
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Josh Wetzel
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,67 @@
1
+ # Existence
2
+
3
+ Lightweight presence and blank checks for Ruby without ActiveSupport.
4
+
5
+ ## Installation
6
+ ```ruby
7
+ gem "existence"
8
+ ```
9
+
10
+ ## Usage
11
+ Extends the following classes with presence and blank checks.
12
+
13
+ ### Array
14
+ ```ruby
15
+ [].present? # => false
16
+ ["a"].present? # => true
17
+ [].blank? # => true
18
+ ["a"].blank? # => false
19
+ ```
20
+
21
+ ### Hash
22
+ ```ruby
23
+ {}.present? # => false
24
+ { a: 1 }.present? # => true
25
+ {}.blank? # => true
26
+ { a: 1 }.blank? # => false
27
+ ```
28
+
29
+ ### String
30
+ Blank if empty or whitespace-only.
31
+
32
+ ```ruby
33
+ "".present? # => false
34
+ "hello".present? # => true
35
+ " ".blank? # => true
36
+ "hello".blank? # => false
37
+ ```
38
+
39
+ ### Numeric
40
+ All numbers are present, including zero.
41
+
42
+ ```ruby
43
+ 0.present? # => true
44
+ 1.present? # => true
45
+ 0.blank? # => false
46
+ 1.blank? # => false
47
+ ```
48
+
49
+ ### Symbol
50
+ ```ruby
51
+ :foo.present? # => true
52
+ :foo.blank? # => false
53
+ ```
54
+
55
+ ### NilClass
56
+ ```ruby
57
+ nil.present? # => false
58
+ nil.blank? # => true
59
+ ```
60
+
61
+ ### TrueClass / FalseClass
62
+ ```ruby
63
+ true.present? # => true
64
+ true.blank? # => false
65
+ false.present? # => false
66
+ false.blank? # => true
67
+ ```
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Array
2
4
  def present?
3
5
  !empty?
4
6
  end
5
7
 
6
- alias_method :blank?, :empty?
8
+ alias blank? empty?
7
9
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class FalseClass
2
4
  def present?
3
5
  false
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Hash
2
4
  def present?
3
5
  !empty?
4
6
  end
5
7
 
6
- alias_method :blank?, :empty?
8
+ alias blank? empty?
7
9
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class NilClass
2
4
  def present?
3
5
  false
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Numeric
4
+ def present?
5
+ true
6
+ end
7
+
8
+ def blank?
9
+ false
10
+ end
11
+ end
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class String
2
4
  def present?
3
5
  !blank?
4
6
  end
5
7
 
6
8
  def blank?
7
- self.strip.empty?
9
+ strip.empty?
8
10
  end
9
11
  end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Symbol
4
+ def present?
5
+ true
6
+ end
7
+
8
+ def blank?
9
+ false
10
+ end
11
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class TrueClass
2
4
  def present?
3
5
  true
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Existence
2
- VERSION = '1.0.0'
4
+ VERSION = '1.1.0'
3
5
  end
data/lib/existence.rb CHANGED
@@ -1,6 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'existence/array'
2
4
  require 'existence/false_class'
3
5
  require 'existence/hash'
4
6
  require 'existence/nil_class'
7
+ require 'existence/numeric'
5
8
  require 'existence/string'
9
+ require 'existence/symbol'
6
10
  require 'existence/true_class'
metadata CHANGED
@@ -1,62 +1,68 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: existence
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Wetzel
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-12 00:00:00.000000000 Z
11
+ date: 2026-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '5'
19
+ version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '5'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '13'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '13'
41
- description:
42
- email:
40
+ version: '0'
41
+ description:
42
+ email:
43
43
  executables: []
44
44
  extensions: []
45
45
  extra_rdoc_files: []
46
46
  files:
47
+ - LICENSE
48
+ - README.md
47
49
  - lib/existence.rb
48
50
  - lib/existence/array.rb
49
51
  - lib/existence/false_class.rb
50
52
  - lib/existence/hash.rb
51
53
  - lib/existence/nil_class.rb
54
+ - lib/existence/numeric.rb
52
55
  - lib/existence/string.rb
56
+ - lib/existence/symbol.rb
53
57
  - lib/existence/true_class.rb
54
58
  - lib/existence/version.rb
55
- homepage:
59
+ homepage: https://github.com/joshwetzel/existence
56
60
  licenses:
57
61
  - MIT
58
- metadata: {}
59
- post_install_message:
62
+ metadata:
63
+ homepage_uri: https://github.com/joshwetzel/existence
64
+ source_code_uri: https://github.com/joshwetzel/existence
65
+ post_install_message:
60
66
  rdoc_options: []
61
67
  require_paths:
62
68
  - lib
@@ -64,15 +70,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
64
70
  requirements:
65
71
  - - ">="
66
72
  - !ruby/object:Gem::Version
67
- version: '2'
73
+ version: '3.2'
68
74
  required_rubygems_version: !ruby/object:Gem::Requirement
69
75
  requirements:
70
76
  - - ">="
71
77
  - !ruby/object:Gem::Version
72
78
  version: '0'
73
79
  requirements: []
74
- rubygems_version: 3.0.3
75
- signing_key:
80
+ rubygems_version: 3.4.19
81
+ signing_key:
76
82
  specification_version: 4
77
- summary: Exposes present? and blank? to common Ruby classes.
83
+ summary: Lightweight presence and blank checks without ActiveSupport
78
84
  test_files: []