mongoid-slug 6.0.0 → 7.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +20 -20
- data/README.md +392 -336
- data/lib/mongoid/slug/criteria.rb +111 -107
- data/lib/mongoid/slug/{index.rb → index_builder.rb} +69 -45
- data/lib/mongoid/slug/railtie.rb +11 -9
- data/lib/mongoid/slug/slug_id_strategy.rb +5 -3
- data/lib/mongoid/slug/unique_slug.rb +172 -173
- data/lib/mongoid/slug/version.rb +7 -5
- data/lib/mongoid/slug.rb +333 -328
- data/lib/mongoid_slug.rb +4 -2
- data/lib/tasks/mongoid_slug.rake +17 -19
- metadata +13 -173
- data/spec/models/alias.rb +0 -6
- data/spec/models/article.rb +0 -9
- data/spec/models/artist.rb +0 -8
- data/spec/models/artwork.rb +0 -10
- data/spec/models/author.rb +0 -15
- data/spec/models/author_polymorphic.rb +0 -15
- data/spec/models/book.rb +0 -12
- data/spec/models/book_polymorphic.rb +0 -12
- data/spec/models/caption.rb +0 -17
- data/spec/models/entity.rb +0 -11
- data/spec/models/friend.rb +0 -7
- data/spec/models/incorrect_slug_persistence.rb +0 -9
- data/spec/models/integer_id.rb +0 -9
- data/spec/models/magazine.rb +0 -7
- data/spec/models/page.rb +0 -9
- data/spec/models/page_localize.rb +0 -9
- data/spec/models/page_slug_localized.rb +0 -9
- data/spec/models/page_slug_localized_custom.rb +0 -10
- data/spec/models/page_slug_localized_history.rb +0 -9
- data/spec/models/partner.rb +0 -7
- data/spec/models/person.rb +0 -12
- data/spec/models/relationship.rb +0 -8
- data/spec/models/string_id.rb +0 -9
- data/spec/models/subject.rb +0 -7
- data/spec/models/without_slug.rb +0 -5
- data/spec/mongoid/criteria_spec.rb +0 -207
- data/spec/mongoid/index_spec.rb +0 -33
- data/spec/mongoid/slug_spec.rb +0 -1169
- data/spec/shared/indexes.rb +0 -41
- data/spec/spec_helper.rb +0 -61
- data/spec/tasks/mongoid_slug_rake_spec.rb +0 -73
data/lib/mongoid_slug.rb
CHANGED
data/lib/tasks/mongoid_slug.rake
CHANGED
@@ -1,19 +1,17 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end
|
19
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
namespace :mongoid_slug do
|
4
|
+
desc 'Goes though all documents and sets slug if not already set'
|
5
|
+
task set: :environment do |_, args|
|
6
|
+
Rails.application.eager_load! if defined?(Rails)
|
7
|
+
klasses = Mongoid::Config.models.find_all { |c| c.ancestors.include?(Mongoid::Slug) }
|
8
|
+
unless klasses.blank?
|
9
|
+
models = args.extras
|
10
|
+
klasses = (klasses.map(&:to_s) & models.map(&:classify)).map(&:constantize) if models.any?
|
11
|
+
klasses.each do |klass|
|
12
|
+
# set slug for objects having blank slug
|
13
|
+
klass.each { |object| object.set_slug! unless object.slugs? && object.slugs.any? }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid-slug
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 7.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andreas Saebjoernsen
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mongoid
|
@@ -16,28 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '7.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: mongoid-compatibility
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
26
|
+
version: '7.0'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: stringex
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,90 +38,6 @@ dependencies:
|
|
52
38
|
- - "~>"
|
53
39
|
- !ruby/object:Gem::Version
|
54
40
|
version: '2.0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: awesome_print
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: guard-rspec
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: rake
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: rspec
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: rspec-its
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - ">="
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - ">="
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '0'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: uuid
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - ">="
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '0'
|
132
|
-
type: :development
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - ">="
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: '0'
|
139
41
|
description: Mongoid URL slug or permalink generator
|
140
42
|
email:
|
141
43
|
- andy@cosemble.com
|
@@ -147,49 +49,19 @@ files:
|
|
147
49
|
- README.md
|
148
50
|
- lib/mongoid/slug.rb
|
149
51
|
- lib/mongoid/slug/criteria.rb
|
150
|
-
- lib/mongoid/slug/
|
52
|
+
- lib/mongoid/slug/index_builder.rb
|
151
53
|
- lib/mongoid/slug/railtie.rb
|
152
54
|
- lib/mongoid/slug/slug_id_strategy.rb
|
153
55
|
- lib/mongoid/slug/unique_slug.rb
|
154
56
|
- lib/mongoid/slug/version.rb
|
155
57
|
- lib/mongoid_slug.rb
|
156
58
|
- lib/tasks/mongoid_slug.rake
|
157
|
-
- spec/models/alias.rb
|
158
|
-
- spec/models/article.rb
|
159
|
-
- spec/models/artist.rb
|
160
|
-
- spec/models/artwork.rb
|
161
|
-
- spec/models/author.rb
|
162
|
-
- spec/models/author_polymorphic.rb
|
163
|
-
- spec/models/book.rb
|
164
|
-
- spec/models/book_polymorphic.rb
|
165
|
-
- spec/models/caption.rb
|
166
|
-
- spec/models/entity.rb
|
167
|
-
- spec/models/friend.rb
|
168
|
-
- spec/models/incorrect_slug_persistence.rb
|
169
|
-
- spec/models/integer_id.rb
|
170
|
-
- spec/models/magazine.rb
|
171
|
-
- spec/models/page.rb
|
172
|
-
- spec/models/page_localize.rb
|
173
|
-
- spec/models/page_slug_localized.rb
|
174
|
-
- spec/models/page_slug_localized_custom.rb
|
175
|
-
- spec/models/page_slug_localized_history.rb
|
176
|
-
- spec/models/partner.rb
|
177
|
-
- spec/models/person.rb
|
178
|
-
- spec/models/relationship.rb
|
179
|
-
- spec/models/string_id.rb
|
180
|
-
- spec/models/subject.rb
|
181
|
-
- spec/models/without_slug.rb
|
182
|
-
- spec/mongoid/criteria_spec.rb
|
183
|
-
- spec/mongoid/index_spec.rb
|
184
|
-
- spec/mongoid/slug_spec.rb
|
185
|
-
- spec/shared/indexes.rb
|
186
|
-
- spec/spec_helper.rb
|
187
|
-
- spec/tasks/mongoid_slug_rake_spec.rb
|
188
59
|
homepage: https://github.com/mongoid/mongoid-slug
|
189
60
|
licenses:
|
190
61
|
- MIT
|
191
|
-
metadata:
|
192
|
-
|
62
|
+
metadata:
|
63
|
+
rubygems_mfa_required: 'true'
|
64
|
+
post_install_message:
|
193
65
|
rdoc_options: []
|
194
66
|
require_paths:
|
195
67
|
- lib
|
@@ -197,47 +69,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
197
69
|
requirements:
|
198
70
|
- - ">="
|
199
71
|
- !ruby/object:Gem::Version
|
200
|
-
version: '
|
72
|
+
version: '2.7'
|
201
73
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
202
74
|
requirements:
|
203
75
|
- - ">="
|
204
76
|
- !ruby/object:Gem::Version
|
205
77
|
version: '0'
|
206
78
|
requirements: []
|
207
|
-
|
208
|
-
|
209
|
-
signing_key:
|
79
|
+
rubygems_version: 3.4.4
|
80
|
+
signing_key:
|
210
81
|
specification_version: 4
|
211
82
|
summary: Mongoid URL slugs
|
212
|
-
test_files:
|
213
|
-
- spec/mongoid/criteria_spec.rb
|
214
|
-
- spec/mongoid/slug_spec.rb
|
215
|
-
- spec/mongoid/index_spec.rb
|
216
|
-
- spec/spec_helper.rb
|
217
|
-
- spec/tasks/mongoid_slug_rake_spec.rb
|
218
|
-
- spec/shared/indexes.rb
|
219
|
-
- spec/models/article.rb
|
220
|
-
- spec/models/integer_id.rb
|
221
|
-
- spec/models/book.rb
|
222
|
-
- spec/models/entity.rb
|
223
|
-
- spec/models/caption.rb
|
224
|
-
- spec/models/without_slug.rb
|
225
|
-
- spec/models/artist.rb
|
226
|
-
- spec/models/string_id.rb
|
227
|
-
- spec/models/page.rb
|
228
|
-
- spec/models/page_slug_localized.rb
|
229
|
-
- spec/models/author.rb
|
230
|
-
- spec/models/friend.rb
|
231
|
-
- spec/models/subject.rb
|
232
|
-
- spec/models/magazine.rb
|
233
|
-
- spec/models/partner.rb
|
234
|
-
- spec/models/alias.rb
|
235
|
-
- spec/models/person.rb
|
236
|
-
- spec/models/page_slug_localized_custom.rb
|
237
|
-
- spec/models/relationship.rb
|
238
|
-
- spec/models/book_polymorphic.rb
|
239
|
-
- spec/models/page_slug_localized_history.rb
|
240
|
-
- spec/models/author_polymorphic.rb
|
241
|
-
- spec/models/incorrect_slug_persistence.rb
|
242
|
-
- spec/models/page_localize.rb
|
243
|
-
- spec/models/artwork.rb
|
83
|
+
test_files: []
|
data/spec/models/alias.rb
DELETED
data/spec/models/article.rb
DELETED
data/spec/models/artist.rb
DELETED
data/spec/models/artwork.rb
DELETED
data/spec/models/author.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
class Author
|
2
|
-
include Mongoid::Document
|
3
|
-
include Mongoid::Slug
|
4
|
-
field :first_name
|
5
|
-
field :last_name
|
6
|
-
if Mongoid::Compatibility::Version.mongoid6_or_newer?
|
7
|
-
belongs_to :book, required: false
|
8
|
-
else
|
9
|
-
belongs_to :book
|
10
|
-
end
|
11
|
-
has_many :characters,
|
12
|
-
class_name: 'Person',
|
13
|
-
foreign_key: :author_id
|
14
|
-
slug :first_name, :last_name, scope: :book, history: false, max_length: 256
|
15
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
class AuthorPolymorphic
|
2
|
-
include Mongoid::Document
|
3
|
-
include Mongoid::Slug
|
4
|
-
field :first_name
|
5
|
-
field :last_name
|
6
|
-
slug :first_name, :last_name, scope: :book_polymorphic
|
7
|
-
if Mongoid::Compatibility::Version.mongoid6_or_newer?
|
8
|
-
belongs_to :book_polymorphic, required: false
|
9
|
-
else
|
10
|
-
belongs_to :book_polymorphic
|
11
|
-
end
|
12
|
-
has_many :characters,
|
13
|
-
class_name: 'Person',
|
14
|
-
foreign_key: :author_id
|
15
|
-
end
|
data/spec/models/book.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
class BookPolymorphic
|
2
|
-
include Mongoid::Document
|
3
|
-
include Mongoid::Slug
|
4
|
-
field :title
|
5
|
-
|
6
|
-
slug :title, history: true, by_model_type: true
|
7
|
-
embeds_many :subjects
|
8
|
-
has_many :author_polymorphics
|
9
|
-
end
|
10
|
-
|
11
|
-
class ComicBookPolymorphic < BookPolymorphic
|
12
|
-
end
|
data/spec/models/caption.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
class Caption
|
2
|
-
include Mongoid::Document
|
3
|
-
include Mongoid::Slug
|
4
|
-
field :my_identity, type: String
|
5
|
-
field :title
|
6
|
-
field :medium
|
7
|
-
|
8
|
-
# A fairly complex scenario, where we want to create a slug out of an
|
9
|
-
# my_identity field, which comprises name of artist and some more bibliographic
|
10
|
-
# info in parantheses, and the title of the work.
|
11
|
-
#
|
12
|
-
# We are only interested in the name of the artist so we remove the
|
13
|
-
# paranthesized details.
|
14
|
-
slug :my_identity, :title do |cur_object|
|
15
|
-
cur_object.slug_builder.gsub(/\s*\([^)]+\)/, '').to_url
|
16
|
-
end
|
17
|
-
end
|
data/spec/models/entity.rb
DELETED
data/spec/models/friend.rb
DELETED
data/spec/models/integer_id.rb
DELETED
data/spec/models/magazine.rb
DELETED
data/spec/models/page.rb
DELETED
data/spec/models/partner.rb
DELETED
data/spec/models/person.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
class Person
|
2
|
-
include Mongoid::Document
|
3
|
-
include Mongoid::Slug
|
4
|
-
field :name
|
5
|
-
slug :name, permanent: true, scope: :author
|
6
|
-
embeds_many :relationships
|
7
|
-
if Mongoid::Compatibility::Version.mongoid6_or_newer?
|
8
|
-
belongs_to :author, inverse_of: :characters, required: false
|
9
|
-
else
|
10
|
-
belongs_to :author, inverse_of: :characters
|
11
|
-
end
|
12
|
-
end
|
data/spec/models/relationship.rb
DELETED
data/spec/models/string_id.rb
DELETED
data/spec/models/subject.rb
DELETED