corelib 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/corelib/string/core.rb +2 -2
- data/lib/corelib/version.rb +1 -1
- data/spec/string/core_spec.rb +8 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b40273d8345128c15662dbb6b8405b9cbe478f33
|
4
|
+
data.tar.gz: 10e8b878e22f4bb36d968b528726e56b998dce83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3eed0d06beb744ac7105a1a6bf9b6755735d8db87cce9929b71569299c301934b84559b5df2e15e2a2e776953234e0a204090ebc630a0a28ff970f6ae64a724
|
7
|
+
data.tar.gz: 865b337465c7d99d0c8d91e1c5747ce4df155f1399c65317529732d8190f8887b6d9448c7070e259d6dcb759f90de89ef1a79333a7d17ed1defb3e146e53b75d
|
data/lib/corelib/string/core.rb
CHANGED
@@ -16,8 +16,8 @@ class String
|
|
16
16
|
# Combines two strings together with a separator.
|
17
17
|
def combine(str, options={})
|
18
18
|
strip = options.fetch(:strip, true)
|
19
|
-
return
|
20
|
-
return
|
19
|
+
(return strip ? self.strip : self.dup) if str.nil? or str.empty?
|
20
|
+
(return strip ? str.strip : str.dup) if self.empty?
|
21
21
|
separator = options.fetch(:separator, " ")
|
22
22
|
|
23
23
|
if strip
|
data/lib/corelib/version.rb
CHANGED
data/spec/string/core_spec.rb
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe String do
|
4
|
+
describe "#combine" do
|
5
|
+
it 'defaults work' do
|
6
|
+
"test".combine("test2").should == "test test2"
|
7
|
+
"".combine("test2").should=="test2"
|
8
|
+
"test".combine("").should == "test"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
4
12
|
describe "#to_bool" do
|
5
13
|
it 'converts to true correctly' do
|
6
14
|
"true".to_bool.should == true
|