to_bool 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f74c30f848ad6c680456ade1596e64e56cf300a4679fc043994b731daa77d9d8
4
- data.tar.gz: 0b138f38fa312c2ff228873db0f04c77dc79f6edffd19bd0772527dae0a3eed0
3
+ metadata.gz: 9ac619060f8d31344eb7690663105cf9f70dc0dbde03baf7638039ff26d0f821
4
+ data.tar.gz: 68c4d0360c67d7e851c4c9765718d5e653efe553c70c2ab7ada53e5cc047b8bc
5
5
  SHA512:
6
- metadata.gz: d4d3b41a40a2cbc59e5c315879e1f6029c00d975ff6683c9ea6f9a151e7ad88e12284ddff4d69fe83797ca4d1c1f7f3129c6a127e59ed54946f5845fdcb63b20
7
- data.tar.gz: 7476fb2ee6902dfdf34d0c43467b8d1bf51c9aad895acd58cb9ca2f89c5f52df20ebe19806aff66ff049b9fbc0f21ec5e9b72b3ed996f561c03d8a08f0bbdbb1
6
+ metadata.gz: 85c97a718b42dd6a241c0d27a7aebec592624c237fef131aea87dcea3735680a722686d36702e9813296651863fa30c748bb8b31787b31b4a70b5ed775659944
7
+ data.tar.gz: e2c748c117fc2561d31ad201370f4b1d101be3ac3b9502c5fb86583e537cd4803df7e5490b0ceb7af76ee240eacddc246de754a4108f825261d03e756e6c3998
data/spec/to_bool_spec.rb CHANGED
@@ -1,109 +1,49 @@
1
1
  require 'bundler/setup'
2
2
  Bundler.require
3
3
 
4
- describe "String" do
5
- it "is true if 'yes'" do
6
- expect("yes".to_bool).to eq true
7
- end
8
-
9
- it "is true if 'YES'" do
10
- expect("YES".to_bool).to eq true
11
- end
12
-
13
- it "is true if 'y'" do
14
- expect("y".to_bool).to eq true
15
- end
16
-
17
- it "is true if 'Y'" do
18
- expect("Y".to_bool).to eq true
19
- end
20
-
21
- it "is true if '1'" do
22
- expect("1".to_bool).to eq true
23
- end
24
-
25
- it "is true if 'true'" do
26
- expect("true".to_bool).to eq true
27
- end
28
-
29
- it "is true if 'TRUE'" do
30
- expect("TRUE".to_bool).to eq true
31
- end
32
-
33
- it "is true if 't'" do
34
- expect("t".to_bool).to eq true
35
- end
36
-
37
- it "is true if 'T'" do
38
- expect("T".to_bool).to eq true
39
- end
40
-
41
- it "is false otherwise" do
42
- expect("no".to_bool).to eq false
43
- expect("NO".to_bool).to eq false
44
- expect("n".to_bool).to eq false
45
- expect("N".to_bool).to eq false
46
- expect("false".to_bool).to eq false
47
- expect("FALSE".to_bool).to eq false
48
- expect("f".to_bool).to eq false
49
- expect("F".to_bool).to eq false
50
- expect("0".to_bool).to eq false
51
- end
52
-
53
- it "is true when using to_boolean" do
54
- expect("true".to_boolean).to eq true
55
- end
4
+ def assert(expected, actual)
5
+ raise "Failed Assertion" if expected != actual
56
6
  end
57
7
 
58
- describe "Integer" do
59
- it "is true if 1" do
60
- expect(1.to_bool).to eq true
61
- end
62
-
63
- it "is false otherwise" do
64
- expect(0.to_bool).to eq false
65
- end
66
-
67
- it "is true when using to_boolean" do
68
- expect(1.to_boolean).to eq true
69
- end
70
- end
71
-
72
- describe "TrueClass" do
73
- it "is true" do
74
- expect(true.to_bool).to eq true
75
- end
76
-
77
- it "is true when using to_boolean" do
78
- expect(true.to_boolean).to eq true
79
- end
80
- end
81
-
82
- describe "Object" do
83
- it "is false by default" do
84
- expect(Object.new.to_bool).to eq false
85
- end
86
-
87
- it "is false when using to_boolean" do
88
- expect(Object.new.to_boolean).to eq false
89
- end
90
- end
91
-
92
- describe "Symbol" do
93
- it "is true if :true" do
94
- expect(:true.to_bool).to eq true
95
- end
96
-
97
- it "is true if :TRUE" do
98
- expect(:TRUE.to_bool).to eq true
99
- end
100
-
101
- it "is false otherwise" do
102
- expect(:false.to_bool).to eq false
103
- expect(:hoge.to_bool).to eq false
104
- end
105
-
106
- it "is true when using to_boolean" do
107
- expect(:true.to_bool).to eq true
108
- end
109
- end
8
+ # String
9
+ assert(true, "yes".to_bool)
10
+ assert(true, "YES".to_bool)
11
+ assert(true, "y".to_bool)
12
+ assert(true, "Y".to_bool)
13
+ assert(true, "1".to_bool)
14
+ assert(true, "true".to_bool)
15
+ assert(true, "TRUE".to_bool)
16
+ assert(true, "t".to_bool)
17
+ assert(true, "T".to_bool)
18
+ assert(true, "true".to_boolean)
19
+
20
+ assert(false, "no".to_bool)
21
+ assert(false, "NO".to_bool)
22
+ assert(false, "n".to_bool)
23
+ assert(false, "N".to_bool)
24
+ assert(false, "false".to_bool)
25
+ assert(false, "FALSE".to_bool)
26
+ assert(false, "f".to_bool)
27
+ assert(false, "F".to_bool)
28
+ assert(false, "0".to_bool)
29
+
30
+ # Integer
31
+ assert(true, 1.to_bool)
32
+ assert(true, 1.to_boolean)
33
+ assert(false, 0.to_bool)
34
+
35
+ # TrueClass
36
+ assert(true, true.to_bool)
37
+ assert(true, true.to_boolean)
38
+ assert(false, false.to_boolean)
39
+
40
+ # Object
41
+ assert(false, Object.new.to_bool)
42
+ assert(false, Object.new.to_boolean)
43
+
44
+ # Symbol
45
+ assert(true, :true.to_bool)
46
+ assert(true, :TRUE.to_bool)
47
+ assert(false, :false.to_bool)
48
+ assert(false, :hoge.to_bool)
49
+ assert(true, :true.to_boolean)
metadata CHANGED
@@ -1,47 +1,28 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: to_bool
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Ricker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-23 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: rspec
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
11
+ date: 2023-11-10 00:00:00.000000000 Z
12
+ dependencies: []
27
13
  description: Super-simple gem that extends some Ruby classes with a "to_bool" method,
28
14
  which converts any object naturally into a boolean.
29
15
  email:
30
- - bryancricker@gmail.com
16
+ - rubygems@bryanricker.com
31
17
  executables: []
32
18
  extensions: []
33
19
  extra_rdoc_files: []
34
20
  files:
35
- - ".gitignore"
36
- - CHANGELOG.md
37
- - Gemfile
38
- - README.md
39
- - Rakefile
40
21
  - lib/to_bool.rb
41
22
  - spec/to_bool_spec.rb
42
- - to_bool.gemspec
43
23
  homepage: http://github.com/bricker/to_bool
44
- licenses: []
24
+ licenses:
25
+ - MIT
45
26
  metadata: {}
46
27
  post_install_message:
47
28
  rdoc_options: []
@@ -58,7 +39,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
39
  - !ruby/object:Gem::Version
59
40
  version: '0'
60
41
  requirements: []
61
- rubygems_version: 3.0.3
42
+ rubygems_version: 3.4.10
62
43
  signing_key:
63
44
  specification_version: 4
64
45
  summary: Convert any object naturally into a boolean
data/.gitignore DELETED
@@ -1,18 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
18
- .idea/*
data/CHANGELOG.md DELETED
@@ -1,4 +0,0 @@
1
- # Changelog
2
-
3
- ## 2.0.0
4
- - Added "y" as truthy value for String (Gustav Bertram)
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in to_bool.gemspec
4
- gemspec
data/README.md DELETED
@@ -1,35 +0,0 @@
1
- # ToBool
2
-
3
- Natural coercion into boolean (true / false). Useful for API interaction.
4
-
5
-
6
- ## Installation
7
-
8
- `gem "to_bool"`
9
-
10
-
11
- ## Usage
12
-
13
- Call `to_bool` on any object. It will *usually* return false, except:
14
-
15
- * String: `"true"`, `"1"`, `"y"`, and `"yes"` are true
16
- * Integer: `1` is true
17
- * TrueClass: `true` is true
18
- * Symbol: `:true` is true
19
-
20
- See the spec, it pretty much maps it out.
21
-
22
- ## Contributing
23
-
24
- Yes!
25
-
26
- ### Running Tests
27
-
28
- ```
29
- bundle exec rspec
30
- ```
31
-
32
-
33
- ## License
34
-
35
- MIT
data/Rakefile DELETED
@@ -1,3 +0,0 @@
1
- require "bundler/gem_tasks"
2
- RSpec::Core::RakeTask.new(:spec)
3
- task :default => "spec"
data/to_bool.gemspec DELETED
@@ -1,20 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
-
5
- Gem::Specification.new do |gem|
6
- gem.name = "to_bool"
7
- gem.version = "2.0.0"
8
- gem.authors = ["Bryan Ricker"]
9
- gem.email = ["bryancricker@gmail.com"]
10
- gem.description = %q{Super-simple gem that extends some Ruby classes with a "to_bool" method, which converts any object naturally into a boolean.}
11
- gem.summary = %q{Convert any object naturally into a boolean}
12
- gem.homepage = "http://github.com/bricker/to_bool"
13
-
14
- gem.files = `git ls-files`.split($/)
15
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
16
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
17
- gem.require_paths = ["lib"]
18
-
19
- gem.add_development_dependency "rspec", [">= 0"]
20
- end