bootstripe 0.2.14 → 0.2.15
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.
- data/lib/bootstripe/string_additions.rb +7 -1
- data/lib/bootstripe/version.rb +1 -1
- data/spec/string_additions_spec.rb +18 -0
- metadata +2 -2
@@ -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
|
data/lib/bootstripe/version.rb
CHANGED
@@ -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.
|
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-
|
12
|
+
date: 2012-10-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|