bootstripe 0.2.14 → 0.2.15

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,8 +2,14 @@ class String
2
2
  def decapitalize
3
3
  self[0, 1].downcase + self[1..-1]
4
4
  end
5
-
5
+
6
6
  def to_class
7
7
  Object.const_get(self)
8
8
  end
9
+
10
+ def to_bool
11
+ return true if self == true || self =~ (/(true|t|yes|y|1)$/i)
12
+ return false if self == false || self.empty? || self =~ (/(false|f|no|n|0)$/i)
13
+ raise ArgumentError.new("invalid value for Boolean: \"#{self}\"")
14
+ end
9
15
  end
@@ -1,3 +1,3 @@
1
1
  module Bootstripe
2
- VERSION = "0.2.14"
2
+ VERSION = "0.2.15"
3
3
  end
@@ -6,4 +6,22 @@ describe String do
6
6
  'Sweet String'.decapitalize.should eq 'sweet String'
7
7
  end
8
8
 
9
+ it 'should parse true booleans' do
10
+ "true".to_bool.should be_true
11
+ "t".to_bool.should be_true
12
+ "yes".to_bool.should be_true
13
+ "y".to_bool.should be_true
14
+ "1".to_bool.should be_true
15
+ end
16
+
17
+ it 'should parse false booleans' do
18
+ nil.to_s.to_bool.should be_false
19
+ "".to_bool.should be_false
20
+ "false".to_bool.should be_false
21
+ "f".to_bool.should be_false
22
+ "no".to_bool.should be_false
23
+ "n".to_bool.should be_false
24
+ "0".to_bool.should be_false
25
+ end
26
+
9
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootstripe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.14
4
+ version: 0.2.15
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-17 00:00:00.000000000 Z
12
+ date: 2012-10-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec