friendly_id 4.0.0 → 4.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -10,3 +10,4 @@ coverage
10
10
  *.sqlite3
11
11
  *.rbc
12
12
  *.lock
13
+ .rbx
data/.travis.yml CHANGED
@@ -1,9 +1,8 @@
1
1
  rvm:
2
2
  - 1.9.3
3
- - 1.9.2
4
3
  - 1.8.7
5
- - rbx-2.0
6
- # - jruby
4
+ - jruby
5
+ - rbx
7
6
 
8
7
  branches:
9
8
  only:
@@ -16,5 +15,6 @@ env:
16
15
  gemfile:
17
16
  - gemfiles/Gemfile.rails-3.0.rb
18
17
  - gemfiles/Gemfile.rails-3.1.rb
19
-
20
- script: "bundle exec rake db:reset db:up test"
18
+ - gemfiles/Gemfile.rails-3.2.rb
19
+ before_script: 'bundle exec rake db:create db:up > /dev/null'
20
+ script: 'bundle exec rake test'
data/Changelog.md CHANGED
@@ -6,375 +6,21 @@ suggestions, ideas and improvements to FriendlyId.
6
6
  * Table of Contents
7
7
  {:toc}
8
8
 
9
- ## 4.0.0 (NOT_RELEASED_YET)
9
+ ## 4.0.1 (2012-02-29)
10
+
11
+ * Added support for Globalize 3 (Enrico Pilotto and Philip Arndt)
12
+ * Allow the scoped module to use multiple scopes (Ben Caldwell)
13
+ * Fixes for conflicting slugs in history module (Erik Ogan, Thomas Shafer, Evan Arnold)
14
+ * Fix for conflicting slugs when using STI (Danny van der Heiden, Diederick Lawson)
15
+ * Maintainence improvements (Norman Clarke, Philip Arndt, Thomas Darde, Lee Hambley)
16
+
17
+ ## 4.0.0 (2011-12-27)
10
18
 
11
19
  This is a complete rewrite of FriendlyId, and introduces a smaller, faster and
12
20
  less ambitious codebase. The primary change is the relegation of external slugs
13
21
  to an optional addon, and the adoption of what were formerly "cached slugs"
14
22
  as the primary way of handling slugging.
15
23
 
16
- ## 3.3.0 (NOT_RELEASED_YET)
17
-
18
- This is a compatiblity branch and will be maintained for apps that can't
19
- upgrade to 4.0. No new features are planned, only bugfixes. If you're creating
20
- a new app, please use 4.x.
21
-
22
- * Support for Active Record 2.3 dropped
23
- * Convert blank slugs to nil automatically ([Gabe da Silveira ](https://github.com/dasil003))
24
- * Compatibility with Active Record 3.1 ([Andrew White](https://github.com/pixeltrix))
25
- * Gemspec compatibility with RubyGems 1.7 ([Philip Arndt](https://github.com/parndt))
26
- * Fixed generators for Rails 3.1 ([Matt Burke](https://github.com/spraints))
27
- * Rake task fix for models with primary keys not named "id" ([Danny Hawkins](https://github.com/danhawkins))
28
-
29
-
30
- ## 3.2.1 (2011-02-03)
31
-
32
- * Fixed minor issue with ActiveRecord 3.0.4.rc1 (Bruno Michel)
33
- * Added support for Rubygems-test
34
-
35
- ## 3.2.0 (2011-01-17)
36
-
37
- * Fixed deprecation on Rails edge. Thanks [slbug](http://github.com/slbug)
38
- * Removes `:scope` as a find parameter, allowing more flexible finds with
39
- scoped records.
40
- * Improve logic of `friendly_id:redo_slugs` to support models with non-numeric ids. (thanks Oleksandr Petrov)
41
-
42
- ## 3.1.8 (2010-11-22)
43
-
44
- * Fix compatibility with Active Record 3.0.3.
45
-
46
- ## 3.1.7 (2010-09-22)
47
-
48
- * Reserved words can now be regular expressions.
49
- * Fix broken SQL when finding with a nil scope on AR3 (Tony Primerano)
50
- * Slug#sluggable now works around default scopes (Cyrille Stepanyk)
51
- * Explicitly make slug attributes accessible (William Melody)
52
- * Improve abstraction support for DataMapper and Sequel (Alex Coles).
53
-
54
- ## 3.1.6 (2010-09-02)
55
-
56
- * Fix missing sluggable type in AR3 slug query. This was a fairly major oversight, and if you
57
- are using 3.1.4 or 3.1.5, you should update right away.
58
- * Fix scoped queries when the model has a cached slug column. Bascially, the cached slug
59
- is now completely ignored when a scope is configured.
60
-
61
- ## 3.1.5 (2010-09-01)
62
-
63
- * Fix invalid empty symbol with 1.8.x.
64
-
65
- ## 3.1.4 (2010-09-01)
66
-
67
- * Significantly improve performance of queries using slugs with no cache on AR3.
68
- * Fix callbacks being invoked after setting cached slugs.
69
- * Add validations to some configuration params.
70
-
71
- ## 3.1.3 (2010-08-11)
72
-
73
- * Reverted approach to read-only fix from previous release.
74
- See [this commit](http://github.com/norman/friendly_id/commit/e263f74e446c1e4d95901e9e8d7d6713c078c38e)
75
- for details.
76
-
77
- ## 3.1.2 (2010-08-11)
78
-
79
- * Fixed records being returned read-only. (Thanks Luis Lavena)
80
- * Don't assume relations are subclasses of ActiveRecord::Base. This fixes using
81
- FriendlyId with [Static Model](http://github.com/quirkey/static_model). (Thanks
82
- Luis Lavena)
83
- * Avoid checking for dependent scopes when no models are using the scopes feature.
84
-
85
-
86
- ## 3.1.1 (2010-07-30)
87
-
88
- * Fixed call to method on nil value for failing unfriendly finds (thanks [jlippiner](http://github.com/jlippiner))
89
-
90
- ## 3.1.0 (2010-07-29)
91
-
92
- * Refactored/simplified Active Record 2 and 3 query code.
93
- * Better support for Active Record 3 finds and scopes.
94
- * Extract slug handling code into separate gem, [Babosa](http://github.com/norman/babosa).
95
- * `:max-length` option now uses bytes rather than characters.
96
- * Fix quoting issue that prevented using a domain- or database-qualified column. (thanks James Cropcho)
97
- * Support for Active Record 2.2.x dropped; 2.3 or above is now required.
98
- * Fixed a few small errors on Postgres.
99
- * Improved porability for Sequel and in-progress DataMapper adapter.
100
-
101
- ## 3.0.6 (2010-06-10)
102
-
103
- * Fix bad call to apply_mapping on 2.3.
104
-
105
- ## 3.0.5 (2010-06-10)
106
-
107
- * Fixed support for Rails 3.0 beta4 (Bruno Michel)
108
- * Made rake tasks skip validations (Emilio Tagua).
109
- * Fixed incorrect status of records found with a numeric friendly_id.
110
- * Made slug an explicit has_one relation to enable eager-loading via :include => :slug
111
-
112
- ## 3.0.4 (2010-04-27)
113
-
114
- * Fixed backwards-compatiblity with ActiveSupport 2.3.4 (Thanks Juergen Fesslmeier).
115
-
116
- ## 3.0.3 (2010-04-26)
117
-
118
- * Fixed scope update when models use polymorphic relations.
119
-
120
- ## 3.0.2 (2010-04-09)
121
-
122
- * Fixed finding non-slugged models by an array of ids.
123
- * Added backported `tidy_bytes` implementation from [utf8_utils](http://github.com/norman/utf8_utils)
124
- * Removed dependency on Rubygems 1.3.6; this blocked deploy on Heroku (thanks Steven Noble)
125
- * Replaced File.dirname calls with File.expand_path, which should allow compatibility with Ruby 1.9.2
126
- * Cleanups and some improvements to tests.
127
-
128
- ## 3.0.1 (2010-03-30)
129
-
130
- * Fixed bad path in Rails 2.x generator.
131
-
132
- ## 3.0.0 (2010-03-30)
133
-
134
- * Rails 3 support.
135
- * Removed features deprecated in FriendlyId 2.3.
136
- * Fixed searching by numeric friendly_id in non-slugged models.
137
- * Added `:allow_nil` config option (Andre Duffeck and Norman Clarke)
138
-
139
- ## 2.3.4 (2010-03-22)
140
-
141
- * Made slugged status use the slug sequence. This fixes problems with #best?
142
- returning false when finding with a sequenced slug.
143
- * Doc fixes. (Juan Schiwndt)
144
- * Misc cleanups.
145
-
146
- ## 2.3.3 (2010-03-10)
147
-
148
- * Fixed sequence regexp to grab all trailing digits. (Nash Kabbara)
149
- * Block param now warns, not raises. (Kamal Fariz Mahyuddin)
150
- * Misc doc fixes. (Kamal Fariz Mahyuddin)
151
-
152
- ## 2.3.2 (2010-02-14)
153
-
154
- * Fixed finding by old slug when using cached slugs.
155
- * Sequence separator parsing now correctly handles occurrences of the sequence
156
- separator string inside the friendly_id text (Johan Kok).
157
- * Fixed missing quotes on table names in a few places (Brian Collins).
158
-
159
-
160
- ## 2.3.1 (2010-02-09)
161
-
162
- * Fixed stack level too deep error on #strip_diacritics.
163
-
164
-
165
- ## 2.3.0 (2010-02-04)
166
-
167
- This is a major update à la "Snow Leopard" that adds no new major features,
168
- but significantly improves the underlying code. Most users should be able to
169
- upgrade with no issues other than new deprecation messages appearing in the
170
- logs.
171
-
172
- If, however, you have monkey-patched FriendlyId, or are maintaining your own
173
- fork, then this upgrade may causes issues.
174
-
175
- **Changes:**
176
-
177
- * Sequence separator can now be configured to something other than "--".
178
- * New option to pass arguments to `FriendlyId::SlugString#approximate_ascii!`,
179
- allowing custom approximations specific to German or Spanish.
180
- * FriendlyId now queries against the cached_slug column, which improves performance.
181
- * FriendlyId::SlugString class added, allowing finer-grained control over
182
- Unicode friendly_id strings.
183
- * FriendlyId::Configuration class added, offering more flexible/hackable
184
- options.
185
- * FriendlyId now raises subclasses of FriendlyId::SlugGenerationError
186
- depending on the error context.
187
- * Simple models now correctly validate friendly_id length.
188
- * Passing block into FriendlyId deprecated in favor of overriding
189
- the model's `normalize_friendly_id` method.
190
- * Updating only the model's scope now also updates the slug.
191
- * Major refactorings, cleanups and deprecations en route to the 3.0 release.
192
-
193
- ## 2.2.7 (2009-12-16)
194
-
195
- * Fixed typo in Rake tasks which caused delete_old_slugs to fail. (Diego R.V.)
196
-
197
- ## 2.2.6 (2009-12-10)
198
-
199
- * Made cached_slug automagic configuration occur outside of has_friendly_id.
200
- This was causing problems in code where the class is loaded before
201
- ActiveRecord has established its connection.
202
- * Fixes for scope feature with Postgres (Ben Woosley)
203
- * Migrated away from Hoe/Newgem for gem management.
204
- * Made tests database-agnostic (Ben Woosley)
205
-
206
- ## 2.2.5 (2009-11-30)
207
-
208
- * Fixed typo in config options (Steven Noble).
209
-
210
- ## 2.2.4 (2009-11-12)
211
-
212
- * Fixed typo in post-install message.
213
-
214
- ## 2.2.3 (2009-11-12)
215
-
216
- * Fixed some issues with gem load order under 1.8.x (closes GH Issue #20)
217
- * Made sure friendly_id generator makes a lib/tasks directory (Josh Nichols)
218
- * Finders now accept instances of ActiveRecord::Base, matching AR's behavior
219
- (Josh Nichols)
220
- * SlugGenerationError now raise when a blank value is passed to
221
- strip_diacritics
222
-
223
- ## 2.2.2 (2009-10-26)
224
-
225
- * Fixed Rake tasks creating duplicate slugs and not properly clearing cached
226
- slugs (closes GH issues #14 and #15)
227
-
228
- ## 2.2.1 (2009-10-23)
229
-
230
- * slug cache now properly caches the slug sequence (closes GH issue #10)
231
- * attr_protected is now only invoked on the cached_slug column if
232
- attr_accessible has not already been invoked. (closes GH issue #11)
233
-
234
- ## 2.2.0 (2009-10-19)
235
-
236
- * Added slug caching, offers huge performance boost (Bruno Michel)
237
- * Handle Unicode string length correctly (Mikhail Shirkov)
238
- * Remove alias_method_chain in favor of super (Diego Carrion)
239
-
240
- ## 2.1.4 (2009-09-01)
241
-
242
- * Fixed upgrade generator not installing rake tasks (Harry Love)
243
- * Fixed handling of very large id's (Nathan Phelps)
244
- * Fixed long index name on migration (Rob Ingram)
245
-
246
- ## 2.1.3 (2009-06-03)
247
-
248
- * Always call #to_s on slug_text to allow objects such as DateTimes to be used
249
- for the friendly_id text. (reported by Jon Ng)
250
-
251
- ## 2.1.2 (2009-05-21)
252
-
253
- * Non-slugged models now validate the friendly_id on save as well as create
254
- (Joe Van Dyk).
255
- * Replaced Shoulda with Contest.
256
-
257
- ## 2.1.1 (2009-03-25)
258
-
259
- * Fixed bug with find_some; if a record has old slugs, find_some will no
260
- longer return multiple copies of that record when finding by numerical ID.
261
- (Steve Luscher)
262
- * Fixed bug with find_some: you can now find_some with an array of numerical
263
- IDs without an error being thrown. (Steve Luscher)
264
-
265
- ## 2.1.0 (2009-03-25)
266
-
267
- * Ruby 1.9 compatibility.
268
- * Removed dependency on ancient Unicode gem.
269
-
270
- ## 2.0.4 (2009-02-12)
271
-
272
- * You can now pass in your own custom slug generation blocks while setting up
273
- friendly_id.
274
-
275
- ## 2.0.3 (2009-02-11)
276
-
277
- * Fixed to_param returning an empty string for non-slugged models with a null
278
- friendly_id.
279
-
280
- ## 2.0.2 (2009-02-09)
281
-
282
- * Made FriendlyId depend only on ActiveRecord. It should now be possible to
283
- use FriendlyId with Camping or any other codebase that uses AR.
284
- * Overhauled creaky testing setup and switched to Shoulda.
285
- * Made reserved words work for non-slugged models.
286
-
287
- ## 2.0.1 (2009-01-19)
288
-
289
- * Fix infinite redirect bug when using .has_better_id? in your controllers
290
- (Sean Abrahams)
291
-
292
-
293
- ## 2.0.0 (2009-01-03)
294
-
295
- * Support for scoped slugs (Norman Clarke)
296
- * Support for UTF-8 friendly_ids (Norman Clarke)
297
- * Can now be installed via Ruby Gems, or as a Rails plugin (Norman Clarke)
298
- * Improved handling of non-unique slugs (Norman Clarke and Adrian Mugnolo)
299
- * Shoulda macro (Josh Nichols)
300
- * Various small bugfixes, cleanups and refactorings
301
-
302
- ## 1.0 (2008-12-11)
303
-
304
- * Fixed bug that may return invalid records having similar id/names and using
305
- MySQL. (Emilio Tagua)
306
- * Fixed slug generation to increment only numeric extension without modifying
307
- the name on duplicated slugs. (Emilio Tagua)
308
-
309
- ## 2008-10-31
310
-
311
- * Fixed compatibility with Rails 2.0.x. (Norman Clarke)
312
- * friendly_id::make_slugs update records in chunks of 1000 to avoid running
313
- out of memory with large datasets. (Tim Kadom)
314
- * Fixed logic error with slug name collisions. Thanks to Tim Kadom for
315
- reporting this bug.
316
-
317
- ## 2008-10-22
318
-
319
- * Reverted use of UTF8Handler - was causing errors for some people (Bence Nagy)
320
- * Corrected find in case if a friendly_id begins with number (Bence Nagy)
321
- * Added ability to reserve words from slugs (Adam Cigánek)
322
-
323
- ## 2008-10-09
324
-
325
- * Moved "require"" for iconv to init.rb (Florian Aßmann)
326
- * Removed "require" for Unicode, use Rails' handler instead (Florian Aßmann)
327
- * Replaced some magic numbers with constants (Florian Aßmann)
328
- * Don't overwrite find, alias_method_chain find_one and find_some instead
329
- (Florian Aßmann)
330
- * Slugs behave more like ids now (Florian Aßmann)
331
- * Can find by mixture of ids and slugs (Florian Aßmann)
332
- * Reformatted code and comments (Florian Aßmann)
333
- * Added support for Edge Rails' Inflector::parameterize (Norman Clarke)
334
-
335
- ## 0.5 (2008-08-25)
336
-
337
- * Moved strip_diacritics into Slug for easier reuse/better organization.
338
- * Put class methods inside class << self block. (Norman Clarke)
339
-
340
- * Small change to allow friendly_id to work better with STI. (David Ramalho)
341
-
342
- ## 2008-07-14
343
-
344
- * Improved slug generation for friendly id's with apostrophes. (Alistair Holt)
345
- * Added support for namespaced models in Rakefile. (David Ramalho)
346
-
347
- ## 2008-06-23
348
-
349
- * Cached most recent slug to improve performance (Emilio Tagua).
350
-
351
- ## 2008-06-10
352
-
353
- * Added ability to find friendly_ids by array (Emilio Tagua)
354
-
355
- ## 2008-05-15
356
-
357
- * Made friendly_id raise an error if slug method returns a blank value.
358
-
359
- ## 2008-05-12
360
-
361
- * Added experimental Github gemspec.
362
-
363
- ## 2008-04-18
364
-
365
- * Improved slug name collision avoidance.
366
-
367
- ## 2008-03-13
368
-
369
- * Added :dependent => :destroy to slug relation, as suggested by Emilio Tagua.
370
- * Fixed error when renaming a slugged item back to a previously used name.
371
- * Incorporated documentation changes suggested by Jesse Crouch and Chris Nolan.
372
-
373
- ## 2008-02-07
24
+ ## Older releases
374
25
 
375
- * Applied patches from blog commenter "suntzu" to fix problem with model
376
- values were being overwritten.
377
- * Applied patch from Dan Blue to make friendly_id no longer ignore options on
378
- ActiveRecordBase#find.
379
- * Added call to options.assert_valid_keys in has_friendly_id. Thanks to W.
380
- Andrew Loe III for pointing out that this was missing.
26
+ Please see the 3.x branch.
data/Guide.rdoc CHANGED
@@ -44,7 +44,7 @@ method to configure your desired options:
44
44
 
45
45
  class Foo < ActiveRecord::Base
46
46
  extend FriendlyId
47
- friendly_id bar, :use => [:slugged, :i18n]
47
+ friendly_id :bar, :use => [:slugged, :simple_i18n]
48
48
  end
49
49
 
50
50
  The most important option is `:use`, which you use to tell FriendlyId which
@@ -390,9 +390,10 @@ an example of one way to set this up:
390
390
  http://example.org/cities/chicago/restaurants/joes-diner
391
391
 
392
392
 
393
- == Basic I18n
393
+ == Simple I18n
394
394
 
395
- This {FriendlyId::I18n i18n} adds very basic i18n support to FriendlyId.
395
+ The {FriendlyId::SimpleI18n SimpleI18n} module adds very basic i18n support to
396
+ FriendlyId.
396
397
 
397
398
  In order to use this module, your model must have a slug column for each locale.
398
399
  By default FriendlyId looks for columns named, for example, "slug_en",
@@ -436,13 +437,13 @@ When new records are created, the slug is generated for the current locale only.
436
437
  === Translating Slugs
437
438
 
438
439
  To translate an existing record's friendly_id, use
439
- {FriendlyId::I18n::Model#set_friendly_id}. This will ensure that the slug you
440
- add is properly escaped, transliterated and sequenced:
440
+ {FriendlyId::SimpleI18n::Model#set_friendly_id}. This will ensure that the slug
441
+ you add is properly escaped, transliterated and sequenced:
441
442
 
442
443
  post = Post.create :name => "Star Wars"
443
444
  post.set_friendly_id("La guerra de las galaxas", :es)
444
445
 
445
- If you don't pass in a locale argument, FriendlyId::I18n will just use the
446
+ If you don't pass in a locale argument, FriendlyId::SimpleI18n will just use the
446
447
  current locale:
447
448
 
448
449
  I18n.with_locale(:es) do