string-utility 2.6.0 → 2.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/utils.rb +6 -3
- data/spec/testcases.rb +3 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2defc994ee582faf5c459b3be066bbbf9bc590f
|
4
|
+
data.tar.gz: f72122ba8058fe44ab3146f0840bbb411faa78c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e316fd265940f7c7088d991149a049b1e3db5382b514aea73a0bf435504708092ec50008626bb6501b8124766d3963cbf584f6d3594d8588f0f77b0ae2d69379
|
7
|
+
data.tar.gz: 6198e97f447abfca20894832817b29ebebe7d8e74b24ad6f8affa93cb97dfdc9bfda4afc1c40a1d4698cb7c4d6688215c75a4eff1062863e7db10f08fe16c701
|
data/CHANGELOG.md
CHANGED
data/lib/utils.rb
CHANGED
@@ -19,19 +19,22 @@ module StringUtility
|
|
19
19
|
# of #separate.
|
20
20
|
# @return [Int] The integer version of the separated string.
|
21
21
|
def to_i_separated
|
22
|
-
self.gsub!(/\D/, '')
|
22
|
+
self.gsub!(/\D/, '') if self =~ /\D/
|
23
|
+
to_i
|
23
24
|
end
|
24
25
|
|
25
26
|
# Replaces all whitespace with underscores.
|
26
27
|
# @return [String] The string with replaced whitespace.
|
27
28
|
def underscorify
|
28
|
-
self.gsub!(/\s/, '_')
|
29
|
+
self.gsub!(/\s/, '_') if self =~ /\s/
|
30
|
+
self
|
29
31
|
end
|
30
32
|
|
31
33
|
# Replaces all underscores with whitespace.
|
32
34
|
# @return [String] The string with replaced underscores.
|
33
35
|
def spacify
|
34
|
-
self.tr!('_', ' ')
|
36
|
+
self.tr!('_', ' ') if self.include?('_')
|
37
|
+
self
|
35
38
|
end
|
36
39
|
end
|
37
40
|
|
data/spec/testcases.rb
CHANGED
@@ -12,14 +12,17 @@ class TestStringUtility < Test::Unit::TestCase
|
|
12
12
|
|
13
13
|
def test_to_i_sparated
|
14
14
|
assert_equal(1000, '1,000'.to_i_separated)
|
15
|
+
assert_equal(1000, '1000'.to_i_separated)
|
15
16
|
end
|
16
17
|
|
17
18
|
def test_underscorify
|
18
19
|
assert_equal('_', ' '.underscorify)
|
20
|
+
assert_equal('Test', 'Test'.underscorify)
|
19
21
|
end
|
20
22
|
|
21
23
|
def test_spacify
|
22
24
|
assert_equal(' ', '_'.spacify)
|
25
|
+
assert_equal('Test', 'Test'.spacify)
|
23
26
|
end
|
24
27
|
|
25
28
|
def test_random_line
|
metadata
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: string-utility
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.6.
|
4
|
+
version: 2.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eli Foster
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
13
|
+
description: |2
|
14
|
+
Some simple but handy methods to interact with string objects.
|
14
15
|
email: elifosterwy@gmail.com
|
15
16
|
executables: []
|
16
17
|
extensions: []
|