friendly_id 5.2.3 → 5.4.0

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.
Files changed (45) hide show
  1. checksums.yaml +5 -5
  2. checksums.yaml.gz.sig +0 -0
  3. data/.github/stale.yml +17 -0
  4. data/.github/workflows/test.yml +60 -0
  5. data/Changelog.md +39 -1
  6. data/Gemfile +3 -0
  7. data/README.md +54 -163
  8. data/Rakefile +2 -2
  9. data/UPGRADING.md +115 -0
  10. data/certs/parndt.pem +25 -0
  11. data/friendly_id.gemspec +7 -3
  12. data/gemfiles/Gemfile.rails-5.0.rb +2 -2
  13. data/gemfiles/{Gemfile.rails-4.2.rb → Gemfile.rails-5.1.rb} +4 -5
  14. data/gemfiles/{Gemfile.rails-4.1.rb → Gemfile.rails-5.2.rb} +5 -7
  15. data/gemfiles/{Gemfile.rails-4.0.rb → Gemfile.rails-6.0.rb} +5 -8
  16. data/lib/friendly_id/base.rb +4 -8
  17. data/lib/friendly_id/candidates.rb +0 -2
  18. data/lib/friendly_id/configuration.rb +3 -2
  19. data/lib/friendly_id/finder_methods.rb +18 -7
  20. data/lib/friendly_id/finders.rb +1 -1
  21. data/lib/friendly_id/history.rb +21 -12
  22. data/lib/friendly_id/initializer.rb +11 -0
  23. data/lib/friendly_id/migration.rb +9 -3
  24. data/lib/friendly_id/object_utils.rb +9 -2
  25. data/lib/friendly_id/scoped.rb +8 -1
  26. data/lib/friendly_id/sequentially_slugged.rb +12 -2
  27. data/lib/friendly_id/slug.rb +4 -0
  28. data/lib/friendly_id/slugged.rb +2 -2
  29. data/lib/friendly_id/version.rb +1 -1
  30. data/test/databases.yml +6 -4
  31. data/test/finders_test.rb +24 -0
  32. data/test/helper.rb +13 -3
  33. data/test/history_test.rb +86 -7
  34. data/test/numeric_slug_test.rb +31 -0
  35. data/test/object_utils_test.rb +2 -0
  36. data/test/schema.rb +19 -2
  37. data/test/scoped_test.rb +13 -0
  38. data/test/sequentially_slugged_test.rb +59 -0
  39. data/test/shared.rb +2 -2
  40. data/test/simple_i18n_test.rb +2 -2
  41. data/test/slugged_test.rb +168 -4
  42. data.tar.gz.sig +2 -0
  43. metadata +44 -15
  44. metadata.gz.sig +0 -0
  45. data/.travis.yml +0 -40
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 8ecc233dd377f5400a788a6a6fb7d37e2f4b200c
4
- data.tar.gz: 9c848d7c0f238d70577cb0737b1f6411e779a6d5
2
+ SHA256:
3
+ metadata.gz: 6fa83b80901ae7c4930b4a0dea61544152f2cc4a7d94b828c2f52e807fb5d686
4
+ data.tar.gz: b5db403619e2d9bc275d567dc9f567fb943316e1222bc9c6052e43a285b92116
5
5
  SHA512:
6
- metadata.gz: 4c0a2db2212245e2dcadd50a6f62e3970a10ca72d7230e92cebf31a03da6772c23d2203303e08ff51ed9c9985f234310e01db91f0baa79c663c9756b84181b7a
7
- data.tar.gz: cc539ec2396d5736499c3852d0bd967c10d1d6d0ec3afd63b137634e9ac7f6365d7b073895c5297390a42ad74a9cb363064c81c317ad899f3e44f6f15a312f19
6
+ metadata.gz: f8c8bef9ec1e0a42103fa813d40b087bcb84c1f3148f73d53d21fde568865b9a6dc0a2c83508431a2ffa2c2b09bf7f3d26e49b30ac09a758e39dd02323aff328
7
+ data.tar.gz: 0f78de10e8d9597728e554dc53949318f23a5771adb8014b23172c204f550c48b5f2222f8df144a4368d5f34560f01051a5f42183fcac415f85ad9e1bfb262e4
checksums.yaml.gz.sig ADDED
Binary file
data/.github/stale.yml ADDED
@@ -0,0 +1,17 @@
1
+ # Number of days of inactivity before an issue becomes stale
2
+ daysUntilStale: 42
3
+ # Number of days of inactivity before a stale issue is closed
4
+ daysUntilClose: 7
5
+ # Issues with these labels will never be considered stale
6
+ exemptLabels:
7
+ - pinned
8
+ - security
9
+ # Label to use when marking an issue as stale
10
+ staleLabel: stale
11
+ # Comment to post when marking an issue as stale. Set to `false` to disable
12
+ markComment: >
13
+ This issue has been automatically marked as stale because it has not had
14
+ recent activity. It will be closed if no further activity occurs. Thank you
15
+ for your contributions.
16
+ # Comment to post when closing a stale issue. Set to `false` to disable
17
+ closeComment: false
@@ -0,0 +1,60 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - 'master'
7
+ pull_request:
8
+ jobs:
9
+ test:
10
+ strategy:
11
+ matrix:
12
+ architecture: [ x64 ]
13
+ database: [ mysql, postgresql ]
14
+ gemfile: [ '6.0', '5.2', '5.1', '5.0' ]
15
+ ruby: [ '2.6.x', '2.5.x' ]
16
+ fail-fast: false
17
+ runs-on: ubuntu-latest
18
+ name: ${{ matrix.ruby }} ${{ matrix.database }} rails-${{ matrix.gemfile }}
19
+ steps:
20
+ - uses: actions/setup-ruby@v1.0.0
21
+ with:
22
+ architecture: ${{ matrix.architecture }}
23
+ ruby-version: ${{ matrix.ruby }}
24
+ version: ${{ matrix.ruby }}
25
+ - uses: actions/checkout@v1
26
+ - run: sudo apt-get update && sudo apt-get install libpq-dev postgresql-client libmysqlclient-dev mysql-client libsqlite3-dev -y
27
+ - id: cache-bundler
28
+ uses: actions/cache@v1
29
+ with:
30
+ path: vendor/bundle
31
+ key: ${{ matrix.ruby }}-gem-${{ hashFiles(format('gemfiles/Gemfile.rails-{0}.rb', matrix.gemfile)) }}
32
+ - run: gem install bundler
33
+ - run: bundle install --path vendor/bundle
34
+ - run: bundle exec rake db:create db:up
35
+ - run: bundle exec rake test
36
+
37
+ env:
38
+ BUNDLE_JOBS: 4
39
+ BUNDLE_GEMFILE: gemfiles/Gemfile.rails-${{ matrix.gemfile }}.rb
40
+ BUNDLE_PATH: vendor/bundle
41
+ CI: true
42
+ COVERALLS: true
43
+ DB: ${{ matrix.database }}
44
+ MYSQL_PASSWORD: root
45
+ PGHOST: localhost
46
+ PGPORT: 5432
47
+ PGUSER: postgres
48
+ RAILS_ENV: test
49
+
50
+ services:
51
+ postgres:
52
+ image: postgres:11.5
53
+ ports: ["5432:5432"]
54
+ options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
55
+ mysql:
56
+ image: mysql:5.7
57
+ ports: ["3306:3306"]
58
+ options: --health-cmd "mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 5
59
+ env:
60
+ MYSQL_ROOT_PASSWORD: root
data/Changelog.md CHANGED
@@ -3,6 +3,44 @@
3
3
  We would like to think our many [contributors](https://github.com/norman/friendly_id/graphs/contributors) for
4
4
  suggestions, ideas and improvements to FriendlyId.
5
5
 
6
+ ## Unreleased
7
+
8
+ ## 5.4.0 (2020-08-14)
9
+
10
+ * Fix Ruby 2.7 keyword params deprecation warning ([#939](https://github.com/norman/friendly_id/pull/939))
11
+ * Fix Slug Validation in `unset_slug_if_invalid` ([#938](https://github.com/norman/friendly_id/pull/938))
12
+ * Make `first_by_friendly_id` case insensitive using `downcase` ([#787](https://github.com/norman/friendly_id/pull/787))
13
+ * Use `destroy_all` rather than `delete_all` when creating historical slugs ([#924](https://github.com/norman/friendly_id/pull/924))
14
+ * Set required ruby version to `>= 2.1.0` ([#923](https://github.com/norman/friendly_id/pull/923))
15
+ * Avoid using deprecated `update_attributes` ([#922](https://github.com/norman/friendly_id/pull/922))
16
+
17
+ ## 5.3.0 (2019-09-25)
18
+
19
+ * Record history when scope changes but slug does not ([#916](https://github.com/norman/friendly_id/pull/916))
20
+ * Add support for Rails 6 ([#897](https://github.com/norman/friendly_id/pull/897))
21
+
22
+ ## 5.2.5 (2018-12-30)
23
+
24
+ * Pass all possible parameters to ActiveRecord::RecordNotFound.new when raising the exception ([#890](https://github.com/norman/friendly_id/pull/890))
25
+ * Use composite index for queries by sluggable ([#882](https://github.com/norman/friendly_id/pull/882))
26
+ * Scoped: generate new slug if scope changed ([#878](https://github.com/norman/friendly_id/pull/878))
27
+ * Fix History + SequentiallySlugged issues ([#877](https://github.com/norman/friendly_id/pull/877))
28
+ * Support scoped with STI ([#745](https://github.com/norman/friendly_id/pull/745))
29
+ * Fix exists? to behave the same as find for numeric slugs ([#875](https://github.com/norman/friendly_id/pull/875))
30
+ * Remove dirty tracking code from to_param ([#867](https://github.com/norman/friendly_id/pull/867))
31
+
32
+ ## 5.2.4 (2018-04-24)
33
+
34
+ * Fix compatibility with Rails versions 4.0 -> 5.2. ([#863](https://github.com/norman/friendly_id/pull/863)).
35
+ * Refactor `History::FinderMethods` to use base implementation. ([#853](https://github.com/norman/friendly_id/pull/853)).
36
+ * Defer loading of ActiveRecord to avoid config issues. ([#852](https://github.com/norman/friendly_id/pull/852)).
37
+ * Ensure compatibility with paranoid deletion libraries. ([#838](https://github.com/norman/friendly_id/pull/838)).
38
+ * Add treat_reserved_as_conflict option to initializer ([#847](https://github.com/norman/friendly_id/pull/847)).
39
+
40
+ ## 5.2.3 (2017-09-22)
41
+
42
+ * Added option to treat reserved words as conflicts ([#831](https://github.com/norman/friendly_id/pull/831)).
43
+
6
44
  ## 5.2.2 (2017-09-13)
7
45
 
8
46
  * Prevent warning on db:migrate in Rails 5.1 ([#826](https://github.com/norman/friendly_id/pull/826)).
@@ -24,7 +62,7 @@ suggestions, ideas and improvements to FriendlyId.
24
62
  * Don't calculate all changes just to check if the param field has changed ([#667](https://github.com/norman/friendly_id/pull/667)).
25
63
  * Don't set or change slug when unrelated validation failures block the record from being saved ([#642](https://github.com/norman/friendly_id/issues/642)).
26
64
  * Fix order dependence bug between history and finders modules ([#718](https://github.com/norman/friendly_id/pull/718))
27
- * Added ability to conditionally turn off :dependent => :destory on FriendlyId::Slugs([#724](https://github.com/norman/friendly_id/pull/724))
65
+ * Added ability to conditionally turn off `:dependent => :destroy` on FriendlyId::Slugs([#724](https://github.com/norman/friendly_id/pull/724))
28
66
  * Add support for Rails 5. ([#728](https://github.com/norman/friendly_id/pull/728))
29
67
  * Allow per-model conditional disabling of friendly path generation using a :routes option to friendly_id ([#735](https://github.com/norman/friendly_id/pull/735))
30
68
 
data/Gemfile CHANGED
@@ -2,9 +2,12 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
+ gem 'rake'
6
+
5
7
  group :development, :test do
6
8
  platforms :ruby do
7
9
  gem 'byebug'
10
+ gem 'pry'
8
11
  end
9
12
 
10
13
  platforms :jruby do
data/README.md CHANGED
@@ -1,19 +1,7 @@
1
- [![Build Status](https://travis-ci.org/norman/friendly_id.svg)](https://travis-ci.org/norman/friendly_id)
1
+ [![Build Status](https://github.com/norman/friendly_id/workflows/CI/badge.svg)](https://github.com/norman/friendly_id/actions)
2
2
  [![Code Climate](https://codeclimate.com/github/norman/friendly_id.svg)](https://codeclimate.com/github/norman/friendly_id)
3
3
  [![Inline docs](http://inch-ci.org/github/norman/friendly_id.svg?branch=master)](http://inch-ci.org/github/norman/friendly_id)
4
4
 
5
- **GETTING HELP**
6
-
7
- Please ask questions on [Stack
8
- Overflow](http://stackoverflow.com/questions/tagged/friendly-id) using the
9
- "friendly-id" tag. Prior to asking, search and see if your question has
10
- already been answered.
11
-
12
- Please only post issues in Github issues for actual bugs.
13
-
14
- I am asking people to do this because the same questions keep getting asked
15
- over and over and over again in the issues.
16
-
17
5
  # FriendlyId
18
6
 
19
7
  **For the most complete, user-friendly documentation, see the [FriendlyId Guide](http://norman.github.io/friendly_id/file.Guide.html).**
@@ -31,185 +19,88 @@ instead of:
31
19
  http://example.com/states/4323454
32
20
 
33
21
 
34
- ## FriendlyId Features
35
-
36
- FriendlyId offers many advanced features, including: slug history and
37
- versioning, i18n, scoped slugs, reserved words, and custom slug generators.
38
-
39
- ### What Changed in Version 5.1
40
-
41
- 5.1 is a bugfix release, but bumps the minor version because some applications may be dependent
42
- on the previously buggy behavior. The changes include:
43
-
44
- * Blank strings can no longer be used as slugs.
45
- * When the first slug candidate is rejected because it is reserved, additional candidates will
46
- now be considered before marking the record as invalid.
47
- * The `:finders` module is now compatible with Rails 4.2.
48
-
49
- ### What Changed in Version 5.0
50
-
51
- As of version 5.0, FriendlyId uses [semantic versioning](http://semver.org/). Therefore, as you might
52
- infer from the version number, 5.0 introduces changes incompatible with 4.0.
53
-
54
- The most important changes are:
55
-
56
- * Finders are no longer overridden by default. If you want to do friendly finds,
57
- you must do `Model.friendly.find` rather than `Model.find`. You can however
58
- restore FriendlyId 4-style finders by using the `:finders` addon:
59
-
60
- ```ruby
61
- friendly_id :foo, use: :slugged # you must do MyClass.friendly.find('bar')
62
- # or...
63
- friendly_id :foo, use: [:slugged, :finders] # you can now do MyClass.find('bar')
64
- ```
65
- * A new "candidates" functionality which makes it easy to set up a list of
66
- alternate slugs that can be used to uniquely distinguish records, rather than
67
- appending a sequence. For example:
68
-
69
- ```ruby
70
- class Restaurant < ActiveRecord::Base
71
- extend FriendlyId
72
- friendly_id :slug_candidates, use: :slugged
73
-
74
- # Try building a slug based on the following fields in
75
- # increasing order of specificity.
76
- def slug_candidates
77
- [
78
- :name,
79
- [:name, :city],
80
- [:name, :street, :city],
81
- [:name, :street_number, :street, :city]
82
- ]
83
- end
84
- end
85
- ```
86
- * Now that candidates have been added, FriendlyId no longer uses a numeric
87
- sequence to differentiate conflicting slug, but rather a UUID (e.g. something
88
- like `2bc08962-b3dd-4f29-b2e6-244710c86106`). This makes the
89
- codebase simpler and more reliable when running concurrently, at the expense
90
- of uglier ids being generated when there are conflicts.
91
- * The default sequence separator has been changed from two dashes to one dash.
92
- * Slugs are no longer regenerated when a record is saved. If you want to regenerate
93
- a slug, you must explicitly set the slug column to nil:
94
-
95
- ```ruby
96
- restaurant.friendly_id # joes-diner
97
- restaurant.name = "The Plaza Diner"
98
- restaurant.save!
99
- restaurant.friendly_id # joes-diner
100
- restaurant.slug = nil
101
- restaurant.save!
102
- restaurant.friendly_id # the-plaza-diner
103
- ```
104
-
105
- You can restore some of the old behavior by overriding the
106
- `should_generate_new_friendly_id?` method.
107
- * The `friendly_id` Rails generator now generates an initializer showing you
108
- how to do some common global configuration.
109
- * The Globalize plugin has moved to a [separate gem](https://github.com/norman/friendly_id-globalize) (currently in alpha).
110
- * The `:reserved` module no longer includes any default reserved words.
111
- Previously it blocked "edit" and "new" everywhere. The default word list has
112
- been moved to `config/initializers/friendly_id.rb` and now includes many more
113
- words.
114
- * The `:history` and `:scoped` addons can now be used together.
115
- * Since it now requires Rails 4, FriendlyId also now requires Ruby 1.9.3 or
116
- higher.
117
-
118
- #### Upgrading from FriendlyId 4.0
119
-
120
- Run `rails generate friendly_id --skip-migration` and edit the initializer
121
- generated in `config/initializers/friendly_id.rb`. This file contains notes
122
- describing how to restore (or not) some of the defaults from FriendlyId 4.0.
123
-
124
- If you want to use the `:history` and `:scoped` addons together, you must add a
125
- `:scope` column to your friendly_id_slugs table and replace the unique index on
126
- `:slug` and `:sluggable_type` with a unique index on those two columns, plus
127
- the new `:scope` column.
128
-
129
- A migration like this should be sufficient:
130
-
131
- ```ruby
132
- add_column :friendly_id_slugs, :scope, :string
133
- remove_index :friendly_id_slugs, [:slug, :sluggable_type]
134
- add_index :friendly_id_slugs, [:slug, :sluggable_type]
135
- add_index :friendly_id_slugs, [:slug, :sluggable_type, :scope], unique: true
136
- ```
137
-
138
- ## Articles
139
-
140
- [Migrating an ad-hoc URL slug system to FriendlyId](http://olivierlacan.com/posts/migrating-an-ad-hoc-url-slug-system-to-friendly-id/)
141
- [Pretty URLs with FriendlyId](http://railscasts.com/episodes/314-pretty-urls-with-friendlyid)
142
-
143
- ## Docs
22
+ ## Getting Help
144
23
 
145
- The most current docs from the master branch can always be found
146
- [here](http://norman.github.io/friendly_id).
24
+ Ask questions on [Stack Overflow](http://stackoverflow.com/questions/tagged/friendly-id)
25
+ using the "friendly-id" tag, and for bugs have a look at [the bug section](https://github.com/norman/friendly_id#bugs)
147
26
 
148
- Docs for older versions are also available:
27
+ ## FriendlyId Features
149
28
 
150
- * [5.0](http://norman.github.io/friendly_id/5.0/)
151
- * [4.0](http://norman.github.io/friendly_id/4.0/)
152
- * [3.3](http://norman.github.io/friendly_id/3.3/)
153
- * [2.3](http://norman.github.io/friendly_id/2.3/)
29
+ FriendlyId offers many advanced features, including:
154
30
 
155
- The best place to start is with the
156
- [Guide](http://norman.github.io/friendly_id/file.Guide.html),
157
- which compiles the top-level RDocs into one outlined document.
31
+ * slug history and versioning
32
+ * i18n
33
+ * scoped slugs
34
+ * reserved words
35
+ * custom slug generators
158
36
 
159
- For a getting started video, you may want to watch [GoRails #9](https://gorails.com/episodes/pretty-urls-with-friendly-id)
37
+ ## Usage
160
38
 
161
- You might also want to watch Ryan Bates's [Railscast on FriendlyId](http://railscasts.com/episodes/314-pretty-urls-with-friendlyid),
162
- which is now somewhat outdated but still relevant.
39
+ Add this line to your application's Gemfile:
163
40
 
41
+ ```ruby
42
+ gem 'friendly_id', '~> 5.2.4' # Note: You MUST use 5.0.0 or greater for Rails 4.0+
43
+ ```
164
44
 
165
- ## Rails Quickstart
45
+ And then execute:
166
46
 
167
47
  ```shell
168
- rails new my_app
169
- cd my_app
48
+ bundle install
170
49
  ```
171
- ```ruby
172
- # Gemfile
173
- gem 'friendly_id', '~> 5.1.0' # Note: You MUST use 5.0.0 or greater for Rails 4.0+
50
+
51
+ Add a `slug` column to the desired table (e.g. `Users`)
52
+ ```shell
53
+ rails g migration AddSlugToUsers slug:uniq
174
54
  ```
55
+
56
+ Generate the friendly configuration file and a new migration
57
+
175
58
  ```shell
176
59
  rails generate friendly_id
177
60
  ```
178
- >Temp solution for Rails 5.1+ : Before running the migration, go into the generated migration file and specify the Rails version:
179
- `class CreateFriendlyIdSlugs < ActiveRecord::Migration[5.1]`
61
+
62
+ Note: You can delete the `CreateFriendlyIdSlugs` migration if you won't use the slug history feature. ([Read more](https://norman.github.io/friendly_id/FriendlyId/History.html))
63
+
64
+ Run the migration scripts
65
+
180
66
  ```shell
181
- rails generate scaffold user name:string slug:string:uniq
182
- rake db:migrate
67
+ rails db:migrate
183
68
  ```
69
+
70
+ Edit the `app/models/user.rb` file as the following:
71
+
184
72
  ```ruby
185
- # edit app/models/user.rb
186
73
  class User < ApplicationRecord
187
74
  extend FriendlyId
188
75
  friendly_id :name, use: :slugged
189
76
  end
77
+ ```
190
78
 
191
- User.create! name: "Joe Schmoe"
79
+ Edit the `app/controllers/users_controller.rb` file and replace `User.find` by `User.friendly.find`
192
80
 
193
- # Change User.find to User.friendly.find in your controller
194
- User.friendly.find(params[:id])
81
+ ```ruby
82
+ class UserController < ApplicationController
83
+ def show
84
+ @user = User.friendly.find(params[:id])
85
+ end
86
+ end
195
87
  ```
196
- ```shell
197
- rails server
198
88
 
199
- GET http://localhost:3000/users/joe-schmoe
200
- ```
89
+ Now when you create a new user like the following:
90
+
201
91
  ```ruby
202
- # If you're adding FriendlyId to an existing app and need
203
- # to generate slugs for existing users, do this from the
204
- # console, runner, or add a Rake task:
205
- User.find_each(&:save)
92
+ User.create! name: "Joe Schmoe"
206
93
  ```
207
94
 
208
- ## Benchmarks
95
+ You can then access the user show page using the URL http://localhost:3000/users/joe-schmoe.
96
+
209
97
 
210
- The latest benchmarks for FriendlyId are maintained
211
- [here](http://bit.ly/friendly-id-benchmarks).
98
+ If you're adding FriendlyId to an existing app and need to generate slugs for
99
+ existing users, do this from the console, runner, or add a Rake task:
212
100
 
101
+ ```ruby
102
+ User.find_each(&:save)
103
+ ```
213
104
 
214
105
  ## Bugs
215
106
 
@@ -226,8 +117,8 @@ If you have a bug to report, please include the following information:
226
117
  If you are able to, it helps even more if you can fork FriendlyId on Github,
227
118
  and add a test that reproduces the error you are experiencing.
228
119
 
229
- For more info on how to report bugs, please see [this
230
- article](http://yourbugreportneedsmore.info/).
120
+ For more inspiration on how to report bugs, please see [this
121
+ article](https://www.chiark.greenend.org.uk/~sgtatham/bugs.html).
231
122
 
232
123
  ## Thanks and Credits
233
124
 
data/Rakefile CHANGED
@@ -71,7 +71,7 @@ namespace :db do
71
71
  driver = FriendlyId::Test::Database.driver
72
72
  config = FriendlyId::Test::Database.config[driver]
73
73
  commands = {
74
- "mysql" => "mysql -u #{config['username']} -e 'create database #{config["database"]};' >/dev/null",
74
+ "mysql" => "mysql -h #{config['host']} -P #{config['port']} -u #{config['username']} --password=#{config['password']} -e 'create database #{config["database"]};' >/dev/null",
75
75
  "postgres" => "psql -c 'create database #{config['database']};' -U #{config['username']} >/dev/null"
76
76
  }
77
77
  %x{#{commands[driver] || true}}
@@ -83,7 +83,7 @@ namespace :db do
83
83
  driver = FriendlyId::Test::Database.driver
84
84
  config = FriendlyId::Test::Database.config[driver]
85
85
  commands = {
86
- "mysql" => "mysql -u #{config['username']} -e 'drop database #{config["database"]};' >/dev/null",
86
+ "mysql" => "mysql -h #{config['host']} -P #{config['port']} -u #{config['username']} --password=#{config['password']} -e 'drop database #{config["database"]};' >/dev/null",
87
87
  "postgres" => "psql -c 'drop database #{config['database']};' -U #{config['username']} >/dev/null"
88
88
  }
89
89
  %x{#{commands[driver] || true}}
data/UPGRADING.md ADDED
@@ -0,0 +1,115 @@
1
+ ## Articles
2
+
3
+ * [Migrating an ad-hoc URL slug system to FriendlyId](http://olivierlacan.com/posts/migrating-an-ad-hoc-url-slug-system-to-friendly-id/)
4
+ * [Pretty URLs with FriendlyId](http://railscasts.com/episodes/314-pretty-urls-with-friendlyid)
5
+
6
+ ## Docs
7
+
8
+ The most current docs from the master branch can always be found
9
+ [here](http://norman.github.io/friendly_id).
10
+
11
+ Docs for older versions are also available:
12
+
13
+ * [5.0](http://norman.github.io/friendly_id/5.0/)
14
+ * [4.0](http://norman.github.io/friendly_id/4.0/)
15
+ * [3.3](http://norman.github.io/friendly_id/3.3/)
16
+ * [2.3](http://norman.github.io/friendly_id/2.3/)
17
+
18
+ ## What Changed in Version 5.1
19
+
20
+ 5.1 is a bugfix release, but bumps the minor version because some applications may be dependent
21
+ on the previously buggy behavior. The changes include:
22
+
23
+ * Blank strings can no longer be used as slugs.
24
+ * When the first slug candidate is rejected because it is reserved, additional candidates will
25
+ now be considered before marking the record as invalid.
26
+ * The `:finders` module is now compatible with Rails 4.2.
27
+
28
+ ## What Changed in Version 5.0
29
+
30
+ As of version 5.0, FriendlyId uses [semantic versioning](http://semver.org/). Therefore, as you might
31
+ infer from the version number, 5.0 introduces changes incompatible with 4.0.
32
+
33
+ The most important changes are:
34
+
35
+ * Finders are no longer overridden by default. If you want to do friendly finds,
36
+ you must do `Model.friendly.find` rather than `Model.find`. You can however
37
+ restore FriendlyId 4-style finders by using the `:finders` addon:
38
+
39
+ ```ruby
40
+ friendly_id :foo, use: :slugged # you must do MyClass.friendly.find('bar')
41
+ # or...
42
+ friendly_id :foo, use: [:slugged, :finders] # you can now do MyClass.find('bar')
43
+ ```
44
+ * A new "candidates" functionality which makes it easy to set up a list of
45
+ alternate slugs that can be used to uniquely distinguish records, rather than
46
+ appending a sequence. For example:
47
+
48
+ ```ruby
49
+ class Restaurant < ActiveRecord::Base
50
+ extend FriendlyId
51
+ friendly_id :slug_candidates, use: :slugged
52
+
53
+ # Try building a slug based on the following fields in
54
+ # increasing order of specificity.
55
+ def slug_candidates
56
+ [
57
+ :name,
58
+ [:name, :city],
59
+ [:name, :street, :city],
60
+ [:name, :street_number, :street, :city]
61
+ ]
62
+ end
63
+ end
64
+ ```
65
+ * Now that candidates have been added, FriendlyId no longer uses a numeric
66
+ sequence to differentiate conflicting slug, but rather a UUID (e.g. something
67
+ like `2bc08962-b3dd-4f29-b2e6-244710c86106`). This makes the
68
+ codebase simpler and more reliable when running concurrently, at the expense
69
+ of uglier ids being generated when there are conflicts.
70
+ * The default sequence separator has been changed from two dashes to one dash.
71
+ * Slugs are no longer regenerated when a record is saved. If you want to regenerate
72
+ a slug, you must explicitly set the slug column to nil:
73
+
74
+ ```ruby
75
+ restaurant.friendly_id # joes-diner
76
+ restaurant.name = "The Plaza Diner"
77
+ restaurant.save!
78
+ restaurant.friendly_id # joes-diner
79
+ restaurant.slug = nil
80
+ restaurant.save!
81
+ restaurant.friendly_id # the-plaza-diner
82
+ ```
83
+
84
+ You can restore some of the old behavior by overriding the
85
+ `should_generate_new_friendly_id?` method.
86
+ * The `friendly_id` Rails generator now generates an initializer showing you
87
+ how to do some common global configuration.
88
+ * The Globalize plugin has moved to a [separate gem](https://github.com/norman/friendly_id-globalize) (currently in alpha).
89
+ * The `:reserved` module no longer includes any default reserved words.
90
+ Previously it blocked "edit" and "new" everywhere. The default word list has
91
+ been moved to `config/initializers/friendly_id.rb` and now includes many more
92
+ words.
93
+ * The `:history` and `:scoped` addons can now be used together.
94
+ * Since it now requires Rails 4, FriendlyId also now requires Ruby 1.9.3 or
95
+ higher.
96
+
97
+ ## Upgrading from FriendlyId 4.0
98
+
99
+ Run `rails generate friendly_id --skip-migration` and edit the initializer
100
+ generated in `config/initializers/friendly_id.rb`. This file contains notes
101
+ describing how to restore (or not) some of the defaults from FriendlyId 4.0.
102
+
103
+ If you want to use the `:history` and `:scoped` addons together, you must add a
104
+ `:scope` column to your friendly_id_slugs table and replace the unique index on
105
+ `:slug` and `:sluggable_type` with a unique index on those two columns, plus
106
+ the new `:scope` column.
107
+
108
+ A migration like this should be sufficient:
109
+
110
+ ```ruby
111
+ add_column :friendly_id_slugs, :scope, :string
112
+ remove_index :friendly_id_slugs, [:slug, :sluggable_type]
113
+ add_index :friendly_id_slugs, [:slug, :sluggable_type]
114
+ add_index :friendly_id_slugs, [:slug, :sluggable_type, :scope], unique: true
115
+ ```
data/certs/parndt.pem ADDED
@@ -0,0 +1,25 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIEMjCCApqgAwIBAgIBATANBgkqhkiG9w0BAQsFADAjMSEwHwYDVQQDDBhnZW1z
3
+ L0RDPXAvREM9YXJuZHQvREM9aW8wHhcNMjAwNTEwMjIxOTQ2WhcNMjEwNTEwMjIx
4
+ OTQ2WjAjMSEwHwYDVQQDDBhnZW1zL0RDPXAvREM9YXJuZHQvREM9aW8wggGiMA0G
5
+ CSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDT+JzHYPGMYJt9ct2DCsbIymn1uJJp
6
+ HnDkQESfsGe40jTC90oF2iVbVOkaacNc1N3CSWUZvZjuygUuS86P6/kpBILGdO2+
7
+ bkXXKtfGC2YGGx9TdNLpCb4925vQHvdFeKXGpQDZdDw1SNC6zraZou47CvOE1cl2
8
+ Bp+1QMZuGRZ4+5CzOEWDWurjqce3O1jUEbyBB7z5H0h/YEaxfXipxhL1Dhi0sgkH
9
+ qP/e6SxzifdifdZCksJFQ06a1ji9hJY6eM23qbv/aaluVHAZSVBAQBS7rYniLo+N
10
+ G4vpFhoubQO5u8UluUtCaPUpI/qOvVcSaZn3ZkzlMwC8b1RwAeXBQmtFE2wnrv2i
11
+ ovTwoN7rHchwhgaHbkuFh4Wr92wGbrWL7J+X8rWKk1f8RF4kvtNE/NA6YrkxTpVh
12
+ QMyDmekt7rTxvcq2NneLGroWIUVCx/JID+Jw492LKQ6Sl1/P2TRzdEDtqZAZL0gt
13
+ xlWeMUfGG2D/gLnhs5qnaFaWQwGTmBnTgHcCAwEAAaNxMG8wCQYDVR0TBAIwADAL
14
+ BgNVHQ8EBAMCBLAwHQYDVR0OBBYEFEqtAyQVxPgKsrgoTQ1YmaIu/fmvMBoGA1Ud
15
+ EQQTMBGBD2dlbXNAcC5hcm5kdC5pbzAaBgNVHRIEEzARgQ9nZW1zQHAuYXJuZHQu
16
+ aW8wDQYJKoZIhvcNAQELBQADggGBALu2HM50B8xqlAXkCwavJDvWWtV9pG1igFUg
17
+ friZRWprUQ5nTaNmAd8p8qbJQwaIK2gt+DfYWfB9LtKnQTfbhLRBbmJ7zYw8LjKY
18
+ PwCs4RWjDAiuyCO3ppfsz+1bsMUXPLgWlaUkXsUy3nr2NruEFTO9zu3wGYQQ93Tt
19
+ vYSHOnP35UB4QjsjNrOO7FBaQfy6O909PP+GnVcJ62s9c26voJz63RSolwY7Jydw
20
+ XUlG68jjJKSoDHRzVTmNB7sX8rs8P2kvYkpIUXPHyls3mWBWjBWbdEYWESZrxI2x
21
+ dS7jY3AnfqhvsWra2pSREb2IDqPnJrHVOejnEI/zuuufUxLwDx3AC6SMdsyWkZ7V
22
+ 9OmLt2rg75Sct6h2220lO5ySqYtqAXuOMBDGv5L0zLalx1g8LACA7uILTKVWh8B8
23
+ Hsej0MQ3drCB1eA4c9OXdCUQJnY2aLTq3uNvTbZvoTgWK55eq3KLBJ4zzoKZ4tBX
24
+ /HIFI/fEwYlI1Ji3oikUrHkc4rWgaQ==
25
+ -----END CERTIFICATE-----
data/friendly_id.gemspec CHANGED
@@ -8,18 +8,17 @@ Gem::Specification.new do |s|
8
8
  s.email = ["norman@njclarke.com", "p@arndt.io"]
9
9
  s.homepage = "https://github.com/norman/friendly_id"
10
10
  s.summary = "A comprehensive slugging and pretty-URL plugin."
11
- s.rubyforge_project = "friendly_id"
12
11
  s.files = `git ls-files`.split("\n")
13
12
  s.test_files = `git ls-files -- {test}/*`.split("\n")
14
13
  s.require_paths = ["lib"]
15
14
  s.license = 'MIT'
16
15
 
17
- s.required_ruby_version = '>= 1.9.3'
16
+ s.required_ruby_version = '>= 2.1.0'
18
17
 
19
18
  s.add_dependency 'activerecord', '>= 4.0.0'
20
19
 
21
20
  s.add_development_dependency 'coveralls'
22
- s.add_development_dependency 'railties', '~> 4.0'
21
+ s.add_development_dependency 'railties', '>= 4.0'
23
22
  s.add_development_dependency 'minitest', '~> 5.3'
24
23
  s.add_development_dependency 'mocha', '~> 1.1'
25
24
  s.add_development_dependency 'yard'
@@ -32,4 +31,9 @@ FriendlyId is the "Swiss Army bulldozer" of slugging and permalink plugins for
32
31
  Active Record. It lets you create pretty URLs and work with human-friendly
33
32
  strings as if they were numeric ids.
34
33
  EOM
34
+
35
+ s.cert_chain = [File.expand_path('certs/parndt.pem', __dir__)]
36
+ if $PROGRAM_NAME =~ /gem\z/ && ARGV.include?('build') && ARGV.include?(__FILE__)
37
+ s.signing_key = File.expand_path('~/.ssh/gem-private_key.pem')
38
+ end
35
39
  end
@@ -9,8 +9,8 @@ gem 'i18n', '~> 0.7.0'
9
9
  # Database Configuration
10
10
  group :development, :test do
11
11
  platforms :jruby do
12
- gem 'activerecord-jdbcmysql-adapter', git: 'https://github.com/jruby/activerecord-jdbc-adapter.git', branch: 'rails-5'
13
- gem 'activerecord-jdbcpostgresql-adapter', git: 'https://github.com/jruby/activerecord-jdbc-adapter.git', branch: 'rails-5'
12
+ gem 'activerecord-jdbcmysql-adapter', '~> 50.1'
13
+ gem 'activerecord-jdbcpostgresql-adapter', '~> 50.1'
14
14
  gem 'kramdown'
15
15
  end
16
16
 
@@ -2,15 +2,14 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec path: '../'
4
4
 
5
- gem 'activerecord', '~> 4.2.1'
6
- gem 'railties', '~> 4.2.1'
7
- gem 'i18n', '~> 0.7.0'
5
+ gem 'activerecord', '~> 5.1.0'
6
+ gem 'railties', '~> 5.1.0'
8
7
 
9
8
  # Database Configuration
10
9
  group :development, :test do
11
10
  platforms :jruby do
12
- gem 'activerecord-jdbcmysql-adapter', '~> 1.3.14'
13
- gem 'activerecord-jdbcpostgresql-adapter', '~> 1.3.14'
11
+ gem 'activerecord-jdbcmysql-adapter', '~> 50.1'
12
+ gem 'activerecord-jdbcpostgresql-adapter', '~> 50.1'
14
13
  gem 'kramdown'
15
14
  end
16
15