to_b 0.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3cacdcf660b819e12f5b9aef2999bd8c6c870514
4
+ data.tar.gz: f1ac6448967fe9caef2d0171c07ff4666af8e6a8
5
+ SHA512:
6
+ metadata.gz: c840b70b5ef956f6d51e1df2c2243b98201dc289b0bfdcc40d2d28c895b7638fe2fd418a149f7050c242b8c29ea23096920b1ec56d38f61cf599e33e210c4642
7
+ data.tar.gz: 94b36b355c5b36fde396a07f70ea605c655f52324d024aad71333b15bfeaa16a06d1351c2380a990a6f265bfc47870f1e7a37c8bb275dbb2f424d30a279d27b0
data/License.md ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Ben Slaughter
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,10 @@
1
+ to_bool
2
+ =======
3
+
4
+ [![Code Climate](https://codeclimate.com/github/benSlaughter/to_bool.png)](https://codeclimate.com/github/benSlaughter/to_bool)
5
+ [![Build Status](https://travis-ci.org/benSlaughter/to_bool.png?branch=master)](https://travis-ci.org/benSlaughter/to_bool)
6
+ [![Dependency Status](https://gemnasium.com/benSlaughter/to_bool.png)](https://gemnasium.com/benSlaughter/to_bool)
7
+ [![Coverage Status](https://coveralls.io/repos/benSlaughter/to_bool/badge.png)](https://coveralls.io/r/benSlaughter/to_bool)
8
+ [![Gem Version](https://badge.fury.io/rb/to_bool.png)](http://badge.fury.io/rb/to_bool)
9
+
10
+ Extends classes to include the to_b method
data/lib/to_bool.rb ADDED
@@ -0,0 +1,10 @@
1
+ require 'to_bool/bool.rb'
2
+ require 'to_bool/version.rb'
3
+
4
+ class String
5
+ include Bool
6
+ end
7
+
8
+ class Fixnum
9
+ include Bool
10
+ end
@@ -0,0 +1,10 @@
1
+ module Bool
2
+ def to_b
3
+ case self
4
+ when /true/i, /yes/i, /t/i, /1/i, 1
5
+ true
6
+ when /false/i, /no/i, /f/i, /0/i, 0
7
+ false
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,4 @@
1
+ module Bool
2
+ VERSION = "0.0.1".freeze
3
+ DATE = "2013-09-30".freeze
4
+ end
@@ -0,0 +1,17 @@
1
+ require 'helper'
2
+
3
+ describe Fixnum do
4
+ describe "#to_b" do
5
+ it "returns true when 1" do
6
+ expect(1.to_b).to be true
7
+ end
8
+
9
+ it "returns false when 0" do
10
+ expect(0.to_b).to be false
11
+ end
12
+
13
+ it "returns nil when not 0 or 1" do
14
+ expect(2.to_b).to be nil
15
+ end
16
+ end
17
+ end
data/spec/helper.rb ADDED
@@ -0,0 +1,9 @@
1
+ require 'coveralls'
2
+
3
+ Coveralls.wear!
4
+ require 'to_bool'
5
+
6
+ RSpec.configure do |config|
7
+ config.color_enabled = true
8
+ config.formatter = :documentation
9
+ end
@@ -0,0 +1,37 @@
1
+ require 'helper'
2
+
3
+ describe String do
4
+ describe "#to_b" do
5
+ it "returns true when true" do
6
+ expect('true'.to_b).to be true
7
+ end
8
+
9
+ it "returns true when yes" do
10
+ expect('yes'.to_b).to be true
11
+ end
12
+
13
+ it "returns true when t" do
14
+ expect('t'.to_b).to be true
15
+ end
16
+
17
+ it "returns true when 1" do
18
+ expect('1'.to_b).to be true
19
+ end
20
+
21
+ it "returns false when false" do
22
+ expect('false'.to_b).to be false
23
+ end
24
+
25
+ it "returns false when no" do
26
+ expect('no'.to_b).to be false
27
+ end
28
+
29
+ it "returns false when f" do
30
+ expect('f'.to_b).to be false
31
+ end
32
+
33
+ it "returns false when 0" do
34
+ expect('0'.to_b).to be false
35
+ end
36
+ end
37
+ end
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: to_b
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ben Slaughter
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
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'
27
+ - !ruby/object:Gem::Dependency
28
+ name: yard
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
+ - !ruby/object:Gem::Dependency
42
+ name: coveralls
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 2.13.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 2.13.0
69
+ description: Converts strings and fixnum to boolean
70
+ email: b.p.slaughter@gmail.com
71
+ executables: []
72
+ extensions: []
73
+ extra_rdoc_files: []
74
+ files:
75
+ - README.md
76
+ - License.md
77
+ - lib/to_bool/bool.rb
78
+ - lib/to_bool/version.rb
79
+ - lib/to_bool.rb
80
+ - spec/fixnum_spec.rb
81
+ - spec/helper.rb
82
+ - spec/string_spec.rb
83
+ homepage: http://benslaughter.github.io/to_bool/
84
+ licenses:
85
+ - MIT
86
+ metadata: {}
87
+ post_install_message:
88
+ rdoc_options: []
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - '>='
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ requirements: []
102
+ rubyforge_project:
103
+ rubygems_version: 2.0.3
104
+ signing_key:
105
+ specification_version: 4
106
+ summary: Converts strings and fixnum to boolean
107
+ test_files:
108
+ - spec/fixnum_spec.rb
109
+ - spec/helper.rb
110
+ - spec/string_spec.rb
111
+ has_rdoc: