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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e3df9b4d5a7705d8d2118adba5a44523e53beb16
4
- data.tar.gz: 8ba47c57448e59c907f3ed98a46543f3774a89be
3
+ metadata.gz: d2defc994ee582faf5c459b3be066bbbf9bc590f
4
+ data.tar.gz: f72122ba8058fe44ab3146f0840bbb411faa78c8
5
5
  SHA512:
6
- metadata.gz: 461e859617e13218267d078835893f6f8bb9b8a1261f9c004870dd3b2a70f746bc505abd806f172fbb3e1744c137f518e37680efa32c14922db4272e019b554d
7
- data.tar.gz: 89b404fa66cc1d78b69603adfa0991f5746f38cf40c426293926b95d4c3fa14e688c089a7e915fd3c94a8e364db53df560aa64ca427f758c8c070fb24814680c
6
+ metadata.gz: e316fd265940f7c7088d991149a049b1e3db5382b514aea73a0bf435504708092ec50008626bb6501b8124766d3963cbf584f6d3594d8588f0f77b0ae2d69379
7
+ data.tar.gz: 6198e97f447abfca20894832817b29ebebe7d8e74b24ad6f8affa93cb97dfdc9bfda4afc1c40a1d4698cb7c4d6688215c75a4eff1062863e7db10f08fe16c701
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
  ## Version 2
3
+ ### Version 2.6.1
4
+ * Fix issue where to_i_separated, underscorify, and spacify returned nil, due to tr! and gsub! returning nil (#2).
5
+
3
6
  ### Version 2.6.0
4
7
  * Improve performance.
5
8
  * Add specs.
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/, '').to_i
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.0
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-19 00:00:00.000000000 Z
11
+ date: 2015-12-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: " Some simple but handy methods to interact with string objects.\n"
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: []