friendly_id 5.5.0 → 5.5.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0b1293d744a87c9988c0ff2dfba773f351cdf62bc24e3b3c73e386310b44d4bb
4
- data.tar.gz: 1e02363f0abe107ce5165942024ff4cdabfc8b8c18083e0615846c58f5e41252
3
+ metadata.gz: 5fd869be5d6d4518b4928f41284ec56c4eca0162a3d0683369ed6789b87206ed
4
+ data.tar.gz: b349d6f8cbb6d1289c768cf6d38c55ad864b472fc39f08e98baf2389af96e85d
5
5
  SHA512:
6
- metadata.gz: f7f27736b4ae2218c95c42cde457472a919c81f89d0b899453c351e4b16c2e557c6f44a9dc32ef947123e2228e5588f8bcd1157c60d3ecb4f4195cc4687609b9
7
- data.tar.gz: bf6b4a73627faa1363a78d70d6a82e3e1ebf2fa1b7979504d0914646325fffc980f9b78508a3a9ad8ab17c93034bc45c2b50cf3d058f33857b4e83a064c605fc
6
+ metadata.gz: 07ca31c8fc194a8a3b336a8e2fdf63cb69f2ac84f1e8cb3781e35beabd392c8b8100495b9fc07e42a548d4e91d1bbf35aed2f9b51c5d5f65cf59d32cb4f25732
7
+ data.tar.gz: 776d4a15ae8c7144dbff2b9bc2b9d8f745f22858db397617a58af1bc61bacbdb9cc6e52477dfa7ee88e5457f9bda775a892292c3fe51b49060743e783b74e317
checksums.yaml.gz.sig CHANGED
Binary file
@@ -11,10 +11,14 @@ jobs:
11
11
  matrix:
12
12
  database: [ mysql, postgresql ]
13
13
  gemfile: [ '7.0', '6.1', '6.0' ]
14
- ruby: [ '2.6', '2.7', '3.0', '3.1' ]
14
+ ruby: [ '2.6', '2.7', '3.0', '3.1', '3.2' ]
15
15
  exclude:
16
16
  - ruby: '2.6'
17
17
  gemfile: '7.0'
18
+ - ruby: '3.2'
19
+ gemfile: '6.0'
20
+ - ruby: '3.2'
21
+ gemfile: '6.1'
18
22
  fail-fast: false
19
23
  runs-on: ubuntu-latest
20
24
 
data/.yardopts CHANGED
@@ -1,5 +1,7 @@
1
1
  -e guide.rb
2
2
  --files=Changelog.md,Guide.md
3
+ --tag guide
4
+ --hide-tag guide
3
5
  --private
4
6
  --protected
5
7
  --exclude lib/friendly_id/migration
data/Changelog.md CHANGED
@@ -5,6 +5,10 @@ suggestions, ideas and improvements to FriendlyId.
5
5
 
6
6
  ## Unreleased
7
7
 
8
+ ## 5.5.1 (2023-11-13)
9
+
10
+ * Fix YARD doc generation. ([#1006](https://github.com/norman/friendly_id/pull/1006))
11
+
8
12
  ## 5.5.0 (2022-11-16)
9
13
 
10
14
  * SimpleI18n: Handle regional locales ([#965](https://github.com/norman/friendly_id/pull/965))
data/friendly_id.gemspec CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.add_development_dependency "coveralls"
20
20
  s.add_development_dependency "railties", ">= 4.0"
21
21
  s.add_development_dependency "minitest", "~> 5.3"
22
- s.add_development_dependency "mocha", "~> 1.1"
22
+ s.add_development_dependency "mocha", "~> 2.1"
23
23
  s.add_development_dependency "yard"
24
24
  s.add_development_dependency "i18n"
25
25
  s.add_development_dependency "ffaker"
data/guide.rb CHANGED
@@ -4,8 +4,15 @@
4
4
 
5
5
  def comments_from path
6
6
  path = File.expand_path("../lib/friendly_id/#{path}", __FILE__)
7
- match = File.read(path).match(/\n=begin(.*)\n=end/m)[1].to_s
8
- match.split("\n").reject { |x| x =~ /^@/ }.join("\n").strip
7
+ matches = File.read(path).match(/\n\s*# @guide begin\n(.*)\s*# @guide end/m)
8
+
9
+ return if matches.nil?
10
+
11
+ match = matches[1].to_s
12
+ match.split("\n")
13
+ .map { |x| x.sub(/^\s*#\s?/, "") } # Strip off the comment, leading whitespace, and the space after the comment
14
+ .reject { |x| x =~ /^@/ } # Ignore yarddoc tags for the guide
15
+ .join("\n").strip
9
16
  end
10
17
 
11
18
  File.open(File.expand_path("../Guide.md", __FILE__), "w:utf-8") do |guide|
@@ -1,6 +1,7 @@
1
1
  module FriendlyId
2
+ # @guide begin
2
3
  #
3
- ## Setting Up FriendlyId in Your Model
4
+ # ## Setting Up FriendlyId in Your Model
4
5
  #
5
6
  # To use FriendlyId in your ActiveRecord models, you must first either extend or
6
7
  # include the FriendlyId module (it makes no difference), then invoke the
@@ -21,7 +22,7 @@ module FriendlyId
21
22
  # all classes that participate in STI, both your parent classes and their
22
23
  # children.*
23
24
  #
24
- ### The Default Setup: Simple Models
25
+ # ### The Default Setup: Simple Models
25
26
  #
26
27
  # The simplest way to use FriendlyId is with a model that has a uniquely indexed
27
28
  # column with no spaces or special characters, and that is seldom or never
@@ -53,6 +54,7 @@ module FriendlyId
53
54
  # in a URL can be repetitive and surprisingly tricky, so for this reason it's
54
55
  # often better and easier to use {FriendlyId::Slugged slugs}.
55
56
  #
57
+ # @guide end
56
58
  module Base
57
59
  # Configure FriendlyId's behavior in a model.
58
60
  #
@@ -1,4 +1,6 @@
1
1
  module FriendlyId
2
+ # @guide begin
3
+ #
2
4
  # ## Performing Finds with FriendlyId
3
5
  #
4
6
  # FriendlyId offers enhanced finders which will search for your record by
@@ -12,7 +14,7 @@ module FriendlyId
12
14
  # Restaurant.find(23) #=> still works
13
15
  # Restaurant.find('plaza-diner') #=> will not work
14
16
  #
15
- ### Restoring FriendlyId 4.0-style finders
17
+ # ### Restoring FriendlyId 4.0-style finders
16
18
  #
17
19
  # Prior to version 5.0, FriendlyId overrode the default finder methods to perform
18
20
  # friendly finds all the time. This required modifying parts of Rails that did
@@ -34,7 +36,7 @@ module FriendlyId
34
36
  # Restaurant.find('plaza-diner') #=> now also works
35
37
  # Restaurant.active.find('plaza-diner') #=> now also works
36
38
  #
37
- ### Updating your application to use FriendlyId's finders
39
+ # ### Updating your application to use FriendlyId's finders
38
40
  #
39
41
  # Unless you've chosen to use the `:finders` addon, be sure to modify the finders
40
42
  # in your controllers to use the `friendly` scope. For example:
@@ -49,7 +51,7 @@ module FriendlyId
49
51
  # @restaurant = Restaurant.friendly.find(params[:id])
50
52
  # end
51
53
  #
52
- #### Active Admin
54
+ # #### Active Admin
53
55
  #
54
56
  # Unless you use the `:finders` addon, you should modify your admin controllers
55
57
  # for models that use FriendlyId with something similar to the following:
@@ -60,6 +62,7 @@ module FriendlyId
60
62
  # end
61
63
  # end
62
64
  #
65
+ # @guide end
63
66
  module Finders
64
67
  module ClassMethods
65
68
  if (ActiveRecord::VERSION::MAJOR == 4) && (ActiveRecord::VERSION::MINOR == 0)
@@ -1,6 +1,7 @@
1
1
  module FriendlyId
2
+ # @guide begin
2
3
  #
3
- ## History: Avoiding 404's When Slugs Change
4
+ # ## History: Avoiding 404's When Slugs Change
4
5
  #
5
6
  # FriendlyId's {FriendlyId::History History} module adds the ability to store a
6
7
  # log of a model's slugs, so that when its friendly id changes, it's still
@@ -8,7 +9,7 @@ module FriendlyId
8
9
  #
9
10
  # The primary use case for this is avoiding broken URLs.
10
11
  #
11
- ### Setup
12
+ # ### Setup
12
13
  #
13
14
  # In order to use this module, you must add a table to your database schema to
14
15
  # store the slug records. FriendlyId provides a generator for this purpose:
@@ -19,13 +20,13 @@ module FriendlyId
19
20
  # This will add a table named `friendly_id_slugs`, used by the {FriendlyId::Slug}
20
21
  # model.
21
22
  #
22
- ### Considerations
23
+ # ### Considerations
23
24
  #
24
25
  # Because recording slug history requires creating additional database records,
25
26
  # this module has an impact on the performance of the associated model's `create`
26
27
  # method.
27
28
  #
28
- ### Example
29
+ # ### Example
29
30
  #
30
31
  # class Post < ActiveRecord::Base
31
32
  # extend FriendlyId
@@ -49,6 +50,8 @@ module FriendlyId
49
50
  # end
50
51
  # end
51
52
  # end
53
+ #
54
+ # @guide end
52
55
  module History
53
56
  module Configuration
54
57
  def dependent_value
@@ -1,6 +1,7 @@
1
1
  module FriendlyId
2
+ # @guide begin
2
3
  #
3
- ## Reserved Words
4
+ # ## Reserved Words
4
5
  #
5
6
  # The {FriendlyId::Reserved Reserved} module adds the ability to exclude a list of
6
7
  # words from use as FriendlyId slugs.
@@ -26,6 +27,7 @@ module FriendlyId
26
27
  # end
27
28
  # end
28
29
  #
30
+ # @guide end
29
31
  module Reserved
30
32
  # When included, this module adds configuration options to the model class's
31
33
  # friendly_id_config.
@@ -1,8 +1,9 @@
1
1
  require "friendly_id/slugged"
2
2
 
3
3
  module FriendlyId
4
+ # @guide begin
4
5
  #
5
- ## Unique Slugs by Scope
6
+ # ## Unique Slugs by Scope
6
7
  #
7
8
  # The {FriendlyId::Scoped} module allows FriendlyId to generate unique slugs
8
9
  # within a scope.
@@ -53,7 +54,7 @@ module FriendlyId
53
54
  #
54
55
  # All supplied values will be used to determine scope.
55
56
  #
56
- ### Finding Records by Friendly ID
57
+ # ### Finding Records by Friendly ID
57
58
  #
58
59
  # If you are using scopes your friendly ids may not be unique, so a simple find
59
60
  # like:
@@ -70,13 +71,13 @@ module FriendlyId
70
71
  # Restaurant.where(:city_id => @city.id).friendly.find("joes-diner")
71
72
  #
72
73
  #
73
- ### Finding All Records That Match a Scoped ID
74
+ # ### Finding All Records That Match a Scoped ID
74
75
  #
75
76
  # Query the slug column directly:
76
77
  #
77
78
  # Restaurant.where(:slug => "joes-diner")
78
79
  #
79
- ### Routes for Scoped Models
80
+ # ### Routes for Scoped Models
80
81
  #
81
82
  # Recall that FriendlyId is a database-centric library, and does not set up any
82
83
  # routes for scoped models. You must do this yourself in your application. Here's
@@ -98,6 +99,7 @@ module FriendlyId
98
99
  # http://example.org/cities/seattle/restaurants/joes-diner
99
100
  # http://example.org/cities/chicago/restaurants/joes-diner
100
101
  #
102
+ # @guide end
101
103
  module Scoped
102
104
  # FriendlyId::Config.use will invoke this method when present, to allow
103
105
  # loading dependent modules prior to overriding them when necessary.
@@ -1,8 +1,9 @@
1
1
  require "i18n"
2
2
 
3
3
  module FriendlyId
4
+ # @guide begin
4
5
  #
5
- ## Translating Slugs Using Simple I18n
6
+ # ## Translating Slugs Using Simple I18n
6
7
  #
7
8
  # The {FriendlyId::SimpleI18n SimpleI18n} module adds very basic i18n support to
8
9
  # FriendlyId.
@@ -17,7 +18,7 @@ module FriendlyId
17
18
  # If you need to support two or more locales, you may wish to use the
18
19
  # friendly_id_globalize gem instead.
19
20
  #
20
- ### Example migration
21
+ # ### Example migration
21
22
  #
22
23
  # def self.up
23
24
  # create_table :posts do |t|
@@ -32,7 +33,7 @@ module FriendlyId
32
33
  # add_index :posts, :slug_pt_br
33
34
  # end
34
35
  #
35
- ### Finds
36
+ # ### Finds
36
37
  #
37
38
  # Finds will take into consideration the current locale:
38
39
  #
@@ -50,11 +51,11 @@ module FriendlyId
50
51
  # Post.friendly.find("la-guerra-de-las-galaxias")
51
52
  # end
52
53
  #
53
- ### Creating Records
54
+ # ### Creating Records
54
55
  #
55
56
  # When new records are created, the slug is generated for the current locale only.
56
57
  #
57
- ### Translating Slugs
58
+ # ### Translating Slugs
58
59
  #
59
60
  # To translate an existing record's friendly_id, use
60
61
  # {FriendlyId::SimpleI18n::Model#set_friendly_id}. This will ensure that the slug
@@ -69,6 +70,8 @@ module FriendlyId
69
70
  # I18n.with_locale(:es) do
70
71
  # post.set_friendly_id("La guerra de las galaxias")
71
72
  # end
73
+ #
74
+ # @guide end
72
75
  module SimpleI18n
73
76
  # FriendlyId::Config.use will invoke this method when present, to allow
74
77
  # loading dependent modules prior to overriding them when necessary.
@@ -2,8 +2,9 @@ require "friendly_id/slug_generator"
2
2
  require "friendly_id/candidates"
3
3
 
4
4
  module FriendlyId
5
+ # @guide begin
5
6
  #
6
- ## Slugged Models
7
+ # ## Slugged Models
7
8
  #
8
9
  # FriendlyId can use a separate column to store slugs for models which require
9
10
  # some text processing.
@@ -34,7 +35,7 @@ module FriendlyId
34
35
  # unique. You may also wish to constrain it to NOT NULL, but this depends on your
35
36
  # app's behavior and requirements.
36
37
  #
37
- ### Example Setup
38
+ # ### Example Setup
38
39
  #
39
40
  # # your model
40
41
  # class Post < ActiveRecord::Base
@@ -60,9 +61,9 @@ module FriendlyId
60
61
  # end
61
62
  # end
62
63
  #
63
- ### Working With Slugs
64
+ # ### Working With Slugs
64
65
  #
65
- #### Formatting
66
+ # #### Formatting
66
67
  #
67
68
  # By default, FriendlyId uses Active Support's
68
69
  # [parameterize](http://api.rubyonrails.org/classes/ActiveSupport/Inflector.html#method-i-parameterize)
@@ -72,7 +73,7 @@ module FriendlyId
72
73
  # movie = Movie.create! :title => "Der Preis fürs Überleben"
73
74
  # movie.slug #=> "der-preis-furs-uberleben"
74
75
  #
75
- #### Column or Method?
76
+ # #### Column or Method?
76
77
  #
77
78
  # FriendlyId always uses a method as the basis of the slug text - not a column. At
78
79
  # first glance, this may sound confusing, but remember that Active Record provides
@@ -95,7 +96,7 @@ module FriendlyId
95
96
  #
96
97
  # FriendlyId refers to this internally as the "base" method.
97
98
  #
98
- #### Uniqueness
99
+ # #### Uniqueness
99
100
  #
100
101
  # When you try to insert a record that would generate a duplicate friendly id,
101
102
  # FriendlyId will append a UUID to the generated slug to ensure uniqueness:
@@ -109,7 +110,7 @@ module FriendlyId
109
110
  # Previous versions of FriendlyId appended a numeric sequence to make slugs
110
111
  # unique, but this was removed to simplify using FriendlyId in concurrent code.
111
112
  #
112
- #### Candidates
113
+ # #### Candidates
113
114
  #
114
115
  # Since UUIDs are ugly, FriendlyId provides a "slug candidates" functionality to
115
116
  # let you specify alternate slugs to use in the event the one you want to use is
@@ -147,20 +148,20 @@ module FriendlyId
147
148
  # unique slug, then FriendlyId will append a UUID to the first candidate as a
148
149
  # last resort.
149
150
  #
150
- #### Sequence Separator
151
+ # #### Sequence Separator
151
152
  #
152
153
  # By default, FriendlyId uses a dash to separate the slug from a sequence.
153
154
  #
154
155
  # You can change this with the {FriendlyId::Slugged::Configuration#sequence_separator
155
156
  # sequence_separator} configuration option.
156
157
  #
157
- #### Providing Your Own Slug Processing Method
158
+ # #### Providing Your Own Slug Processing Method
158
159
  #
159
160
  # You can override {FriendlyId::Slugged#normalize_friendly_id} in your model for
160
161
  # total control over the slug format. It will be invoked for any generated slug,
161
162
  # whether for a single slug or for slug candidates.
162
163
  #
163
- #### Deciding When to Generate New Slugs
164
+ # #### Deciding When to Generate New Slugs
164
165
  #
165
166
  # As of FriendlyId 5.0, slugs are only generated when the `slug` field is nil. If
166
167
  # you want a slug to be regenerated,set the slug field to nil:
@@ -198,7 +199,7 @@ module FriendlyId
198
199
  # end
199
200
  # end
200
201
  #
201
- #### Locale-specific Transliterations
202
+ # #### Locale-specific Transliterations
202
203
  #
203
204
  # Active Support's `parameterize` uses
204
205
  # [transliterate](http://api.rubyonrails.org/classes/ActiveSupport/Inflector.html#method-i-transliterate),
@@ -219,7 +220,7 @@ module FriendlyId
219
220
  #
220
221
  # This functionality was in fact taken from earlier versions of FriendlyId.
221
222
  #
222
- #### Gotchas: Common Problems
223
+ # #### Gotchas: Common Problems
223
224
  #
224
225
  # FriendlyId uses a before_validation callback to generate and set the slug. This
225
226
  # means that if you create two model instances before saving them, it's possible
@@ -233,6 +234,7 @@ module FriendlyId
233
234
  # creating more than one nested record for a model that uses FriendlyId. See [this
234
235
  # Github issue](https://github.com/norman/friendly_id/issues/185) for discussion.
235
236
  #
237
+ # @guide end
236
238
  module Slugged
237
239
  # Sets up behavior and configuration options for FriendlyId's slugging
238
240
  # feature.
@@ -1,3 +1,3 @@
1
1
  module FriendlyId
2
- VERSION = "5.5.0".freeze
2
+ VERSION = "5.5.1".freeze
3
3
  end
data/lib/friendly_id.rb CHANGED
@@ -4,8 +4,9 @@ require "friendly_id/object_utils"
4
4
  require "friendly_id/configuration"
5
5
  require "friendly_id/finder_methods"
6
6
 
7
+ # @guide begin
7
8
  #
8
- ## About FriendlyId
9
+ # ## About FriendlyId
9
10
  #
10
11
  # FriendlyId is an add-on to Ruby's Active Record that allows you to replace ids
11
12
  # in your URLs with strings:
@@ -19,9 +20,9 @@ require "friendly_id/finder_methods"
19
20
  # It requires few changes to your application code and offers flexibility,
20
21
  # performance and a well-documented codebase.
21
22
  #
22
- ### Core Concepts
23
+ # ### Core Concepts
23
24
  #
24
- #### Slugs
25
+ # #### Slugs
25
26
  #
26
27
  # The concept of *slugs* is at the heart of FriendlyId.
27
28
  #
@@ -29,7 +30,7 @@ require "friendly_id/finder_methods"
29
30
  # keywords, rather than an opaque identifier such as a numeric id. This can make
30
31
  # your application more friendly both for users and search engines.
31
32
  #
32
- #### Finders: Slugs Act Like Numeric IDs
33
+ # #### Finders: Slugs Act Like Numeric IDs
33
34
  #
34
35
  # To the extent possible, FriendlyId lets you treat text-based identifiers like
35
36
  # normal IDs. This means that you can perform finds with slugs just like you do
@@ -38,6 +39,7 @@ require "friendly_id/finder_methods"
38
39
  # Person.find(82542335)
39
40
  # Person.friendly.find("joe")
40
41
  #
42
+ # @guide end
41
43
  module FriendlyId
42
44
  autoload :History, "friendly_id/history"
43
45
  autoload :Slug, "friendly_id/slug"
data/test/helper.rb CHANGED
@@ -19,9 +19,9 @@ rescue LoadError
19
19
  end
20
20
 
21
21
  begin
22
- TestCaseClass = MiniTest::Test
22
+ TestCaseClass = Minitest::Test
23
23
  rescue NameError
24
- TestCaseClass = MiniTest::Unit::TestCase
24
+ TestCaseClass = Minitest::Unit::TestCase
25
25
  end
26
26
 
27
27
  require "mocha/minitest"
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.5.0
4
+ version: 5.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Norman Clarke
@@ -37,7 +37,7 @@ cert_chain:
37
37
  fw1cbj95g7OPe0feGK8+afXh/L38vx/hIIOGlUEZ+HaWL2Dki/7vRGvda8dfOpG5
38
38
  bJfaoyKbVsrK+gGKFJv860zsO8lg6BGLsUw=
39
39
  -----END CERTIFICATE-----
40
- date: 2022-11-15 00:00:00.000000000 Z
40
+ date: 2023-11-12 00:00:00.000000000 Z
41
41
  dependencies:
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: activerecord
@@ -101,14 +101,14 @@ dependencies:
101
101
  requirements:
102
102
  - - "~>"
103
103
  - !ruby/object:Gem::Version
104
- version: '1.1'
104
+ version: '2.1'
105
105
  type: :development
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
109
  - - "~>"
110
110
  - !ruby/object:Gem::Version
111
- version: '1.1'
111
+ version: '2.1'
112
112
  - !ruby/object:Gem::Dependency
113
113
  name: yard
114
114
  requirement: !ruby/object:Gem::Requirement
@@ -258,7 +258,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
258
258
  - !ruby/object:Gem::Version
259
259
  version: '0'
260
260
  requirements: []
261
- rubygems_version: 3.3.7
261
+ rubygems_version: 3.4.22
262
262
  signing_key:
263
263
  specification_version: 4
264
264
  summary: A comprehensive slugging and pretty-URL plugin.
metadata.gz.sig CHANGED
Binary file