string_helpers 0.0.2 → 0.1.0

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/README.md CHANGED
@@ -15,22 +15,28 @@ gem string_helpers
15
15
  ## Usage
16
16
  Slug
17
17
  ```sh
18
- "Jhon Doe".slug #=> "Jhon-Doe"
18
+ "Jhon Doe".slug! #=> "Jhon-Doe"
19
+ ```
20
+ Sluged?
21
+ ```sh
22
+ "Jhon Doe".sluged? #=> false
23
+ "Jhon-Doe".sluged? #=> true
24
+ "Jhon---".sluged? #=> true
25
+ "Jhon".sluged? #=> true
19
26
  ```
20
27
 
21
28
  Fill
22
29
  ```sh
23
- "Jhon Doe".slug
24
- => "Jhon Doe".fill 10 #=> "Jhon Doe "
30
+ "Jhon Doe".fill!(10) #=> "Jhon Doe "
25
31
 
26
- "Jhon Doe".fill 5 #=> "Jhon..."
32
+ "Jhon Doe".fill(5) #=> "Jhon..."
27
33
  ```
28
34
 
29
35
  Apostrophe's
30
36
  ```sh
31
- "Jhon Doe".apostrophe #=> "Jhon Doe’s"
37
+ "Jhon Doe".apostrophe! #=> "Jhon Doe’s"
32
38
 
33
- "Marrys".apostrophe #=> "Marrys’"
39
+ "Marrys".apostrophe! #=> "Marrys’"
34
40
  ```
35
41
 
36
42
  Camelize
@@ -2,18 +2,21 @@
2
2
  include StringHelpers
3
3
 
4
4
  String.class_eval do
5
- def slug
5
+ def slug!
6
6
  self.gsub(" ", "-")
7
7
  end
8
-
9
- def fill characters
8
+
9
+ def sluged?
10
+ !self.include?(" ")
11
+ end
12
+
13
+ def fill! chars = 5
10
14
  length = self.length
11
- chars = characters - 1
12
- return self[0..chars] << "..." if length > characters
13
- self << "\s" * (characters - length) if length < characters
15
+ return self[0..(chars - 1)] << "..." if length > chars
16
+ self << "\s" * (chars - length)
14
17
  end
15
18
 
16
- def apostrophe
19
+ def apostrophe!
17
20
  self << (self[-1,1] == APOSTROPHE_VALIDATE ? APOSTROPHE_CHAR : (APOSTROPHE_CHAR + APOSTROPHE_VALIDATE))
18
21
  end
19
22
 
@@ -1,3 +1,3 @@
1
1
  module StringHelpers
2
- VERSION = "0.0.2"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -5,25 +5,30 @@ require 'string_helpers'
5
5
  include StringHelpers
6
6
 
7
7
  class StringHelpersTest < Test::Unit::TestCase
8
- def test_string_slug
9
- assert_equal "Jhon-Doe", "Jhon Doe".slug
8
+ def test_string_slug!
9
+ assert_equal "Jhon-Doe", "Jhon Doe".slug!
10
10
  end
11
11
 
12
- def test_string_fill
13
- assert_equal "Jhon...", "Jhon Doe".fill(4)
12
+ def test_string_slug?
13
+ string = "Jhon Doe".slug!
14
+ assert_equal true, string.sluged?
14
15
  end
15
16
 
16
- def test_string_camelize
17
+ def test_string_fill!
18
+ assert_equal "Jhon...", "Jhon Doe".fill!(4)
19
+ end
20
+
21
+ def test_string_camelize!
17
22
  assert_equal "JhonDoe", "jhon doe".camelize!
18
23
  end
19
24
 
20
- def test_string_apostrophe
25
+ def test_string_apostrophe!
21
26
  word = "Marry#{APOSTROPHE_CHAR}#{APOSTROPHE_VALIDATE}"
22
- assert_equal word, "Marry".apostrophe
27
+ assert_equal word, "Marry".apostrophe!
23
28
  end
24
29
 
25
- def test_string_apotrophe_with_s
30
+ def test_string_apotrophe_with_s!
26
31
  word = "Marry#{APOSTROPHE_VALIDATE}#{APOSTROPHE_CHAR}"
27
- assert_equal word, "Marry#{APOSTROPHE_VALIDATE}".apostrophe
32
+ assert_equal word, "Marry#{APOSTROPHE_VALIDATE}".apostrophe!
28
33
  end
29
34
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: string_helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: