extends_bool 0.1.0 → 0.2.1
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/.travis.yml +12 -3
- data/CHANGELOG.md +25 -0
- data/Gemfile.lock +2 -2
- data/README.md +13 -9
- data/extends_bool.gemspec +8 -2
- data/lib/extends_bool.rb +6 -1
- data/lib/extends_bool/version.rb +1 -1
- metadata +9 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 809f0d7fed10f6fa63b7b10d248358b2b34a313915ec7c219112da59194facb3
|
4
|
+
data.tar.gz: 17d7fb0f4d949f772d86730fb23fa53b416c86528b7980719a11abdf48751b2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3087eebefe22f1fd5c005060da0ecc186cdbee15bb3f98bd180db1512ecfcec542db6d6c9b624eb6c8eb7ddb6f7ec01cd8f6e7625d125219e740616ffa3c2d3
|
7
|
+
data.tar.gz: 92517ac8715861dcbdc4c7db11f807363a0fafd25cd21317d9d5153d96df76b8a31aabdb8d52a0dc794df4e7a23c7f1bae656cb1df046a5754a538ba0bffabf2
|
data/.travis.yml
CHANGED
@@ -1,5 +1,14 @@
|
|
1
|
-
sudo: false
|
2
1
|
language: ruby
|
3
|
-
|
2
|
+
|
3
|
+
rvm:
|
4
4
|
- 2.5.1
|
5
|
-
|
5
|
+
|
6
|
+
notifications:
|
7
|
+
email:
|
8
|
+
- andreluizleoni@gmail.com
|
9
|
+
|
10
|
+
before_install:
|
11
|
+
- gem install bundler -v 1.16.2
|
12
|
+
|
13
|
+
script:
|
14
|
+
- bundle exec rspec
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## Version 0.2.1
|
4
|
+
|
5
|
+
* Update doc
|
6
|
+
|
7
|
+
## Version 0.2.0
|
8
|
+
|
9
|
+
* Added the behaviour to ignore case_sensitive to string values, when "f", "false", "off".
|
10
|
+
* Added the alias `.to_b`, `.to_boolean` to the default `.to_bool`.
|
11
|
+
|
12
|
+
## Version 0.1.0
|
13
|
+
|
14
|
+
First version. Created the `to_bool` behaviour to the follow classes:
|
15
|
+
|
16
|
+
* String
|
17
|
+
* Integer
|
18
|
+
* Float
|
19
|
+
* Array
|
20
|
+
* Hash
|
21
|
+
* TrueClass
|
22
|
+
* FalseClass
|
23
|
+
* NilClass
|
24
|
+
|
25
|
+
False values: `[nil, false, 0, 0.0, "", "0", "f", "F", "false", "FALSE", "off", "OFF", [], {}]`
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,18 @@
|
|
1
1
|
# ExtendsBool
|
2
2
|
|
3
|
-
|
3
|
+
[](https://codeclimate.com/github/andreleoni/extends_bool/maintainability)
|
4
|
+
[](https://travis-ci.com/andreleoni/extends_bool)
|
4
5
|
|
5
|
-
|
6
|
+
Add `.to_bool` behaviour to the follow classes:
|
7
|
+
|
8
|
+
* String
|
9
|
+
* Integer
|
10
|
+
* Float
|
11
|
+
* Array
|
12
|
+
* Hash
|
13
|
+
* TrueClass
|
14
|
+
* FalseClass
|
15
|
+
* NilClass
|
6
16
|
|
7
17
|
## Installation
|
8
18
|
|
@@ -22,13 +32,7 @@ Or install it yourself as:
|
|
22
32
|
|
23
33
|
## Usage
|
24
34
|
|
25
|
-
|
26
|
-
|
27
|
-
## Development
|
28
|
-
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
-
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
35
|
+
Simple, if the variable have any of `[nil, false, 0, 0.0, "", "0", "f", "F", "false", "FALSE", "off", "OFF", [], {}]` values, will return `false`, else, returns `true`.
|
32
36
|
|
33
37
|
## Contributing
|
34
38
|
|
data/extends_bool.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = ExtendsBool::VERSION
|
9
9
|
spec.authors = ["André Leoni"]
|
10
10
|
spec.email = ["andreluizleoni@gmail.com"]
|
11
|
-
spec.summary = %q{Adds
|
12
|
-
spec.description = %q{Adds
|
11
|
+
spec.summary = %q{Adds ".to_bool" behaviour to String, Integer, Float, Array, Hash, TrueClass, FalseClass and NilClass.}
|
12
|
+
spec.description = %q{Adds ".to_bool" behaviour to String, Integer, Float, Array, Hash, TrueClass, FalseClass and NilClass.}
|
13
13
|
spec.homepage = "https://github.com/andreleoni/extends_bool"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
@@ -22,6 +22,12 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
23
|
spec.require_paths = ["lib"]
|
24
24
|
|
25
|
+
spec.metadata = {
|
26
|
+
"changelog_uri" => "https://github.com/andreleoni/extends_bool/blob/master/CHANGELOG.md",
|
27
|
+
"homepage_uri" => "https://github.com/andreleoni/extends_bool",
|
28
|
+
"source_code_uri" => "https://github.com/andreleoni/extends_bool"
|
29
|
+
}
|
30
|
+
|
25
31
|
spec.add_development_dependency "bundler", "~> 1.16"
|
26
32
|
spec.add_development_dependency "rake", "~> 10.0"
|
27
33
|
spec.add_development_dependency "rspec", "~> 3.0"
|
data/lib/extends_bool.rb
CHANGED
@@ -1,13 +1,18 @@
|
|
1
1
|
require "extends_bool/version"
|
2
2
|
|
3
3
|
module ExtendsBool
|
4
|
-
FALSE_VALUES = [nil, false, 0, 0.0, "", "0", "f", "
|
4
|
+
FALSE_VALUES = [nil, false, 0, 0.0, "", "0", "f", "false", "off", [], {}]
|
5
5
|
|
6
6
|
# Returns a boolean value, according the object value.
|
7
7
|
#
|
8
8
|
def to_bool
|
9
|
+
value = self
|
10
|
+
value.downcase! if value.is_a?(String)
|
9
11
|
!FALSE_VALUES.include?(self)
|
10
12
|
end
|
13
|
+
|
14
|
+
alias_method :to_b, :to_bool
|
15
|
+
alias_method :to_boolean, :to_bool
|
11
16
|
end
|
12
17
|
|
13
18
|
# Add the to_bool behaviour to all the follow classes:
|
data/lib/extends_bool/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: extends_bool
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- André Leoni
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,7 +52,7 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
-
description: Adds
|
55
|
+
description: Adds ".to_bool" behaviour to String, Integer, Float, Array, Hash, TrueClass,
|
56
56
|
FalseClass and NilClass.
|
57
57
|
email:
|
58
58
|
- andreluizleoni@gmail.com
|
@@ -63,6 +63,7 @@ files:
|
|
63
63
|
- ".gitignore"
|
64
64
|
- ".rspec"
|
65
65
|
- ".travis.yml"
|
66
|
+
- CHANGELOG.md
|
66
67
|
- CODE_OF_CONDUCT.md
|
67
68
|
- Gemfile
|
68
69
|
- Gemfile.lock
|
@@ -77,7 +78,10 @@ files:
|
|
77
78
|
homepage: https://github.com/andreleoni/extends_bool
|
78
79
|
licenses:
|
79
80
|
- MIT
|
80
|
-
metadata:
|
81
|
+
metadata:
|
82
|
+
changelog_uri: https://github.com/andreleoni/extends_bool/blob/master/CHANGELOG.md
|
83
|
+
homepage_uri: https://github.com/andreleoni/extends_bool
|
84
|
+
source_code_uri: https://github.com/andreleoni/extends_bool
|
81
85
|
post_install_message:
|
82
86
|
rdoc_options: []
|
83
87
|
require_paths:
|
@@ -97,6 +101,6 @@ rubyforge_project:
|
|
97
101
|
rubygems_version: 2.7.8
|
98
102
|
signing_key:
|
99
103
|
specification_version: 4
|
100
|
-
summary: Adds
|
104
|
+
summary: Adds ".to_bool" behaviour to String, Integer, Float, Array, Hash, TrueClass,
|
101
105
|
FalseClass and NilClass.
|
102
106
|
test_files: []
|