slugtastic 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## v1.1.0
2
+
3
+ * Slugs are now generated with `parameterize`.
4
+ * Spaces get converted to hyphens instead of underscores. Hyphens in the original string are collapsed.
5
+ * Removed dependence on iconv.
6
+
7
+ ## v1.0.0
8
+
9
+ * Added test for slugs with numbers.
10
+
1
11
  ## v0.2.1
2
12
 
3
13
  * Added basic transliteration with IConv.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- slugtastic (0.2.1)
4
+ slugtastic (1.1.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,3 +1,3 @@
1
1
  module Slugtastic
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
data/lib/slugtastic.rb CHANGED
@@ -2,12 +2,9 @@ require "slugtastic/version"
2
2
  require "slugtastic/model_additions"
3
3
  require "slugtastic/railtie" if defined? Rails
4
4
 
5
- # TODO: iconv will be deprecated in the future.
6
- require 'iconv'
7
-
8
5
  module Slugtastic
9
6
  def self.generate_slug(string)
10
7
  return if string.nil?
11
- Iconv.iconv("ASCII//TRANSLIT//IGNORE", "UTF-8", string).join.downcase.gsub(/ /, '_').gsub(/[^a-z0-9\-_]/, '')
8
+ string.parameterize
12
9
  end
13
10
  end
@@ -10,15 +10,15 @@ end
10
10
 
11
11
  describe Slugtastic::ModelAdditions do
12
12
  it "generates a slug from the title" do
13
- Model.create!(:title => "A Simple Title").slug.should eq "a_simple_title"
13
+ Model.create!(:title => "A Simple Title").slug.should eq "a-simple-title"
14
14
  end
15
15
 
16
16
  it "doesn't regenerate the slug if it already exists" do
17
17
  model = Model.create!(:title => "A Simple Title")
18
- model.slug.should eq "a_simple_title"
18
+ model.slug.should eq "a-simple-title"
19
19
 
20
20
  model.title = "A new title"
21
21
  model.save
22
- model.slug.should eq "a_simple_title"
22
+ model.slug.should eq "a-simple-title"
23
23
  end
24
24
  end
@@ -8,24 +8,24 @@ describe Slugtastic do
8
8
  end
9
9
 
10
10
  it "generates a slug from a simple string" do
11
- Slugtastic.generate_slug("A simple string.").should eq "a_simple_string"
11
+ Slugtastic.generate_slug("A simple string.").should eq "a-simple-string"
12
12
  end
13
13
 
14
14
  it "generates a slug from a string with numbers" do
15
- Slugtastic.generate_slug("Slugtastic was built in 2012.").should eq "slugtastic_was_built_in_2012"
15
+ Slugtastic.generate_slug("Slugtastic was built in 2012.").should eq "slugtastic-was-built-in-2012"
16
16
  end
17
17
 
18
18
  it "handles strings with hypens in them" do
19
- Slugtastic.generate_slug("A string - with Hyphens").should eq "a_string_-_with_hyphens"
19
+ Slugtastic.generate_slug("A string - with Hyphens").should eq "a-string-with-hyphens"
20
20
  end
21
21
 
22
22
  it "handles strings with other characters in them" do
23
- Slugtastic.generate_slug("A string, with /All sorts!").should eq "a_string_with_all_sorts"
23
+ Slugtastic.generate_slug("A string, with /All sorts!").should eq "a-string-with-all-sorts"
24
24
  end
25
25
 
26
26
  it "handles basic transliteration" do
27
- Slugtastic.generate_slug("Un été À la maison.").should eq "un_ete_a_la_maison"
28
- Slugtastic.generate_slug("Ātri brūna lapsa").should eq "atri_bruna_lapsa"
27
+ Slugtastic.generate_slug("Un été À la maison.").should eq "un-ete-a-la-maison"
28
+ Slugtastic.generate_slug("Ātri brūna lapsa").should eq "atri-bruna-lapsa"
29
29
  end
30
30
  end
31
31
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slugtastic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.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: 2012-08-21 00:00:00.000000000 Z
12
+ date: 2012-12-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -96,12 +96,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
96
96
  - - ! '>='
97
97
  - !ruby/object:Gem::Version
98
98
  version: '0'
99
+ segments:
100
+ - 0
101
+ hash: -120995727452376200
99
102
  required_rubygems_version: !ruby/object:Gem::Requirement
100
103
  none: false
101
104
  requirements:
102
105
  - - ! '>='
103
106
  - !ruby/object:Gem::Version
104
107
  version: '0'
108
+ segments:
109
+ - 0
110
+ hash: -120995727452376200
105
111
  requirements: []
106
112
  rubyforge_project:
107
113
  rubygems_version: 1.8.23
@@ -112,4 +118,3 @@ test_files:
112
118
  - spec/slugtastic/model_additions_spec.rb
113
119
  - spec/slugtastic_spec.rb
114
120
  - spec/spec_helper.rb
115
- has_rdoc: