slugity 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/slugity.rb +1 -1
- data/lib/slugity/utilities.rb +7 -0
- data/lib/slugity/version.rb +1 -1
- data/spec/accented_character_spec.rb +1 -1
- data/spec/slugity_spec.rb +5 -0
- metadata +2 -2
data/lib/slugity.rb
CHANGED
@@ -20,7 +20,7 @@ module Slugity
|
|
20
20
|
# @param matcher [Symbol] the matcher to use
|
21
21
|
# @return [String] the converted version of the provided string
|
22
22
|
def stringity string, matcher=:default
|
23
|
-
string = Util.
|
23
|
+
string = Util.normalize_string( string )
|
24
24
|
|
25
25
|
Slugity::Matchers.use(matcher).each do |match, replacement|
|
26
26
|
string.gsub!( match, replacement )
|
data/lib/slugity/utilities.rb
CHANGED
@@ -3,6 +3,13 @@ module Slugity
|
|
3
3
|
|
4
4
|
class << self
|
5
5
|
|
6
|
+
def normalize_string string
|
7
|
+
trim_string(string.to_s)
|
8
|
+
rescue NoMethodError
|
9
|
+
raise ArgumentError, "You must pass an object that respond to #to_s"
|
10
|
+
end
|
11
|
+
|
12
|
+
|
6
13
|
# Trims begining and ending spaces from the string
|
7
14
|
#
|
8
15
|
# @param string [String]
|
data/lib/slugity/version.rb
CHANGED
data/spec/slugity_spec.rb
CHANGED
@@ -26,6 +26,11 @@ describe Slugity do
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
+
it "handles non-strings like numbers" do
|
30
|
+
slugity( 42 ).should == "42"
|
31
|
+
slugity( 123.456 ).should == "123456"
|
32
|
+
end
|
33
|
+
|
29
34
|
it "strips unrecognized characters" do
|
30
35
|
slugity( "a…‡†i".encode("UTF-8") ).should == "ai"
|
31
36
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slugity
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
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: 2013-05-
|
12
|
+
date: 2013-05-29 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: ! ' Yet another slugging gem, convert a string to a slug with the option
|
15
15
|
for custom mappings. '
|