to_bool 1.2.0 → 2.1.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: 339332280a7ae12035e5394e891f10edcf188f5ab9becd14c5b3e658ed2c8c8f
4
- data.tar.gz: 86c824068e09632279c4d8cd8ec4f2b5122eab07c653f2c1dccbd8479c18dd87
3
+ metadata.gz: 9ac619060f8d31344eb7690663105cf9f70dc0dbde03baf7638039ff26d0f821
4
+ data.tar.gz: 68c4d0360c67d7e851c4c9765718d5e653efe553c70c2ab7ada53e5cc047b8bc
5
5
  SHA512:
6
- metadata.gz: 5017ce492d24190a1a42fe1ba657bbdf4dc9805ba7897ad5c256a5bd4f79916b401fa549966b8c16bb44a0cf24764eee62cccb917143f4e09096db5d95c4e5ef
7
- data.tar.gz: 867d3180521e6c72c5aa1a412fba8c0469998c4e906d5dcb96a2c832dbe5173ff30f4b65b622384ff1b6e1e3e91aca2826605895da42df7c60be32a8a784ada6
6
+ metadata.gz: 85c97a718b42dd6a241c0d27a7aebec592624c237fef131aea87dcea3735680a722686d36702e9813296651863fa30c748bb8b31787b31b4a70b5ed775659944
7
+ data.tar.gz: e2c748c117fc2561d31ad201370f4b1d101be3ac3b9502c5fb86583e537cd4803df7e5490b0ceb7af76ee240eacddc246de754a4108f825261d03e756e6c3998
data/lib/to_bool.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  class String
2
2
  def to_bool
3
- %w{ 1 true yes t }.include? self.downcase
3
+ %w{ 1 true yes t y }.include? self.downcase
4
4
  end
5
5
 
6
6
  alias to_boolean to_bool
data/spec/to_bool_spec.rb CHANGED
@@ -1,95 +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 '1'" do
14
- expect("1".to_bool).to eq true
15
- end
16
-
17
- it "is true if 'true'" do
18
- expect("true".to_bool).to eq true
19
- end
20
-
21
- it "is true if 'TRUE'" do
22
- expect("TRUE".to_bool).to eq true
23
- end
24
-
25
- it "is true if 't'" do
26
- expect("t".to_bool).to eq true
27
- end
28
-
29
- it "is true if 'T'" do
30
- expect("T".to_bool).to eq true
31
- end
32
-
33
- it "is false otherwise" do
34
- expect("no".to_bool).to eq false
35
- expect("false".to_bool).to eq false
36
- expect("0".to_bool).to eq false
37
- end
38
-
39
- it "is true when using to_boolean" do
40
- expect("true".to_boolean).to eq true
41
- end
42
- end
43
-
44
- describe "Integer" do
45
- it "is true if 1" do
46
- expect(1.to_bool).to eq true
47
- end
48
-
49
- it "is false otherwise" do
50
- expect(0.to_bool).to eq false
51
- end
52
-
53
- it "is true when using to_boolean" do
54
- expect(1.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 "TrueClass" do
59
- it "is true" do
60
- expect(true.to_bool).to eq true
61
- end
62
-
63
- it "is true when using to_boolean" do
64
- expect(true.to_boolean).to eq true
65
- end
66
- end
67
-
68
- describe "Object" do
69
- it "is false by default" do
70
- expect(Object.new.to_bool).to eq false
71
- end
72
-
73
- it "is false when using to_boolean" do
74
- expect(Object.new.to_boolean).to eq false
75
- end
76
- end
77
-
78
- describe "Symbol" do
79
- it "is true if :true" do
80
- expect(:true.to_bool).to eq true
81
- end
82
-
83
- it "is true if :TRUE" do
84
- expect(:TRUE.to_bool).to eq true
85
- end
86
-
87
- it "is false otherwise" do
88
- expect(:false.to_bool).to eq false
89
- expect(:hoge.to_bool).to eq false
90
- end
91
-
92
- it "is true when using to_boolean" do
93
- expect(:true.to_bool).to eq true
94
- end
95
- 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,46 +1,28 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: to_bool
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.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: 2018-09-10 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
- - Gemfile
37
- - README.md
38
- - Rakefile
39
21
  - lib/to_bool.rb
40
22
  - spec/to_bool_spec.rb
41
- - to_bool.gemspec
42
23
  homepage: http://github.com/bricker/to_bool
43
- licenses: []
24
+ licenses:
25
+ - MIT
44
26
  metadata: {}
45
27
  post_install_message:
46
28
  rdoc_options: []
@@ -57,8 +39,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
57
39
  - !ruby/object:Gem::Version
58
40
  version: '0'
59
41
  requirements: []
60
- rubyforge_project:
61
- rubygems_version: 2.7.6
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/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"`, 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 = "1.2.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