friendly_id 2.3.2 → 2.3.3
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/Changelog.md +6 -0
- data/lib/friendly_id.rb +1 -1
- data/lib/friendly_id/configuration.rb +1 -1
- data/lib/friendly_id/slug_string.rb +1 -1
- data/lib/friendly_id/version.rb +1 -1
- data/test/active_record2/deprecated_test.rb +23 -0
- data/test/active_record2/support/models.rb +5 -0
- data/test/active_record2/test_helper.rb +8 -1
- data/test/friendly_id_test.rb +21 -0
- data/test/slug_string_test.rb +4 -0
- metadata +40 -38
data/Changelog.md
CHANGED
@@ -6,6 +6,12 @@ suggestions, ideas and improvements to FriendlyId.
|
|
6
6
|
* Table of Contents
|
7
7
|
{:toc}
|
8
8
|
|
9
|
+
## 2.3.3 (2010-03-10)
|
10
|
+
|
11
|
+
* Fixed sequence regexp to grab all trailing digits. (Nash Kabbara)
|
12
|
+
* Block param now warns, not raises. (Kamal Fariz Mahyuddin)
|
13
|
+
* Misc doc fixes. (Kamal Fariz Mahyuddin)
|
14
|
+
|
9
15
|
## 2.3.2 (2010-02-14)
|
10
16
|
|
11
17
|
* Fixed finding by old slug when using cached slugs.
|
data/lib/friendly_id.rb
CHANGED
@@ -61,7 +61,7 @@ end
|
|
61
61
|
class String
|
62
62
|
def parse_friendly_id(separator = nil)
|
63
63
|
separator ||= FriendlyId::Configuration::DEFAULTS[:sequence_separator]
|
64
|
-
name, sequence = split(/#{Regexp.escape(separator)}(\d)*\z/)
|
64
|
+
name, sequence = split(/#{Regexp.escape(separator)}(\d+)*\z/)
|
65
65
|
return name, sequence ||= "1"
|
66
66
|
end
|
67
67
|
end
|
@@ -87,7 +87,7 @@ module FriendlyId
|
|
87
87
|
|
88
88
|
def normalizer=(arg)
|
89
89
|
return if arg.nil?
|
90
|
-
|
90
|
+
warn("passing a block to has_friendly_id is deprecated and will be removed from 3.0. Please override #normalize_friendly_id.")
|
91
91
|
@normalizer = arg
|
92
92
|
end
|
93
93
|
|
@@ -257,7 +257,7 @@ module FriendlyId
|
|
257
257
|
# Replaces whitespace with dashes ("-").
|
258
258
|
# @return String
|
259
259
|
def with_dashes!
|
260
|
-
@wrapped_string = @wrapped_string.gsub(
|
260
|
+
@wrapped_string = @wrapped_string.gsub(/[\s\-]+/u, '-')
|
261
261
|
end
|
262
262
|
|
263
263
|
%w[approximate_ascii clean downcase word_chars normalize normalize_for to_ascii
|
data/lib/friendly_id/version.rb
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
module FriendlyId
|
4
|
+
module Test
|
5
|
+
module ActiveRecord2
|
6
|
+
|
7
|
+
class DeprecatedTest < ::Test::Unit::TestCase
|
8
|
+
|
9
|
+
include FriendlyId::Test::Generic
|
10
|
+
include FriendlyId::Test::Slugged
|
11
|
+
include FriendlyId::Test::ActiveRecord2::Slugged
|
12
|
+
include FriendlyId::Test::ActiveRecord2::Core
|
13
|
+
|
14
|
+
def klass
|
15
|
+
Block
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
@@ -104,4 +104,11 @@ end
|
|
104
104
|
# A model with no table
|
105
105
|
class Question < ActiveRecord::Base
|
106
106
|
has_friendly_id :name, :use_slug => true
|
107
|
-
end
|
107
|
+
end
|
108
|
+
|
109
|
+
# A model using the deprecated block syntax
|
110
|
+
class Block < ActiveRecord::Base
|
111
|
+
has_friendly_id :name, :use_slug => true do |text|
|
112
|
+
FriendlyId::SlugString.new(text).clean.with_dashes
|
113
|
+
end
|
114
|
+
end
|
data/test/friendly_id_test.rb
CHANGED
@@ -10,6 +10,18 @@ module FriendlyId
|
|
10
10
|
assert_equal ["test", "2"], "test--2".parse_friendly_id
|
11
11
|
end
|
12
12
|
|
13
|
+
test "should parse a friendly_id name and 10 as a sequence" do
|
14
|
+
assert_equal ["test", "10"], "test--10".parse_friendly_id
|
15
|
+
end
|
16
|
+
|
17
|
+
test "should parse a friendly_id name and 11 as a sequence" do
|
18
|
+
assert_equal ["test", "11"], "test--11".parse_friendly_id
|
19
|
+
end
|
20
|
+
|
21
|
+
test "should parse a friendly_id name and 29 as a sequence" do
|
22
|
+
assert_equal ["test", "29"], "test--29".parse_friendly_id
|
23
|
+
end
|
24
|
+
|
13
25
|
test "should parse with a default sequence of 1" do
|
14
26
|
assert_equal ["test", "1"], "test".parse_friendly_id
|
15
27
|
end
|
@@ -18,6 +30,10 @@ module FriendlyId
|
|
18
30
|
assert_equal ["test", "2"], "test:2".parse_friendly_id(":")
|
19
31
|
end
|
20
32
|
|
33
|
+
test "should be parseable with a custom separator and a double digit sequence" do
|
34
|
+
assert_equal ["test", "12"], "test:12".parse_friendly_id(":")
|
35
|
+
end
|
36
|
+
|
21
37
|
test "should parse when default sequence separator occurs in friendly_id name" do
|
22
38
|
assert_equal ["test--test", "2"], "test--test--2".parse_friendly_id
|
23
39
|
end
|
@@ -34,6 +50,11 @@ module FriendlyId
|
|
34
50
|
assert_equal ["test--2--test", "2"], "test--2--test--2".parse_friendly_id
|
35
51
|
end
|
36
52
|
|
53
|
+
test "should parse when double digit sequence separator, number and sequence occur in friendly_id name" do
|
54
|
+
assert_equal ["test--2--test", "12"], "test--2--test--12".parse_friendly_id
|
55
|
+
end
|
56
|
+
|
57
|
+
|
37
58
|
end
|
38
59
|
end
|
39
60
|
end
|
data/test/slug_string_test.rb
CHANGED
@@ -37,6 +37,10 @@ module FriendlyId
|
|
37
37
|
assert_equal "a-b", SlugString.new("a b").clean.with_dashes
|
38
38
|
end
|
39
39
|
|
40
|
+
test "should replace multiple dashes with 1 dash" do
|
41
|
+
assert_equal "male-female", SlugString.new("male - female").with_dashes
|
42
|
+
end
|
43
|
+
|
40
44
|
test "should strip trailing space" do
|
41
45
|
assert_equal "ab", SlugString.new("ab ").clean
|
42
46
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: friendly_id
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Norman Clarke
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2010-
|
14
|
+
date: 2010-03-10 00:00:00 -03:00
|
15
15
|
default_executable:
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
@@ -46,57 +46,58 @@ extensions: []
|
|
46
46
|
extra_rdoc_files: []
|
47
47
|
|
48
48
|
files:
|
49
|
-
- lib/friendly_id/
|
50
|
-
- lib/friendly_id/active_record2/finders.rb
|
51
|
-
- lib/friendly_id/active_record2/simple_model.rb
|
52
|
-
- lib/friendly_id/active_record2/slug.rb
|
53
|
-
- lib/friendly_id/active_record2/slugged_model.rb
|
54
|
-
- lib/friendly_id/active_record2/tasks.rb
|
55
|
-
- lib/friendly_id/active_record2.rb
|
56
|
-
- lib/friendly_id/configuration.rb
|
49
|
+
- lib/friendly_id/test.rb
|
57
50
|
- lib/friendly_id/finders.rb
|
51
|
+
- lib/friendly_id/configuration.rb
|
58
52
|
- lib/friendly_id/slug_string.rb
|
59
|
-
- lib/friendly_id/slugged.rb
|
60
53
|
- lib/friendly_id/status.rb
|
61
|
-
- lib/friendly_id/test.rb
|
62
54
|
- lib/friendly_id/version.rb
|
55
|
+
- lib/friendly_id/slugged.rb
|
56
|
+
- lib/friendly_id/active_record2.rb
|
57
|
+
- lib/friendly_id/active_record2/finders.rb
|
58
|
+
- lib/friendly_id/active_record2/configuration.rb
|
59
|
+
- lib/friendly_id/active_record2/tasks.rb
|
60
|
+
- lib/friendly_id/active_record2/slugged_model.rb
|
61
|
+
- lib/friendly_id/active_record2/slug.rb
|
62
|
+
- lib/friendly_id/active_record2/simple_model.rb
|
63
63
|
- lib/friendly_id.rb
|
64
64
|
- lib/friendly_id/active_record2/tasks/friendly_id.rake
|
65
|
-
- Changelog.md
|
66
|
-
- Contributors.md
|
67
65
|
- Guide.md
|
68
66
|
- README.md
|
67
|
+
- Changelog.md
|
68
|
+
- Contributors.md
|
69
69
|
- LICENSE
|
70
70
|
- Rakefile
|
71
71
|
- rails/init.rb
|
72
72
|
- generators/friendly_id/friendly_id_generator.rb
|
73
73
|
- generators/friendly_id/templates/create_slugs.rb
|
74
|
-
- test/
|
74
|
+
- test/slug_string_test.rb
|
75
|
+
- test/test_helper.rb
|
76
|
+
- test/active_record2/deprecated_test.rb
|
75
77
|
- test/active_record2/cached_slug_test.rb
|
76
|
-
- test/active_record2/
|
77
|
-
- test/active_record2/
|
78
|
+
- test/active_record2/tasks_test.rb
|
79
|
+
- test/active_record2/basic_slugged_model_test.rb
|
78
80
|
- test/active_record2/custom_table_name_test.rb
|
79
|
-
- test/active_record2/scoped_model_test.rb
|
80
|
-
- test/active_record2/simple_test.rb
|
81
|
-
- test/active_record2/slug_test.rb
|
82
|
-
- test/active_record2/slugged.rb
|
83
|
-
- test/active_record2/slugged_status_test.rb
|
84
|
-
- test/active_record2/sti_test.rb
|
85
|
-
- test/active_record2/support/database.mysql.yml
|
86
|
-
- test/active_record2/support/database.postgres.yml
|
87
81
|
- test/active_record2/support/database.sqlite3.yml
|
82
|
+
- test/active_record2/support/database.mysql.yml
|
88
83
|
- test/active_record2/support/models.rb
|
89
|
-
- test/active_record2/
|
84
|
+
- test/active_record2/support/database.postgres.yml
|
85
|
+
- test/active_record2/slug_test.rb
|
86
|
+
- test/active_record2/scoped_model_test.rb
|
87
|
+
- test/active_record2/custom_normalizer_test.rb
|
88
|
+
- test/active_record2/slugged.rb
|
90
89
|
- test/active_record2/test_helper.rb
|
90
|
+
- test/active_record2/core.rb
|
91
|
+
- test/active_record2/sti_test.rb
|
92
|
+
- test/active_record2/slugged_status_test.rb
|
93
|
+
- test/active_record2/simple_test.rb
|
91
94
|
- test/friendly_id_test.rb
|
92
|
-
- test/slug_string_test.rb
|
93
|
-
- test/test_helper.rb
|
94
|
-
- extras/bench.rb
|
95
95
|
- extras/extras.rb
|
96
96
|
- extras/prof.rb
|
97
|
-
- extras/README.txt
|
98
|
-
- extras/template-gem.rb
|
99
97
|
- extras/template-plugin.rb
|
98
|
+
- extras/template-gem.rb
|
99
|
+
- extras/bench.rb
|
100
|
+
- extras/README.txt
|
100
101
|
has_rdoc: true
|
101
102
|
homepage: http://norman.github.com/friendly_id
|
102
103
|
licenses: []
|
@@ -138,15 +139,16 @@ signing_key:
|
|
138
139
|
specification_version: 3
|
139
140
|
summary: A comprehensive slugging and pretty-URL plugin.
|
140
141
|
test_files:
|
141
|
-
- test/
|
142
|
+
- test/slug_string_test.rb
|
143
|
+
- test/active_record2/deprecated_test.rb
|
142
144
|
- test/active_record2/cached_slug_test.rb
|
143
|
-
- test/active_record2/
|
145
|
+
- test/active_record2/tasks_test.rb
|
146
|
+
- test/active_record2/basic_slugged_model_test.rb
|
144
147
|
- test/active_record2/custom_table_name_test.rb
|
145
|
-
- test/active_record2/scoped_model_test.rb
|
146
|
-
- test/active_record2/simple_test.rb
|
147
148
|
- test/active_record2/slug_test.rb
|
148
|
-
- test/active_record2/
|
149
|
+
- test/active_record2/scoped_model_test.rb
|
150
|
+
- test/active_record2/custom_normalizer_test.rb
|
149
151
|
- test/active_record2/sti_test.rb
|
150
|
-
- test/active_record2/
|
152
|
+
- test/active_record2/slugged_status_test.rb
|
153
|
+
- test/active_record2/simple_test.rb
|
151
154
|
- test/friendly_id_test.rb
|
152
|
-
- test/slug_string_test.rb
|