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 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.trim_string( string )
23
+ string = Util.normalize_string( string )
24
24
 
25
25
  Slugity::Matchers.use(matcher).each do |match, replacement|
26
26
  string.gsub!( match, replacement )
@@ -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]
@@ -1,3 +1,3 @@
1
1
  module Slugity
2
- VERSION = '0.3.0'
2
+ VERSION = '0.4.0'
3
3
  end
@@ -898,7 +898,7 @@ describe Slugity do
898
898
  describe "#slugity()" do
899
899
  it "returns the correctly mapped character" do
900
900
  test_characters.each do |input,output|
901
- p "matching #{input}"
901
+ # p "matching #{input}"
902
902
  slugity( input ).should == output
903
903
  end
904
904
  end
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.3.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-22 00:00:00.000000000 Z
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. '