only_blank 1.0.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: 7ea6706cee5a7a41beeb277217cd9b864ff4e3e2e9d5d067984504b05f721424
4
+ data.tar.gz: 36abac21758e5a3bf09cf18ac2f6e1341a7c4ecd705450657fd3ab4de5bf5c51
5
+ SHA512:
6
+ metadata.gz: d8cbc9ed54cd3235d1e58f39f357e5dda1ff7f512ec9f66dbcfb02cdf0084e200eeee577bc41fa368f50801ec4973597af647485906c7047762dfdc47d6feeac
7
+ data.tar.gz: abcf289b40234c5bd0324bf69ec3131ca8f6d0662f49e380afbf12de72a5a7140226e01639dbac2c06dcadffaf5c3d1d1afb40ab76937ff8888fbf6a80ff4a23
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2021 Billy.Zheng
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,20 @@
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
+
3
+ # only_blank
4
+ A tiny library for bring the awesome `blank?` method to ruby.
5
+
6
+ ## Getting Started
7
+
8
+ Add to your Gemfile
9
+
10
+ ```rb
11
+ gem 'only_blank'
12
+
13
+ ```
14
+
15
+ ## Credits
16
+
17
+ Basically, this gem just a tiny wrapper around two library.
18
+
19
+ 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.
data/lib/blank.rb ADDED
@@ -0,0 +1,57 @@
1
+ # frozen-string-literal: true
2
+ #
3
+ # The blank extension adds the blank? method to all objects (e.g. Object#blank?).
4
+ #
5
+ # To load the extension:
6
+ #
7
+ # Sequel.extension :blank
8
+
9
+ [FalseClass, Object, NilClass, Numeric, String, TrueClass].each do |klass|
10
+ # :nocov:
11
+ if klass.method_defined?(:blank?)
12
+ klass.send(:alias_method, :blank?, :blank?)
13
+ end
14
+ # :nocov:
15
+ end
16
+
17
+ class FalseClass
18
+ # false is always blank
19
+ def blank?
20
+ true
21
+ end
22
+ end
23
+
24
+ class Object
25
+ # Objects are blank if they respond true to empty?
26
+ def blank?
27
+ respond_to?(:empty?) && empty?
28
+ end
29
+ end
30
+
31
+ class NilClass
32
+ # nil is always blank
33
+ def blank?
34
+ true
35
+ end
36
+ end
37
+
38
+ class Numeric
39
+ # Numerics are never blank (not even 0)
40
+ def blank?
41
+ false
42
+ end
43
+ end
44
+
45
+ class String
46
+ # Strings are blank if they are empty or include only whitespace
47
+ def blank?
48
+ strip.empty?
49
+ end
50
+ end
51
+
52
+ class TrueClass
53
+ # true is never blank
54
+ def blank?
55
+ false
56
+ end
57
+ end
data/lib/only_blank.rb ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'blank'
4
+ require 'fast_blank'
5
+ require "only_blank/version"
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OnlyBlank
4
+ VERSION = '1.0.0'
5
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: only_blank
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Billy.Zheng(zw963)
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-05-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: fast_blank
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: |-
42
+ A tiny library for bring the awesome `blank?` method to ruby.
43
+ Along with the fastest [fast_blank] gem for `String#blank?`.
44
+ email:
45
+ - vil963@gmail.com
46
+ executables: []
47
+ extensions: []
48
+ extra_rdoc_files: []
49
+ files:
50
+ - LICENSE
51
+ - README.md
52
+ - lib/blank.rb
53
+ - lib/only_blank.rb
54
+ - lib/only_blank/version.rb
55
+ homepage: http://github.com/zw963/only_blank
56
+ licenses:
57
+ - MIT
58
+ metadata: {}
59
+ post_install_message:
60
+ rdoc_options: []
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: 2.2.2
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ requirements: []
74
+ rubygems_version: 3.2.3
75
+ signing_key:
76
+ specification_version: 4
77
+ summary: The missing blank? method for ruby.
78
+ test_files: []