friendly_id 5.4.2 → 5.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/.github/dependabot.yml +6 -0
  4. data/.github/workflows/test.yml +34 -25
  5. data/Changelog.md +6 -0
  6. data/Gemfile +9 -13
  7. data/README.md +21 -0
  8. data/Rakefile +24 -27
  9. data/bench.rb +30 -27
  10. data/certs/parndt.pem +25 -23
  11. data/friendly_id.gemspec +26 -29
  12. data/gemfiles/Gemfile.rails-5.2.rb +11 -16
  13. data/gemfiles/Gemfile.rails-6.0.rb +11 -16
  14. data/gemfiles/Gemfile.rails-6.1.rb +22 -0
  15. data/gemfiles/Gemfile.rails-7.0.rb +22 -0
  16. data/guide.rb +5 -5
  17. data/lib/friendly_id/base.rb +57 -60
  18. data/lib/friendly_id/candidates.rb +9 -11
  19. data/lib/friendly_id/configuration.rb +6 -7
  20. data/lib/friendly_id/finder_methods.rb +26 -11
  21. data/lib/friendly_id/finders.rb +63 -66
  22. data/lib/friendly_id/history.rb +59 -63
  23. data/lib/friendly_id/initializer.rb +4 -4
  24. data/lib/friendly_id/migration.rb +6 -6
  25. data/lib/friendly_id/object_utils.rb +2 -2
  26. data/lib/friendly_id/reserved.rb +28 -32
  27. data/lib/friendly_id/scoped.rb +97 -102
  28. data/lib/friendly_id/sequentially_slugged/calculator.rb +69 -0
  29. data/lib/friendly_id/sequentially_slugged.rb +17 -64
  30. data/lib/friendly_id/simple_i18n.rb +75 -69
  31. data/lib/friendly_id/slug.rb +1 -2
  32. data/lib/friendly_id/slug_generator.rb +1 -3
  33. data/lib/friendly_id/slugged.rb +234 -238
  34. data/lib/friendly_id/version.rb +1 -1
  35. data/lib/friendly_id.rb +41 -45
  36. data/lib/generators/friendly_id_generator.rb +9 -9
  37. data/test/base_test.rb +10 -13
  38. data/test/benchmarks/finders.rb +28 -26
  39. data/test/benchmarks/object_utils.rb +13 -13
  40. data/test/candidates_test.rb +17 -18
  41. data/test/configuration_test.rb +7 -11
  42. data/test/core_test.rb +1 -2
  43. data/test/databases.yml +4 -3
  44. data/test/finders_test.rb +52 -5
  45. data/test/generator_test.rb +16 -26
  46. data/test/helper.rb +29 -22
  47. data/test/history_test.rb +70 -74
  48. data/test/numeric_slug_test.rb +4 -4
  49. data/test/object_utils_test.rb +0 -2
  50. data/test/reserved_test.rb +9 -11
  51. data/test/schema.rb +5 -4
  52. data/test/scoped_test.rb +18 -20
  53. data/test/sequentially_slugged_test.rb +65 -50
  54. data/test/shared.rb +15 -16
  55. data/test/simple_i18n_test.rb +22 -12
  56. data/test/slugged_test.rb +102 -121
  57. data/test/sti_test.rb +19 -21
  58. data.tar.gz.sig +0 -0
  59. metadata +35 -30
  60. metadata.gz.sig +1 -1
data/test/sti_test.rb CHANGED
@@ -1,14 +1,13 @@
1
1
  require "helper"
2
2
 
3
3
  class StiTest < TestCaseClass
4
-
5
4
  include FriendlyId::Test
6
5
  include FriendlyId::Test::Shared::Core
7
6
  include FriendlyId::Test::Shared::Slugged
8
7
 
9
8
  class Journalist < ActiveRecord::Base
10
9
  extend FriendlyId
11
- friendly_id :name, :use => [:slugged]
10
+ friendly_id :name, use: [:slugged]
12
11
  end
13
12
 
14
13
  class Editorialist < Journalist
@@ -20,9 +19,11 @@ class StiTest < TestCaseClass
20
19
 
21
20
  test "friendly_id should accept a base and a hash with single table inheritance" do
22
21
  abstract_klass = Class.new(ActiveRecord::Base) do
23
- def self.table_exists?; false end
22
+ def self.table_exists?
23
+ false
24
+ end
24
25
  extend FriendlyId
25
- friendly_id :foo, :use => :slugged, :slug_column => :bar
26
+ friendly_id :foo, use: :slugged, slug_column: :bar
26
27
  end
27
28
  klass = Class.new(abstract_klass)
28
29
  assert klass < FriendlyId::Slugged
@@ -36,7 +37,9 @@ class StiTest < TestCaseClass
36
37
 
37
38
  test "friendly_id should accept a block with single table inheritance" do
38
39
  abstract_klass = Class.new(ActiveRecord::Base) do
39
- def self.table_exists?; false end
40
+ def self.table_exists?
41
+ false
42
+ end
40
43
  extend FriendlyId
41
44
  friendly_id :foo do |config|
42
45
  config.use :slugged
@@ -52,10 +55,10 @@ class StiTest < TestCaseClass
52
55
 
53
56
  test "friendly_id slugs should not clash with each other" do
54
57
  transaction do
55
- journalist = model_class.base_class.create! :name => 'foo bar'
56
- editoralist = model_class.create! :name => 'foo bar'
58
+ journalist = model_class.base_class.create! name: "foo bar"
59
+ editoralist = model_class.create! name: "foo bar"
57
60
 
58
- assert_equal 'foo-bar', journalist.slug
61
+ assert_equal "foo-bar", journalist.slug
59
62
  assert_match(/foo-bar-.+/, editoralist.slug)
60
63
  end
61
64
  end
@@ -64,7 +67,7 @@ end
64
67
  class StiTestWithHistory < StiTest
65
68
  class Journalist < ActiveRecord::Base
66
69
  extend FriendlyId
67
- friendly_id :name, :use => [:slugged, :history]
70
+ friendly_id :name, use: [:slugged, :history]
68
71
  end
69
72
 
70
73
  class Editorialist < Journalist
@@ -75,19 +78,17 @@ class StiTestWithHistory < StiTest
75
78
  end
76
79
  end
77
80
 
78
-
79
81
  class StiTestWithFinders < TestCaseClass
80
-
81
82
  include FriendlyId::Test
82
83
 
83
84
  class Journalist < ActiveRecord::Base
84
85
  extend FriendlyId
85
- friendly_id :name, :use => [:slugged, :finders]
86
+ friendly_id :name, use: [:slugged, :finders]
86
87
  end
87
88
 
88
89
  class Editorialist < Journalist
89
90
  extend FriendlyId
90
- friendly_id :name, :use => [:slugged, :finders]
91
+ friendly_id :name, use: [:slugged, :finders]
91
92
  end
92
93
 
93
94
  def model_class
@@ -96,22 +97,20 @@ class StiTestWithFinders < TestCaseClass
96
97
 
97
98
  test "friendly_id slugs should be looked up from subclass with friendly" do
98
99
  transaction do
99
- editoralist = model_class.create! :name => 'foo bar'
100
+ editoralist = model_class.create! name: "foo bar"
100
101
  assert_equal editoralist, model_class.friendly.find(editoralist.slug)
101
102
  end
102
103
  end
103
104
 
104
105
  test "friendly_id slugs should be looked up from subclass" do
105
106
  transaction do
106
- editoralist = model_class.create! :name => 'foo bar'
107
+ editoralist = model_class.create! name: "foo bar"
107
108
  assert_equal editoralist, model_class.find(editoralist.slug)
108
109
  end
109
110
  end
110
-
111
111
  end
112
112
 
113
113
  class StiTestSubClass < TestCaseClass
114
-
115
114
  include FriendlyId::Test
116
115
 
117
116
  class Journalist < ActiveRecord::Base
@@ -120,7 +119,7 @@ class StiTestSubClass < TestCaseClass
120
119
 
121
120
  class Editorialist < Journalist
122
121
  extend FriendlyId
123
- friendly_id :name, :use => [:slugged, :finders]
122
+ friendly_id :name, use: [:slugged, :finders]
124
123
  end
125
124
 
126
125
  def model_class
@@ -129,9 +128,8 @@ class StiTestSubClass < TestCaseClass
129
128
 
130
129
  test "friendly_id slugs can be created and looked up from subclass" do
131
130
  transaction do
132
- editoralist = model_class.create! :name => 'foo bar'
131
+ editoralist = model_class.create! name: "foo bar"
133
132
  assert_equal editoralist, model_class.find(editoralist.slug)
134
133
  end
135
134
  end
136
-
137
- end
135
+ end
data.tar.gz.sig CHANGED
Binary file
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: 5.4.2
4
+ version: 5.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Norman Clarke
@@ -11,31 +11,33 @@ bindir: bin
11
11
  cert_chain:
12
12
  - |
13
13
  -----BEGIN CERTIFICATE-----
14
- MIIEMjCCApqgAwIBAgIBATANBgkqhkiG9w0BAQsFADAjMSEwHwYDVQQDDBhnZW1z
15
- L0RDPXAvREM9YXJuZHQvREM9aW8wHhcNMjAwNTEwMjIxOTQ2WhcNMjEwNTEwMjIx
16
- OTQ2WjAjMSEwHwYDVQQDDBhnZW1zL0RDPXAvREM9YXJuZHQvREM9aW8wggGiMA0G
17
- CSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDT+JzHYPGMYJt9ct2DCsbIymn1uJJp
18
- HnDkQESfsGe40jTC90oF2iVbVOkaacN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h0Er3w76fywOWQIDAQABo3kwdzAJBgNVHRMEAjAAMAsGA1Ud
28
+ DwQEAwIEsDAdBgNVHQ4EFgQUxRJaTQZmtkN8FKUWVHKc2riND18wHgYDVR0RBBcw
29
+ FYETcnVieWdlbXNAcC5hcm5kdC5pbzAeBgNVHRIEFzAVgRNydWJ5Z2Vtc0BwLmFy
30
+ bmR0LmlvMA0GCSqGSIb3DQEBCwUAA4IBgQBSRGMkZ2dvJ0LSjFz+rIt3G3AZMbKD
31
+ tjaaQRuC9rOkrl3Rml6h9j7cHYiM0wkTjXneFNySc8jWmM/jKnxiiUfUK9r1XL4n
32
+ 71tz39+MD2lIpLVVEQ69MIoUseppNUTCg0mNghSDYNwISMD/hoWwbJudBi56DbhE
33
+ xkulLbw8qtcEE+iilIKibe+eJF4platKScsOA7d1AuilR1/S245UzeqwwyI52/xK
34
+ dfoP928X9Tb/48+83lWUgAgCQOd6WdfCpgQ5H6R90lc8L7OfuDR/vgcmSOTsNVgG
35
+ 1TC3b2FISS0p0qfZsiS7BXh+ARoBKLXsV1a7WR36X0dUpajvk+zzBGrFCdbW43Gx
36
+ wmJzIksYnf9Ktg8Ux+FLcRBGw4qEIyWvqmS0obB1Hke68rTg0uNTFcKXsNw33XF5
37
+ fw1cbj95g7OPe0feGK8+afXh/L38vx/hIIOGlUEZ+HaWL2Dki/7vRGvda8dfOpG5
38
+ bJfaoyKbVsrK+gGKFJv860zsO8lg6BGLsUw=
37
39
  -----END CERTIFICATE-----
38
- date: 2021-01-07 00:00:00.000000000 Z
40
+ date: 2022-11-15 00:00:00.000000000 Z
39
41
  dependencies:
40
42
  - !ruby/object:Gem::Dependency
41
43
  name: activerecord
@@ -163,10 +165,9 @@ dependencies:
163
165
  - - ">="
164
166
  - !ruby/object:Gem::Version
165
167
  version: '0'
166
- description: |
167
- FriendlyId is the "Swiss Army bulldozer" of slugging and permalink plugins for
168
- Active Record. It lets you create pretty URLs and work with human-friendly
169
- strings as if they were numeric ids.
168
+ description: FriendlyId is the "Swiss Army bulldozer" of slugging and permalink plugins
169
+ for Active Record. It lets you create pretty URLs and work with human-friendly strings
170
+ as if they were numeric ids.
170
171
  email:
171
172
  - norman@njclarke.com
172
173
  - p@arndt.io
@@ -176,6 +177,7 @@ extra_rdoc_files: []
176
177
  files:
177
178
  - ".gemtest"
178
179
  - ".github/FUNDING.yml"
180
+ - ".github/dependabot.yml"
179
181
  - ".github/stale.yml"
180
182
  - ".github/workflows/test.yml"
181
183
  - ".gitignore"
@@ -192,6 +194,8 @@ files:
192
194
  - friendly_id.gemspec
193
195
  - gemfiles/Gemfile.rails-5.2.rb
194
196
  - gemfiles/Gemfile.rails-6.0.rb
197
+ - gemfiles/Gemfile.rails-6.1.rb
198
+ - gemfiles/Gemfile.rails-7.0.rb
195
199
  - guide.rb
196
200
  - lib/friendly_id.rb
197
201
  - lib/friendly_id/.gitattributes
@@ -207,6 +211,7 @@ files:
207
211
  - lib/friendly_id/reserved.rb
208
212
  - lib/friendly_id/scoped.rb
209
213
  - lib/friendly_id/sequentially_slugged.rb
214
+ - lib/friendly_id/sequentially_slugged/calculator.rb
210
215
  - lib/friendly_id/simple_i18n.rb
211
216
  - lib/friendly_id/slug.rb
212
217
  - lib/friendly_id/slug_generator.rb
@@ -253,7 +258,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
253
258
  - !ruby/object:Gem::Version
254
259
  version: '0'
255
260
  requirements: []
256
- rubygems_version: 3.2.3
261
+ rubygems_version: 3.3.7
257
262
  signing_key:
258
263
  specification_version: 4
259
264
  summary: A comprehensive slugging and pretty-URL plugin.
metadata.gz.sig CHANGED
@@ -1 +1 @@
1
- ��Z%d���6(',g������Þ���HU���m)�6���� s,�� �����J1��6.����N��dgf�,R����J켅
1
+ j搉g6hDŽ��� aQ�,��[�H�+P~M@ɈLO�z�!�TV�ٿ��>q|0T����ع|cDs1�`�����5�ϝd+��������\�:Ƶ���T��5��;�P��j]��h'�D�+�H-��@z}�,��WR) w���%�t�I�?L4ɚ4K��뜂HI`4X