to_boolean 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 630ea71e183336c8fd538752b4f3261ae6240bb4
4
+ data.tar.gz: 954d061a4d5bf9525c32b4a73a105d5534872106
5
+ SHA512:
6
+ metadata.gz: a1369c0181be07483f9015a542a9ac829f549219d13da61e4e39c684af614d6703dbcabe6b487e1a8fd00dafb4bfd0619bf2580fb6fad3b4e5c1c7a783964159
7
+ data.tar.gz: 3194100d2f33c7c733835fc16e2be8fcd2a2a5bcd0b26245b1f18b6942a6a75745e14900c90c3540dd6dcd2712718b1f61a195a5920c36b889421c45329561cf
data/lib/to_boolean.rb ADDED
@@ -0,0 +1,6 @@
1
+ class Object
2
+ def to_boolean
3
+ value = self.is_a?(String) ? self.downcase : self
4
+ [true, 'true', 1, '1'].include?(value)
5
+ end
6
+ end
@@ -0,0 +1,7 @@
1
+ require 'minitest/spec'
2
+ require 'minitest/autorun'
3
+ require 'minitest/reporters'
4
+
5
+ require 'to_boolean'
6
+
7
+ Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
@@ -0,0 +1,17 @@
1
+ require_relative 'spec_helper'
2
+
3
+ class TestToBoolean < Minitest::Spec
4
+ describe TestToBoolean do
5
+ it 'should return true' do
6
+ [true, 'true', 'TRUE', 1, '1'].each do |value|
7
+ value.to_boolean.must_equal(true)
8
+ end
9
+ end
10
+
11
+ it 'should return false' do
12
+ [false, 'false', 'FALSE', 0, '0', nil, :symbol].each do |value|
13
+ value.to_boolean.must_equal(false)
14
+ end
15
+ end
16
+ end
17
+ end
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: to_boolean
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Jani Jegoroff
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-10 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: minitest
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: minitest-reporters
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
+ description: Ruby core extension that converts string and integer values to boolean.
56
+ email:
57
+ - jani.jegoroff@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - lib/to_boolean.rb
63
+ - spec/spec_helper.rb
64
+ - spec/spec_to_boolean.rb
65
+ homepage: http://github.com/JaniJegoroff/to_boolean
66
+ licenses:
67
+ - MIT
68
+ metadata: {}
69
+ post_install_message:
70
+ rdoc_options: []
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ requirements: []
84
+ rubyforge_project:
85
+ rubygems_version: 2.2.2
86
+ signing_key:
87
+ specification_version: 4
88
+ summary: Simple gem that provides to_boolean method.
89
+ test_files:
90
+ - spec/spec_helper.rb
91
+ - spec/spec_to_boolean.rb