only_blank 1.1.0 → 1.2.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 +4 -4
- data/README.md +6 -2
- data/lib/blank.rb +3 -2
- data/lib/only_blank/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8882815fdc3122e40733d7b9d38a60600a38a14e5729586a97e6de086d2752b0
|
4
|
+
data.tar.gz: 4fada5f40cf71fdd4be1756fcb14570d5dc260d6ab4531aa040f44fc1e20ac90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1649200c8c482b5a59965a7da2af1b3d6396a24d316f740ff6c7f8b4e1cf05c800ba8f03c84c814269dd32da214ffe6c33a1d90cefc7ef52fdb246896657f1ed
|
7
|
+
data.tar.gz: 05bb7b7f0bd86ed9c5a129e4e8a33c76ed7428a570bf4b5bd772862a04a8f04afea4eccab03e96d8a6a86fc38c7744dc29275c0fd7bcb36d4bd7c8ec31f217b5
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# only_blank [](https://travis-ci.com/zw963/only_blank) [](http://badge.fury.io/rb/only_blank)
|
2
2
|
|
3
3
|
# only_blank
|
4
|
-
A tiny library for bring the awesome `blank?` method to ruby.
|
4
|
+
A tiny library for bring the ruby on rails awesome `blank?` method and friends to ruby.
|
5
5
|
|
6
6
|
## Getting Started
|
7
7
|
|
@@ -10,6 +10,9 @@ Add to your Gemfile
|
|
10
10
|
```rb
|
11
11
|
gem 'only_blank'
|
12
12
|
|
13
|
+
Then, you get three method `blank?`, `present?`, `presence` defined on following class.
|
14
|
+
|
15
|
+
FalseClass, Object, NilClass, Numeric, String, TrueClass.
|
13
16
|
```
|
14
17
|
|
15
18
|
## Credits
|
@@ -17,4 +20,5 @@ gem 'only_blank'
|
|
17
20
|
Basically, this gem just a tiny wrapper around two library.
|
18
21
|
|
19
22
|
1. [The sequel blank extension](https://github.com/jeremyevans/sequel/blob/master/lib/sequel/extensions/blank.rb) which implement the same blank? logic as Ruby On Rails.
|
20
|
-
|
23
|
+
|
24
|
+
2. [fast_blank gem](https://github.com/SamSaffron/fast_blank), which is a simple C extension which provides a very fast implementation of `String#blank?` method.
|
data/lib/blank.rb
CHANGED
@@ -59,6 +59,7 @@ class TrueClass
|
|
59
59
|
end
|
60
60
|
|
61
61
|
[FalseClass, Object, NilClass, Numeric, String, TrueClass].each do |klass|
|
62
|
-
# define
|
63
|
-
klass.
|
62
|
+
# define present?, presence method
|
63
|
+
klass.send(:define_method, :present?) { !blank? }
|
64
|
+
klass.send(:define_method, :presence) { self if present? }
|
64
65
|
end
|
data/lib/only_blank/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: only_blank
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Billy.Zheng(zw963)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-08-
|
11
|
+
date: 2021-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fast_blank
|