to_bool 1.1.0 → 1.2.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: 04a652783b660a09e1e4ee760a7b0cfd33ee5b59d40007014801220519c00031
4
- data.tar.gz: ec92c3478486cec25f766c5a8edcfcad4774f2ff203a89433326bbe257c89c8a
3
+ metadata.gz: 339332280a7ae12035e5394e891f10edcf188f5ab9becd14c5b3e658ed2c8c8f
4
+ data.tar.gz: 86c824068e09632279c4d8cd8ec4f2b5122eab07c653f2c1dccbd8479c18dd87
5
5
  SHA512:
6
- metadata.gz: fc02600d89b7800a3519f7412727e2a437b7a57cc2c73b4ad6669b422b7e833254f9f3de13067af7ccc3693787d748026661e36dec863e7216c4f10c7ec8e0d1
7
- data.tar.gz: e22d990b2df6806629134f78aaabd20bb46c399cc9ce194c5a41652c08fef836bc2d8ea9993b3f47159f597d78ab8f7a1d6c05b8a64d5b436b366b7c35df86ab
6
+ metadata.gz: 5017ce492d24190a1a42fe1ba657bbdf4dc9805ba7897ad5c256a5bd4f79916b401fa549966b8c16bb44a0cf24764eee62cccb917143f4e09096db5d95c4e5ef
7
+ data.tar.gz: 867d3180521e6c72c5aa1a412fba8c0469998c4e906d5dcb96a2c832dbe5173ff30f4b65b622384ff1b6e1e3e91aca2826605895da42df7c60be32a8a784ada6
data/README.md CHANGED
@@ -15,7 +15,7 @@ Call `to_bool` on any object. It will *usually* return false, except:
15
15
  * String: `"true"`, `"1"`, and `"yes"` are true
16
16
  * Integer: `1` is true
17
17
  * TrueClass: `true` is true
18
- * Symbol: :true is true
18
+ * Symbol: `:true` is true
19
19
 
20
20
  See the spec, it pretty much maps it out.
21
21
 
@@ -3,7 +3,7 @@ class String
3
3
  %w{ 1 true yes t }.include? self.downcase
4
4
  end
5
5
 
6
- alias_method :to_boolean, :to_bool
6
+ alias to_boolean to_bool
7
7
  end
8
8
 
9
9
  class Integer
@@ -11,7 +11,7 @@ class Integer
11
11
  self == 1
12
12
  end
13
13
 
14
- alias_method :to_boolean, :to_bool
14
+ alias to_boolean to_bool
15
15
  end
16
16
 
17
17
 
@@ -20,7 +20,7 @@ class TrueClass
20
20
  self
21
21
  end
22
22
 
23
- alias_method :to_boolean, :to_bool
23
+ alias to_boolean to_bool
24
24
  end
25
25
 
26
26
  class Object
@@ -28,13 +28,13 @@ class Object
28
28
  false
29
29
  end
30
30
 
31
- alias_method :to_boolean, :to_bool
31
+ alias to_boolean to_bool
32
32
  end
33
33
 
34
34
  class Symbol
35
35
  def to_bool
36
- self == :true
36
+ self.downcase == :true
37
37
  end
38
38
 
39
- alias_method :to_boolean, :to_bool
39
+ alias to_boolean to_bool
40
40
  end
@@ -2,18 +2,34 @@ require 'bundler/setup'
2
2
  Bundler.require
3
3
 
4
4
  describe "String" do
5
- it "is true if yes" do
5
+ it "is true if 'yes'" do
6
6
  expect("yes".to_bool).to eq true
7
7
  end
8
-
8
+
9
+ it "is true if 'YES'" do
10
+ expect("YES".to_bool).to eq true
11
+ end
12
+
9
13
  it "is true if '1'" do
10
14
  expect("1".to_bool).to eq true
11
15
  end
12
-
16
+
13
17
  it "is true if 'true'" do
14
18
  expect("true".to_bool).to eq true
15
19
  end
16
-
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
+
17
33
  it "is false otherwise" do
18
34
  expect("no".to_bool).to eq false
19
35
  expect("false".to_bool).to eq false
@@ -64,6 +80,10 @@ describe "Symbol" do
64
80
  expect(:true.to_bool).to eq true
65
81
  end
66
82
 
83
+ it "is true if :TRUE" do
84
+ expect(:TRUE.to_bool).to eq true
85
+ end
86
+
67
87
  it "is false otherwise" do
68
88
  expect(:false.to_bool).to eq false
69
89
  expect(:hoge.to_bool).to eq false
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |gem|
6
6
  gem.name = "to_bool"
7
- gem.version = "1.1.0"
7
+ gem.version = "1.2.0"
8
8
  gem.authors = ["Bryan Ricker"]
9
9
  gem.email = ["bryancricker@gmail.com"]
10
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.}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: to_bool
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
  - Bryan Ricker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-18 00:00:00.000000000 Z
11
+ date: 2018-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec