mongoid-slug 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +20 -0
  3. data/README.md +333 -0
  4. data/lib/mongoid/slug.rb +333 -0
  5. data/lib/mongoid/slug/criteria.rb +110 -0
  6. data/lib/mongoid/slug/index.rb +27 -0
  7. data/lib/mongoid/slug/paranoia.rb +22 -0
  8. data/lib/mongoid/slug/slug_id_strategy.rb +3 -0
  9. data/lib/mongoid/slug/unique_slug.rb +153 -0
  10. data/lib/mongoid/slug/version.rb +5 -0
  11. data/lib/mongoid_slug.rb +2 -0
  12. data/spec/models/alias.rb +6 -0
  13. data/spec/models/article.rb +9 -0
  14. data/spec/models/author.rb +11 -0
  15. data/spec/models/author_polymorphic.rb +11 -0
  16. data/spec/models/book.rb +12 -0
  17. data/spec/models/book_polymorphic.rb +12 -0
  18. data/spec/models/caption.rb +17 -0
  19. data/spec/models/entity.rb +12 -0
  20. data/spec/models/friend.rb +7 -0
  21. data/spec/models/incorrect_slug_persistence.rb +9 -0
  22. data/spec/models/integer_id.rb +9 -0
  23. data/spec/models/magazine.rb +7 -0
  24. data/spec/models/page.rb +9 -0
  25. data/spec/models/page_localize.rb +9 -0
  26. data/spec/models/page_slug_localized.rb +9 -0
  27. data/spec/models/page_slug_localized_custom.rb +11 -0
  28. data/spec/models/page_slug_localized_history.rb +9 -0
  29. data/spec/models/paranoid_document.rb +8 -0
  30. data/spec/models/paranoid_permanent.rb +8 -0
  31. data/spec/models/partner.rb +7 -0
  32. data/spec/models/person.rb +8 -0
  33. data/spec/models/relationship.rb +8 -0
  34. data/spec/models/string_id.rb +9 -0
  35. data/spec/models/subject.rb +7 -0
  36. data/spec/models/without_slug.rb +5 -0
  37. data/spec/mongoid/criteria_spec.rb +190 -0
  38. data/spec/mongoid/index_spec.rb +34 -0
  39. data/spec/mongoid/paranoia_spec.rb +169 -0
  40. data/spec/mongoid/slug_spec.rb +1022 -0
  41. data/spec/mongoid/slug_spec.rb.b00 +1101 -0
  42. data/spec/shared/indexes.rb +27 -0
  43. data/spec/spec_helper.rb +47 -0
  44. metadata +245 -0
@@ -0,0 +1,27 @@
1
+ shared_examples "has an index" do |key, options|
2
+ it "has a #{key} index" do
3
+ index = if Mongoid::Slug.mongoid3?
4
+ subject.index_options[key]
5
+ else
6
+ subject.index_specifications.detect { |spec| spec.key == key }
7
+ end
8
+ index.should_not be_nil
9
+ options.each_pair { |name, value|
10
+ if Mongoid::Slug.mongoid3?
11
+ index[name].should == value
12
+ else
13
+ index.options[name].should == value
14
+ end
15
+ } if options
16
+ end
17
+ end
18
+
19
+ shared_examples "does not have an index" do |key, option|
20
+ it "does not have the #{key} index" do
21
+ if Mongoid::Slug.mongoid3?
22
+ subject.index_options[key].should be_nil
23
+ else
24
+ subject.index_specifications.detect { |spec| spec.key == key }.should be_nil
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,47 @@
1
+ require 'bundler/setup'
2
+
3
+ begin
4
+ require 'pry'
5
+ rescue LoadError
6
+ end
7
+ require 'rspec'
8
+ require 'uuid'
9
+ require 'awesome_print'
10
+ require 'active_support'
11
+ require 'active_support/deprecation'
12
+ require 'mongoid'
13
+ require 'mongoid/paranoia'
14
+ require 'rspec/its'
15
+
16
+ require File.expand_path '../../lib/mongoid/slug', __FILE__
17
+
18
+ module Mongoid::Slug::UuidIdStrategy
19
+ def self.call id
20
+ id =~ /\A([0-9a-fA-F]){8}-(([0-9a-fA-F]){4}-){3}([0-9a-fA-F]){12}\z/
21
+ end
22
+ end
23
+
24
+ def database_id
25
+ ENV['CI'] ? "mongoid_slug_#{Process.pid}" : 'mongoid_slug_test'
26
+ end
27
+
28
+ Mongoid.configure do |config|
29
+ config.connect_to database_id
30
+ end
31
+
32
+ [ 'models', 'shared' ].each do |dir|
33
+ Dir["./spec/#{dir}/*.rb"].each { |f| require f }
34
+ end
35
+
36
+ I18n.available_locales = [ :en, :nl ]
37
+
38
+ RSpec.configure do |c|
39
+ c.before(:each) do
40
+ Mongoid.purge!
41
+ Mongoid::IdentityMap.clear if defined?(Mongoid::IdentityMap)
42
+ end
43
+
44
+ c.after(:suite) do
45
+ Mongoid::Threaded.sessions[:default].drop if ENV['CI']
46
+ end
47
+ end
metadata ADDED
@@ -0,0 +1,245 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mongoid-slug
3
+ version: !ruby/object:Gem::Version
4
+ version: 4.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Andreas Saebjoernsen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: mongoid
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: stringex
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: guard-rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
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: 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: rspec-its
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: awesome_print
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: uuid
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: pry
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
+ description: Mongoid URL slug or permalink generator
140
+ email:
141
+ - andy@cosemble.com
142
+ executables: []
143
+ extensions: []
144
+ extra_rdoc_files: []
145
+ files:
146
+ - LICENSE
147
+ - README.md
148
+ - lib/mongoid/slug.rb
149
+ - lib/mongoid/slug/criteria.rb
150
+ - lib/mongoid/slug/index.rb
151
+ - lib/mongoid/slug/paranoia.rb
152
+ - lib/mongoid/slug/slug_id_strategy.rb
153
+ - lib/mongoid/slug/unique_slug.rb
154
+ - lib/mongoid/slug/version.rb
155
+ - lib/mongoid_slug.rb
156
+ - spec/models/alias.rb
157
+ - spec/models/article.rb
158
+ - spec/models/author.rb
159
+ - spec/models/author_polymorphic.rb
160
+ - spec/models/book.rb
161
+ - spec/models/book_polymorphic.rb
162
+ - spec/models/caption.rb
163
+ - spec/models/entity.rb
164
+ - spec/models/friend.rb
165
+ - spec/models/incorrect_slug_persistence.rb
166
+ - spec/models/integer_id.rb
167
+ - spec/models/magazine.rb
168
+ - spec/models/page.rb
169
+ - spec/models/page_localize.rb
170
+ - spec/models/page_slug_localized.rb
171
+ - spec/models/page_slug_localized_custom.rb
172
+ - spec/models/page_slug_localized_history.rb
173
+ - spec/models/paranoid_document.rb
174
+ - spec/models/paranoid_permanent.rb
175
+ - spec/models/partner.rb
176
+ - spec/models/person.rb
177
+ - spec/models/relationship.rb
178
+ - spec/models/string_id.rb
179
+ - spec/models/subject.rb
180
+ - spec/models/without_slug.rb
181
+ - spec/mongoid/criteria_spec.rb
182
+ - spec/mongoid/index_spec.rb
183
+ - spec/mongoid/paranoia_spec.rb
184
+ - spec/mongoid/slug_spec.rb
185
+ - spec/mongoid/slug_spec.rb.b00
186
+ - spec/shared/indexes.rb
187
+ - spec/spec_helper.rb
188
+ homepage: https://github.com/digitalplaywright/mongoid-slug
189
+ licenses:
190
+ - MIT
191
+ metadata: {}
192
+ post_install_message:
193
+ rdoc_options: []
194
+ require_paths:
195
+ - lib
196
+ required_ruby_version: !ruby/object:Gem::Requirement
197
+ requirements:
198
+ - - ">="
199
+ - !ruby/object:Gem::Version
200
+ version: '0'
201
+ required_rubygems_version: !ruby/object:Gem::Requirement
202
+ requirements:
203
+ - - ">="
204
+ - !ruby/object:Gem::Version
205
+ version: '0'
206
+ requirements: []
207
+ rubyforge_project: mongoid-slug
208
+ rubygems_version: 2.2.2
209
+ signing_key:
210
+ specification_version: 4
211
+ summary: Mongoid URL slugs
212
+ test_files:
213
+ - spec/models/alias.rb
214
+ - spec/models/article.rb
215
+ - spec/models/author.rb
216
+ - spec/models/author_polymorphic.rb
217
+ - spec/models/book.rb
218
+ - spec/models/book_polymorphic.rb
219
+ - spec/models/caption.rb
220
+ - spec/models/entity.rb
221
+ - spec/models/friend.rb
222
+ - spec/models/incorrect_slug_persistence.rb
223
+ - spec/models/integer_id.rb
224
+ - spec/models/magazine.rb
225
+ - spec/models/page.rb
226
+ - spec/models/page_localize.rb
227
+ - spec/models/page_slug_localized.rb
228
+ - spec/models/page_slug_localized_custom.rb
229
+ - spec/models/page_slug_localized_history.rb
230
+ - spec/models/paranoid_document.rb
231
+ - spec/models/paranoid_permanent.rb
232
+ - spec/models/partner.rb
233
+ - spec/models/person.rb
234
+ - spec/models/relationship.rb
235
+ - spec/models/string_id.rb
236
+ - spec/models/subject.rb
237
+ - spec/models/without_slug.rb
238
+ - spec/mongoid/criteria_spec.rb
239
+ - spec/mongoid/index_spec.rb
240
+ - spec/mongoid/paranoia_spec.rb
241
+ - spec/mongoid/slug_spec.rb
242
+ - spec/mongoid/slug_spec.rb.b00
243
+ - spec/shared/indexes.rb
244
+ - spec/spec_helper.rb
245
+ has_rdoc: