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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 93c533bebaa62ea4b896a25d283bb1201596d5ee18dd7672cb7f4c63240f4cd2
4
- data.tar.gz: 58709eeefa2fb66d5ddf932d597d00d2e0b308d805169f4d68982872b774af8b
3
+ metadata.gz: 8882815fdc3122e40733d7b9d38a60600a38a14e5729586a97e6de086d2752b0
4
+ data.tar.gz: 4fada5f40cf71fdd4be1756fcb14570d5dc260d6ab4531aa040f44fc1e20ac90
5
5
  SHA512:
6
- metadata.gz: 6322422316873ad2ef57014a01c11f14e5ab176420d33ce556bf0ffccda9cdf749469f6efb120b7585b9293c537a73208d9e4a5057bf2a776bb029485b9131ba
7
- data.tar.gz: a377c14ed0c032cb7c9ff635fb7f57fff76678c36ac584d6e29b51674d518a6a9c1ff7792ab01d014b04dd804742a2c2d6e0e624c2461d8548fde09fb0695896
6
+ metadata.gz: 1649200c8c482b5a59965a7da2af1b3d6396a24d316f740ff6c7f8b4e1cf05c800ba8f03c84c814269dd32da214ffe6c33a1d90cefc7ef52fdb246896657f1ed
7
+ data.tar.gz: 05bb7b7f0bd86ed9c5a129e4e8a33c76ed7428a570bf4b5bd772862a04a8f04afea4eccab03e96d8a6a86fc38c7744dc29275c0fd7bcb36d4bd7c8ec31f217b5
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # only_blank [![Build Status](https://travis-ci.com/zw963/only_blank.svg?branch=master)](https://travis-ci.com/zw963/only_blank) [![Gem Version](https://badge.fury.io/rb/only_blank.svg)](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
- 2. [fast_blank gem](https://github.com/SamSaffron/fast_blank), which is a simple C extension which provides a fast implementation of `String#blank?` method.
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 blank? method
63
- klass.define_method(:present?) { !blank? }
62
+ # define present?, presence method
63
+ klass.send(:define_method, :present?) { !blank? }
64
+ klass.send(:define_method, :presence) { self if present? }
64
65
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OnlyBlank
4
- VERSION = '1.1.0'
4
+ VERSION = '1.2.0'
5
5
  end
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.1.0
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-04 00:00:00.000000000 Z
11
+ date: 2021-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fast_blank