friendly_fk 1.0.27 → 1.1.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +44 -0
- data/LICENSE +1 -1
- data/README.md +34 -2
- data/lib/friendly_fk/version.rb +1 -1
- data/lib/friendly_fk.rb +30 -15
- metadata +15 -26
- data/.github/dependabot.yml +0 -11
- data/.github/workflows/bundle-audit.yml +0 -22
- data/.github/workflows/publish.yml +0 -25
- data/.github/workflows/rspec-mysql.yml +0 -34
- data/.github/workflows/rspec-pg.yml +0 -38
- data/.github/workflows/rubocop.yml +0 -23
- data/.gitignore +0 -11
- data/.rspec +0 -2
- data/.rubocop.yml +0 -209
- data/.rubocop_todo.yml +0 -7
- data/Gemfile +0 -24
- data/Gemfile.lock +0 -136
- data/Rakefile +0 -6
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/friendly_fk.gemspec +0 -36
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '09aca0896f3735ca8ca9c63ae8cbe9e8810f323940d5f6c990db1748a6d4a007'
|
|
4
|
+
data.tar.gz: 52ebfdf81e8ec61f58f36674789dd9d8210084f31cc5603f35901a3c3c87d982
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 705fb269b4c283655878f0f07f0b3f3617ced688c2c3f2bd58f8d3db47468ef6af9e2f44ff1bc06692fa61ce791908f66d0d245714cc8f754cb94a3481999bdb
|
|
7
|
+
data.tar.gz: e4783545f4fc3a3f1fb515187714d3e590db31c1bafdd01fe965351e4ebaee8c18e84eaba9d382579be8b2cb4dfdb8c52a101da30efc761be48fac269bc1e410
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [1.1.0] - 2026-06-04
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Support for ActiveRecord 6.1 through 8.1 (`>= 6.1, < 8.2`).
|
|
12
|
+
- Support for Ruby `>= 2.7`.
|
|
13
|
+
- CI runs the suite across a Ruby × ActiveRecord matrix — Ruby 2.7/3.1 against
|
|
14
|
+
AR 6.1/7.1 and Ruby 3.2–3.4 against the latest AR — on both PostgreSQL and
|
|
15
|
+
MySQL, so the supported range is actually exercised.
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
- Generated foreign key names now fold in the referencing column:
|
|
19
|
+
`fk_<from>__<to>__<column>` (composite columns joined with `_and_`), instead of
|
|
20
|
+
`fk_<from>__<to>`. This keeps names unique when several foreign keys connect the
|
|
21
|
+
same pair of tables — the previous scheme generated identical names and could
|
|
22
|
+
collide.
|
|
23
|
+
- When a generated name would exceed the database's identifier limit, the column
|
|
24
|
+
part is replaced with a short deterministic hash (`fk_<from>__<to>__<hash>`); if
|
|
25
|
+
even the table-pair prefix is too long, the whole name falls back to
|
|
26
|
+
`fk_friendly_<hash>`.
|
|
27
|
+
- The published gem now includes `CHANGELOG.md` (alongside `lib/`, `README.md`, and `LICENSE`).
|
|
28
|
+
|
|
29
|
+
### Fixed
|
|
30
|
+
- `add_foreign_key` without an explicit `column:` no longer raises
|
|
31
|
+
`ArgumentError` on ActiveRecord 8.x. Column resolution is delegated to
|
|
32
|
+
ActiveRecord via `super`, which also restores composite primary key support and
|
|
33
|
+
arity validation.
|
|
34
|
+
- The patch now requires `active_record` itself and is applied via `prepend`,
|
|
35
|
+
removing a load-order dependency.
|
|
36
|
+
|
|
37
|
+
### Upgrading
|
|
38
|
+
- Foreign key constraints already created in your database are unaffected. New
|
|
39
|
+
migrations generate the column-folded names.
|
|
40
|
+
- `remove_foreign_key` by table or by `column:` is unaffected. Only if you remove
|
|
41
|
+
a foreign key by its explicit `name:` do you need to update the name to the new
|
|
42
|
+
scheme (or keep passing an explicit `name:` when you create it).
|
|
43
|
+
|
|
44
|
+
[1.1.0]: https://github.com/marinazzio/friendly_fk/releases/tag/v1.1.0
|
data/LICENSE
CHANGED
data/README.md
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
# FriendlyFk
|
|
5
5
|
|
|
6
|
-
Uses child and parent table names to give
|
|
6
|
+
Uses child and parent table names plus the referencing column to give every foreign key a readable name by default — e.g. `fk_child_table__parent_table__parent_id`. Folding the column in keeps names unique even when several foreign keys connect the same table pair.
|
|
7
|
+
|
|
8
|
+
If the generated name would exceed the database's identifier limit, the column part is replaced with a short deterministic hash (`fk_child_table__parent_table__<hash>`). If even the table-pair prefix is too long for the limit, the whole name falls back to `fk_friendly_<hash>`.
|
|
7
9
|
|
|
8
10
|
## Installation
|
|
9
11
|
|
|
@@ -17,6 +19,36 @@ And then execute:
|
|
|
17
19
|
|
|
18
20
|
$ bundle
|
|
19
21
|
|
|
22
|
+
## Requirements
|
|
23
|
+
|
|
24
|
+
- Ruby >= 2.7
|
|
25
|
+
- ActiveRecord >= 6.1, < 8.2
|
|
26
|
+
|
|
20
27
|
## Usage
|
|
21
28
|
|
|
22
|
-
Just use conventional
|
|
29
|
+
Just use the conventional `add_foreign_key` call in your migrations — FriendlyFk
|
|
30
|
+
fills in the name automatically:
|
|
31
|
+
|
|
32
|
+
```ruby
|
|
33
|
+
add_foreign_key :comments, :posts
|
|
34
|
+
# constraint name: fk_comments__posts__post_id
|
|
35
|
+
|
|
36
|
+
add_foreign_key :comments, :users, column: :author_id
|
|
37
|
+
# constraint name: fk_comments__users__author_id
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Because the column is part of the name, multiple foreign keys between the same
|
|
41
|
+
pair of tables get distinct names instead of colliding:
|
|
42
|
+
|
|
43
|
+
```ruby
|
|
44
|
+
add_foreign_key :messages, :users, column: :sender_id
|
|
45
|
+
# constraint name: fk_messages__users__sender_id
|
|
46
|
+
add_foreign_key :messages, :users, column: :recipient_id
|
|
47
|
+
# constraint name: fk_messages__users__recipient_id
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Pass an explicit `name:` to opt out of the generated name entirely:
|
|
51
|
+
|
|
52
|
+
```ruby
|
|
53
|
+
add_foreign_key :comments, :posts, name: 'my_custom_fk'
|
|
54
|
+
```
|
data/lib/friendly_fk/version.rb
CHANGED
data/lib/friendly_fk.rb
CHANGED
|
@@ -1,23 +1,38 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'openssl'
|
|
4
|
+
require 'active_record'
|
|
3
5
|
require 'friendly_fk/version'
|
|
4
6
|
|
|
5
|
-
module
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
module FriendlyFk
|
|
8
|
+
# Overrides the default foreign key name with a readable one built from the
|
|
9
|
+
# parent and child table names plus the referencing column(s), while
|
|
10
|
+
# delegating column resolution (including composite primary keys) to
|
|
11
|
+
# ActiveRecord. Folding the column in keeps names unique when several foreign
|
|
12
|
+
# keys connect the same table pair. Prepended so +super+ keeps working across
|
|
13
|
+
# ActiveRecord versions.
|
|
14
|
+
module SchemaStatements
|
|
15
|
+
def foreign_key_options(from_table, to_table, options) # :nodoc:
|
|
16
|
+
name_given = options.key?(:name)
|
|
17
|
+
options = super
|
|
18
|
+
options[:name] = friendly_fk_name(from_table, to_table, options[:column]) unless name_given
|
|
19
|
+
options
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
private
|
|
15
23
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
24
|
+
def friendly_fk_name(from_table, to_table, column)
|
|
25
|
+
column_part = Array(column).join('_and_')
|
|
26
|
+
name = "fk_#{from_table}__#{to_table}__#{column_part}"
|
|
27
|
+
return name if name.length <= max_identifier_length
|
|
28
|
+
|
|
29
|
+
# Too long for the adapter's identifier limit: keep a friendly prefix and
|
|
30
|
+
# disambiguate with a deterministic hash of the same parts.
|
|
31
|
+
digest = OpenSSL::Digest::SHA256.hexdigest("#{from_table}/#{to_table}/#{column_part}").first(10)
|
|
32
|
+
candidate = "fk_#{from_table}__#{to_table}__#{digest}"
|
|
33
|
+
candidate.length <= max_identifier_length ? candidate : "fk_friendly_#{digest}"
|
|
21
34
|
end
|
|
22
35
|
end
|
|
23
36
|
end
|
|
37
|
+
|
|
38
|
+
ActiveRecord::ConnectionAdapters::SchemaStatements.prepend(FriendlyFk::SchemaStatements)
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: friendly_fk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Denis Kiselyov
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: activerecord
|
|
@@ -16,14 +15,20 @@ dependencies:
|
|
|
16
15
|
requirements:
|
|
17
16
|
- - ">="
|
|
18
17
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
18
|
+
version: '6.1'
|
|
19
|
+
- - "<"
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '8.2'
|
|
20
22
|
type: :runtime
|
|
21
23
|
prerelease: false
|
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
25
|
requirements:
|
|
24
26
|
- - ">="
|
|
25
27
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '
|
|
28
|
+
version: '6.1'
|
|
29
|
+
- - "<"
|
|
30
|
+
- !ruby/object:Gem::Version
|
|
31
|
+
version: '8.2'
|
|
27
32
|
description: Uses parent and child table names to create FK with neat ids
|
|
28
33
|
email:
|
|
29
34
|
- denis.kiselyov@gmail.com
|
|
@@ -31,37 +36,22 @@ executables: []
|
|
|
31
36
|
extensions: []
|
|
32
37
|
extra_rdoc_files: []
|
|
33
38
|
files:
|
|
34
|
-
-
|
|
35
|
-
- ".github/workflows/bundle-audit.yml"
|
|
36
|
-
- ".github/workflows/publish.yml"
|
|
37
|
-
- ".github/workflows/rspec-mysql.yml"
|
|
38
|
-
- ".github/workflows/rspec-pg.yml"
|
|
39
|
-
- ".github/workflows/rubocop.yml"
|
|
40
|
-
- ".gitignore"
|
|
41
|
-
- ".rspec"
|
|
42
|
-
- ".rubocop.yml"
|
|
43
|
-
- ".rubocop_todo.yml"
|
|
44
|
-
- Gemfile
|
|
45
|
-
- Gemfile.lock
|
|
39
|
+
- CHANGELOG.md
|
|
46
40
|
- LICENSE
|
|
47
41
|
- README.md
|
|
48
|
-
- Rakefile
|
|
49
|
-
- bin/console
|
|
50
|
-
- bin/setup
|
|
51
|
-
- friendly_fk.gemspec
|
|
52
42
|
- lib/friendly_fk.rb
|
|
53
43
|
- lib/friendly_fk/version.rb
|
|
54
44
|
homepage: https://github.com/marinazzio/friendly_fk
|
|
55
45
|
licenses:
|
|
56
46
|
- MIT
|
|
57
47
|
metadata:
|
|
48
|
+
allowed_push_host: https://rubygems.org
|
|
58
49
|
bug_tracker_uri: https://github.com/marinazzio/friendly_fk/issues
|
|
50
|
+
changelog_uri: https://github.com/marinazzio/friendly_fk/blob/master/CHANGELOG.md
|
|
59
51
|
documentation_uri: https://github.com/marinazzio/friendly_fk/blob/master/README.md
|
|
60
52
|
homepage_uri: https://github.com/marinazzio/friendly_fk
|
|
61
53
|
source_code_uri: https://github.com/marinazzio/friendly_fk
|
|
62
54
|
rubygems_mfa_required: 'true'
|
|
63
|
-
allowed_push_host: https://rubygems.org
|
|
64
|
-
post_install_message:
|
|
65
55
|
rdoc_options: []
|
|
66
56
|
require_paths:
|
|
67
57
|
- lib
|
|
@@ -69,15 +59,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
69
59
|
requirements:
|
|
70
60
|
- - ">="
|
|
71
61
|
- !ruby/object:Gem::Version
|
|
72
|
-
version: 2.
|
|
62
|
+
version: 2.7.0
|
|
73
63
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
74
64
|
requirements:
|
|
75
65
|
- - ">="
|
|
76
66
|
- !ruby/object:Gem::Version
|
|
77
67
|
version: '0'
|
|
78
68
|
requirements: []
|
|
79
|
-
rubygems_version:
|
|
80
|
-
signing_key:
|
|
69
|
+
rubygems_version: 4.0.10
|
|
81
70
|
specification_version: 4
|
|
82
71
|
summary: Creates foreign keys with friendly names
|
|
83
72
|
test_files: []
|
data/.github/dependabot.yml
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
# To get started with Dependabot version updates, you'll need to specify which
|
|
2
|
-
# package ecosystems to update and where the package manifests are located.
|
|
3
|
-
# Please see the documentation for all configuration options:
|
|
4
|
-
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
|
|
5
|
-
|
|
6
|
-
version: 2
|
|
7
|
-
updates:
|
|
8
|
-
- package-ecosystem: "bundler" # See documentation for possible values
|
|
9
|
-
directory: "/" # Location of package manifests
|
|
10
|
-
schedule:
|
|
11
|
-
interval: "weekly"
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
name: BundleAudit
|
|
2
|
-
on: push
|
|
3
|
-
|
|
4
|
-
jobs:
|
|
5
|
-
bundle_audit:
|
|
6
|
-
name: bundle_audit
|
|
7
|
-
runs-on: ubuntu-latest
|
|
8
|
-
|
|
9
|
-
steps:
|
|
10
|
-
- name: Checkout
|
|
11
|
-
uses: actions/checkout@v2
|
|
12
|
-
with:
|
|
13
|
-
fetch-depth: 0
|
|
14
|
-
|
|
15
|
-
- name: Set up Ruby
|
|
16
|
-
uses: ruby/setup-ruby@v1
|
|
17
|
-
with:
|
|
18
|
-
ruby-version: '3.3.4'
|
|
19
|
-
bundler-cache: true
|
|
20
|
-
|
|
21
|
-
- name: Bundle audit
|
|
22
|
-
run: bundle exec bundle-audit check
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
name: Build and Publish Gem
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
release:
|
|
5
|
-
types: [published]
|
|
6
|
-
|
|
7
|
-
jobs:
|
|
8
|
-
build:
|
|
9
|
-
runs-on: ubuntu-latest
|
|
10
|
-
|
|
11
|
-
permissions:
|
|
12
|
-
contents: write
|
|
13
|
-
id-token: write
|
|
14
|
-
|
|
15
|
-
steps:
|
|
16
|
-
# Set up
|
|
17
|
-
- uses: actions/checkout@v4
|
|
18
|
-
- name: Set up Ruby
|
|
19
|
-
uses: ruby/setup-ruby@v1
|
|
20
|
-
with:
|
|
21
|
-
bundler-cache: true
|
|
22
|
-
ruby-version: ruby
|
|
23
|
-
|
|
24
|
-
# Release
|
|
25
|
-
- uses: rubygems/release-gem@v1
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
name: RSpec on MySQL
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push: {}
|
|
5
|
-
|
|
6
|
-
jobs:
|
|
7
|
-
rspec:
|
|
8
|
-
runs-on: ubuntu-latest
|
|
9
|
-
strategy:
|
|
10
|
-
matrix:
|
|
11
|
-
ruby-version: ['3.1', '3.2', '3.3']
|
|
12
|
-
|
|
13
|
-
env:
|
|
14
|
-
TEST_DATABASE_URL: mysql2://root:root@localhost:3306/friendly_fk_test
|
|
15
|
-
DB: mysql
|
|
16
|
-
RAILS_ENV: test
|
|
17
|
-
|
|
18
|
-
steps:
|
|
19
|
-
- run: |
|
|
20
|
-
sudo /etc/init.d/mysql start
|
|
21
|
-
mysql -e 'CREATE DATABASE friendly_fk_test;' -uroot -proot
|
|
22
|
-
mysql -e 'SHOW DATABASES;' -uroot -proot
|
|
23
|
-
|
|
24
|
-
- name: Checkout
|
|
25
|
-
uses: actions/checkout@v2
|
|
26
|
-
|
|
27
|
-
- name: Setup Ruby
|
|
28
|
-
uses: ruby/setup-ruby@v1
|
|
29
|
-
with:
|
|
30
|
-
ruby-version: ${{ matrix.ruby-version }}
|
|
31
|
-
bundler-cache: true
|
|
32
|
-
|
|
33
|
-
- name: Run RSpec
|
|
34
|
-
run: bundle exec rspec spec
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
name: RSpec on Postgres
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push: {}
|
|
5
|
-
|
|
6
|
-
jobs:
|
|
7
|
-
rspec:
|
|
8
|
-
runs-on: ubuntu-latest
|
|
9
|
-
strategy:
|
|
10
|
-
matrix:
|
|
11
|
-
ruby-version: ['3.1', '3.2', '3.3']
|
|
12
|
-
|
|
13
|
-
env:
|
|
14
|
-
TEST_DATABASE_URL: postgres://test_user:test_user@localhost:5432/friendly_fk_test
|
|
15
|
-
RAILS_ENV: test
|
|
16
|
-
|
|
17
|
-
services:
|
|
18
|
-
database:
|
|
19
|
-
image: postgres:12-alpine
|
|
20
|
-
env:
|
|
21
|
-
POSTGRES_DB: friendly_fk_test
|
|
22
|
-
POSTGRES_USER: test_user
|
|
23
|
-
POSTGRES_PASSWORD: test_user
|
|
24
|
-
ports:
|
|
25
|
-
- 5432:5432
|
|
26
|
-
|
|
27
|
-
steps:
|
|
28
|
-
- name: Checkout
|
|
29
|
-
uses: actions/checkout@v2
|
|
30
|
-
|
|
31
|
-
- name: Setup Ruby
|
|
32
|
-
uses: ruby/setup-ruby@v1
|
|
33
|
-
with:
|
|
34
|
-
ruby-version: ${{ matrix.ruby-version }}
|
|
35
|
-
bundler-cache: true
|
|
36
|
-
|
|
37
|
-
- name: Run RSpec
|
|
38
|
-
run: bundle exec rspec spec
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
name: Rubocop
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push: {}
|
|
5
|
-
|
|
6
|
-
jobs:
|
|
7
|
-
rubocop:
|
|
8
|
-
runs-on: ubuntu-latest
|
|
9
|
-
strategy:
|
|
10
|
-
matrix:
|
|
11
|
-
ruby-version: ['3.1', '3.2', '3.3']
|
|
12
|
-
steps:
|
|
13
|
-
- name: Checkout
|
|
14
|
-
uses: actions/checkout@v2
|
|
15
|
-
|
|
16
|
-
- name: Setup Ruby
|
|
17
|
-
uses: ruby/setup-ruby@v1
|
|
18
|
-
with:
|
|
19
|
-
ruby-version: ${{ matrix.ruby-version }}
|
|
20
|
-
bundler-cache: true
|
|
21
|
-
|
|
22
|
-
- name: Run rubocop
|
|
23
|
-
run: bundle exec rubocop
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.rubocop.yml
DELETED
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
# softened a bit with http://relaxed.ruby.style/rubocop.yml
|
|
2
|
-
|
|
3
|
-
require:
|
|
4
|
-
- rubocop-rake
|
|
5
|
-
- rubocop-rspec
|
|
6
|
-
|
|
7
|
-
inherit_from: .rubocop_todo.yml
|
|
8
|
-
|
|
9
|
-
AllCops:
|
|
10
|
-
TargetRubyVersion: 2.6
|
|
11
|
-
# Cop names are not d§splayed in offense messages by default. Change behavior
|
|
12
|
-
# by overriding DisplayCopNames, or by giving the -D/--display-cop-names
|
|
13
|
-
# option.
|
|
14
|
-
DisplayCopNames: true
|
|
15
|
-
# Style guide URLs are not displayed in offense messages by default. Change
|
|
16
|
-
# behavior by overriding DisplayStyleGuide, or by giving the
|
|
17
|
-
# -S/--display-style-guide option.
|
|
18
|
-
DisplayStyleGuide: false
|
|
19
|
-
|
|
20
|
-
NewCops: enable
|
|
21
|
-
|
|
22
|
-
# Layout ######################################################################
|
|
23
|
-
Layout/LineLength:
|
|
24
|
-
Max: 120
|
|
25
|
-
|
|
26
|
-
# Checks that the closing brace in an array literal is either on the same line
|
|
27
|
-
# as the last array element, or a new line.
|
|
28
|
-
Layout/MultilineArrayBraceLayout:
|
|
29
|
-
Enabled: true
|
|
30
|
-
EnforcedStyle: symmetrical
|
|
31
|
-
|
|
32
|
-
# Checks that the closing brace in a hash literal is either on the same line as
|
|
33
|
-
# the last hash element, or a new line.
|
|
34
|
-
Layout/MultilineHashBraceLayout:
|
|
35
|
-
Enabled: true
|
|
36
|
-
EnforcedStyle: symmetrical
|
|
37
|
-
|
|
38
|
-
# Checks that the closing brace in a method call is either on the same line as
|
|
39
|
-
# the last method argument, or a new line.
|
|
40
|
-
Layout/MultilineMethodCallBraceLayout:
|
|
41
|
-
Enabled: true
|
|
42
|
-
EnforcedStyle: symmetrical
|
|
43
|
-
|
|
44
|
-
# Checks indentation of binary operations that span more than one line.
|
|
45
|
-
Layout/MultilineOperationIndentation:
|
|
46
|
-
Enabled: true
|
|
47
|
-
EnforcedStyle: indented
|
|
48
|
-
|
|
49
|
-
# Checks for padding/surrounding spaces inside string interpolation.
|
|
50
|
-
Layout/SpaceInsideStringInterpolation:
|
|
51
|
-
EnforcedStyle: no_space
|
|
52
|
-
Enabled: true
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
# Naming ######################################################################
|
|
56
|
-
# Check the naming of accessor methods for get_/set_.
|
|
57
|
-
Naming/AccessorMethodName:
|
|
58
|
-
Enabled: false
|
|
59
|
-
|
|
60
|
-
# Use the configured style when naming variables.
|
|
61
|
-
Naming/VariableName:
|
|
62
|
-
EnforcedStyle: snake_case
|
|
63
|
-
Enabled: true
|
|
64
|
-
|
|
65
|
-
# Use the configured style when numbering variables.
|
|
66
|
-
Naming/VariableNumber:
|
|
67
|
-
Enabled: false
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
# Style #######################################################################
|
|
71
|
-
# Use alias_method instead of alias.
|
|
72
|
-
Style/Alias:
|
|
73
|
-
EnforcedStyle: prefer_alias_method
|
|
74
|
-
Enabled: true
|
|
75
|
-
|
|
76
|
-
Style/AsciiComments:
|
|
77
|
-
Enabled: false
|
|
78
|
-
StyleGuide: http://relaxed.ruby.style/#styleasciicomments
|
|
79
|
-
|
|
80
|
-
# This cop checks that comment annotation keywords are written according
|
|
81
|
-
# to guidelines.
|
|
82
|
-
Style/CommentAnnotation:
|
|
83
|
-
Enabled: false
|
|
84
|
-
|
|
85
|
-
# Document classes and non-namespace modules.
|
|
86
|
-
Style/Documentation:
|
|
87
|
-
Enabled: false
|
|
88
|
-
|
|
89
|
-
# Checks if there is a magic comment to enforce string literals
|
|
90
|
-
Style/FrozenStringLiteralComment:
|
|
91
|
-
Enabled: false
|
|
92
|
-
|
|
93
|
-
Style/RegexpLiteral:
|
|
94
|
-
EnforcedStyle: mixed
|
|
95
|
-
Enabled: false
|
|
96
|
-
|
|
97
|
-
# Checks for proper usage of fail and raise.
|
|
98
|
-
Style/SignalException:
|
|
99
|
-
EnforcedStyle: only_raise
|
|
100
|
-
Enabled: true
|
|
101
|
-
|
|
102
|
-
# Check for the usage of parentheses around stabby lambda arguments.
|
|
103
|
-
Style/StabbyLambdaParentheses:
|
|
104
|
-
EnforcedStyle: require_parentheses
|
|
105
|
-
Enabled: true
|
|
106
|
-
|
|
107
|
-
# Checks if configured preferred methods are used over non-preferred.
|
|
108
|
-
Style/StringMethods:
|
|
109
|
-
PreferredMethods:
|
|
110
|
-
intern: to_sym
|
|
111
|
-
Enabled: true
|
|
112
|
-
|
|
113
|
-
# Checks for %q/%Q when single quotes or double quotes would do.
|
|
114
|
-
Style/RedundantPercentQ:
|
|
115
|
-
Enabled: false
|
|
116
|
-
|
|
117
|
-
# Metrics #####################################################################
|
|
118
|
-
|
|
119
|
-
# A calculated magnitude based on number of assignments,
|
|
120
|
-
# branches, and conditions.
|
|
121
|
-
Metrics/AbcSize:
|
|
122
|
-
Enabled: true
|
|
123
|
-
Max: 60
|
|
124
|
-
|
|
125
|
-
# This cop checks if the length of a block exceeds some maximum value.
|
|
126
|
-
Metrics/BlockLength:
|
|
127
|
-
Enabled: false
|
|
128
|
-
|
|
129
|
-
# Avoid excessive block nesting.
|
|
130
|
-
Metrics/BlockNesting:
|
|
131
|
-
Enabled: true
|
|
132
|
-
Max: 4
|
|
133
|
-
|
|
134
|
-
# Avoid classes longer than 100 lines of code.
|
|
135
|
-
Metrics/ClassLength:
|
|
136
|
-
Enabled: false
|
|
137
|
-
|
|
138
|
-
# A complexity metric that is strongly correlated to the number
|
|
139
|
-
# of test cases needed to validate a method.
|
|
140
|
-
Metrics/CyclomaticComplexity:
|
|
141
|
-
Enabled: true
|
|
142
|
-
Max: 17
|
|
143
|
-
|
|
144
|
-
# Avoid methods longer than 10 lines of code.
|
|
145
|
-
Metrics/MethodLength:
|
|
146
|
-
Max: 50
|
|
147
|
-
|
|
148
|
-
# Avoid modules longer than 100 lines of code.
|
|
149
|
-
Metrics/ModuleLength:
|
|
150
|
-
Enabled: false
|
|
151
|
-
|
|
152
|
-
# Avoid parameter lists longer than three or four parameters.
|
|
153
|
-
Metrics/ParameterLists:
|
|
154
|
-
Enabled: true
|
|
155
|
-
Max: 8
|
|
156
|
-
|
|
157
|
-
# A complexity metric geared towards measuring complexity for a human reader.
|
|
158
|
-
Metrics/PerceivedComplexity:
|
|
159
|
-
Enabled: true
|
|
160
|
-
Max: 18
|
|
161
|
-
|
|
162
|
-
# Lint ########################################################################
|
|
163
|
-
|
|
164
|
-
# This cop checks for ambiguous regexp literals in the first argument of
|
|
165
|
-
# a method invocation without parentheses.
|
|
166
|
-
Lint/AmbiguousRegexpLiteral:
|
|
167
|
-
Enabled: false
|
|
168
|
-
|
|
169
|
-
# This cop looks for use of the same name as outer local variables
|
|
170
|
-
# for block arguments or block local variables.
|
|
171
|
-
Lint/ShadowingOuterLocalVariable:
|
|
172
|
-
Enabled: false
|
|
173
|
-
|
|
174
|
-
# RSpec #######################################################################
|
|
175
|
-
|
|
176
|
-
# Checks for long example.
|
|
177
|
-
RSpec/ExampleLength:
|
|
178
|
-
Enabled: false
|
|
179
|
-
Max: 10
|
|
180
|
-
|
|
181
|
-
# Do not use should when describing your tests.
|
|
182
|
-
RSpec/ExampleWording:
|
|
183
|
-
Enabled: false
|
|
184
|
-
CustomTransform:
|
|
185
|
-
be: is
|
|
186
|
-
have: has
|
|
187
|
-
not: does not
|
|
188
|
-
IgnoredWords: []
|
|
189
|
-
|
|
190
|
-
RSpec/ImplicitExpect:
|
|
191
|
-
EnforcedStyle: should
|
|
192
|
-
Enabled: true
|
|
193
|
-
|
|
194
|
-
# Checks for the usage of instance variables.
|
|
195
|
-
RSpec/InstanceVariable:
|
|
196
|
-
Enabled: false
|
|
197
|
-
|
|
198
|
-
# Checks for `subject` definitions that come after `let` definitions.
|
|
199
|
-
RSpec/LeadingSubject:
|
|
200
|
-
Enabled: false
|
|
201
|
-
|
|
202
|
-
# Checks for explicitly referenced test subjects.
|
|
203
|
-
RSpec/NamedSubject:
|
|
204
|
-
Enabled: false
|
|
205
|
-
|
|
206
|
-
# Enforces the usage of the same method on all negative message expectations.
|
|
207
|
-
RSpec/NotToNot:
|
|
208
|
-
EnforcedStyle: not_to
|
|
209
|
-
Enabled: true
|
data/.rubocop_todo.yml
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
# This configuration was generated by
|
|
2
|
-
# `rubocop --auto-gen-config`
|
|
3
|
-
# on 2017-04-13 10:43:50 +0300 using RuboCop version 0.48.1.
|
|
4
|
-
# The point is for the user to remove these configuration records
|
|
5
|
-
# one by one as the offenses are removed from the code base.
|
|
6
|
-
# Note that changes in the inspected code, or installation of new
|
|
7
|
-
# versions of RuboCop, may require this file to be generated again.
|
data/Gemfile
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
source 'https://rubygems.org'
|
|
2
|
-
|
|
3
|
-
# Specify your gem's dependencies in friendly_fk.gemspec
|
|
4
|
-
gemspec
|
|
5
|
-
|
|
6
|
-
group :development, :test do
|
|
7
|
-
gem 'bundler'
|
|
8
|
-
gem 'fuubar'
|
|
9
|
-
gem 'rake'
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
group :test do
|
|
13
|
-
gem 'bundler-audit', require: false
|
|
14
|
-
gem 'mysql2', require: false
|
|
15
|
-
gem 'pg', require: false
|
|
16
|
-
gem 'rspec', require: false
|
|
17
|
-
gem 'rubocop', require: false
|
|
18
|
-
gem 'rubocop-performance', require: false
|
|
19
|
-
gem 'rubocop-rails', require: false
|
|
20
|
-
gem 'rubocop-rake', require: false
|
|
21
|
-
gem 'rubocop-rspec', require: false
|
|
22
|
-
gem 'simplecov', require: false
|
|
23
|
-
gem 'simplecov-rcov', require: false
|
|
24
|
-
end
|
data/Gemfile.lock
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
PATH
|
|
2
|
-
remote: .
|
|
3
|
-
specs:
|
|
4
|
-
friendly_fk (1.0.27)
|
|
5
|
-
activerecord
|
|
6
|
-
|
|
7
|
-
GEM
|
|
8
|
-
remote: https://rubygems.org/
|
|
9
|
-
specs:
|
|
10
|
-
activemodel (7.2.1)
|
|
11
|
-
activesupport (= 7.2.1)
|
|
12
|
-
activerecord (7.2.1)
|
|
13
|
-
activemodel (= 7.2.1)
|
|
14
|
-
activesupport (= 7.2.1)
|
|
15
|
-
timeout (>= 0.4.0)
|
|
16
|
-
activesupport (7.2.1)
|
|
17
|
-
base64
|
|
18
|
-
bigdecimal
|
|
19
|
-
concurrent-ruby (~> 1.0, >= 1.3.1)
|
|
20
|
-
connection_pool (>= 2.2.5)
|
|
21
|
-
drb
|
|
22
|
-
i18n (>= 1.6, < 2)
|
|
23
|
-
logger (>= 1.4.2)
|
|
24
|
-
minitest (>= 5.1)
|
|
25
|
-
securerandom (>= 0.3)
|
|
26
|
-
tzinfo (~> 2.0, >= 2.0.5)
|
|
27
|
-
ast (2.4.2)
|
|
28
|
-
base64 (0.2.0)
|
|
29
|
-
bigdecimal (3.1.8)
|
|
30
|
-
bundler-audit (0.9.2)
|
|
31
|
-
bundler (>= 1.2.0, < 3)
|
|
32
|
-
thor (~> 1.0)
|
|
33
|
-
concurrent-ruby (1.3.4)
|
|
34
|
-
connection_pool (2.4.1)
|
|
35
|
-
diff-lcs (1.5.1)
|
|
36
|
-
docile (1.4.1)
|
|
37
|
-
drb (2.2.1)
|
|
38
|
-
fuubar (2.5.1)
|
|
39
|
-
rspec-core (~> 3.0)
|
|
40
|
-
ruby-progressbar (~> 1.4)
|
|
41
|
-
i18n (1.14.5)
|
|
42
|
-
concurrent-ruby (~> 1.0)
|
|
43
|
-
json (2.7.2)
|
|
44
|
-
language_server-protocol (3.17.0.3)
|
|
45
|
-
logger (1.6.0)
|
|
46
|
-
minitest (5.25.1)
|
|
47
|
-
mysql2 (0.5.6)
|
|
48
|
-
parallel (1.26.3)
|
|
49
|
-
parser (3.3.4.2)
|
|
50
|
-
ast (~> 2.4.1)
|
|
51
|
-
racc
|
|
52
|
-
pg (1.5.7)
|
|
53
|
-
racc (1.8.1)
|
|
54
|
-
rack (3.1.7)
|
|
55
|
-
rainbow (3.1.1)
|
|
56
|
-
rake (13.2.1)
|
|
57
|
-
regexp_parser (2.9.2)
|
|
58
|
-
rexml (3.3.6)
|
|
59
|
-
strscan
|
|
60
|
-
rspec (3.13.0)
|
|
61
|
-
rspec-core (~> 3.13.0)
|
|
62
|
-
rspec-expectations (~> 3.13.0)
|
|
63
|
-
rspec-mocks (~> 3.13.0)
|
|
64
|
-
rspec-core (3.13.0)
|
|
65
|
-
rspec-support (~> 3.13.0)
|
|
66
|
-
rspec-expectations (3.13.2)
|
|
67
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
|
68
|
-
rspec-support (~> 3.13.0)
|
|
69
|
-
rspec-mocks (3.13.1)
|
|
70
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
|
71
|
-
rspec-support (~> 3.13.0)
|
|
72
|
-
rspec-support (3.13.1)
|
|
73
|
-
rubocop (1.65.1)
|
|
74
|
-
json (~> 2.3)
|
|
75
|
-
language_server-protocol (>= 3.17.0)
|
|
76
|
-
parallel (~> 1.10)
|
|
77
|
-
parser (>= 3.3.0.2)
|
|
78
|
-
rainbow (>= 2.2.2, < 4.0)
|
|
79
|
-
regexp_parser (>= 2.4, < 3.0)
|
|
80
|
-
rexml (>= 3.2.5, < 4.0)
|
|
81
|
-
rubocop-ast (>= 1.31.1, < 2.0)
|
|
82
|
-
ruby-progressbar (~> 1.7)
|
|
83
|
-
unicode-display_width (>= 2.4.0, < 3.0)
|
|
84
|
-
rubocop-ast (1.32.1)
|
|
85
|
-
parser (>= 3.3.1.0)
|
|
86
|
-
rubocop-performance (1.21.1)
|
|
87
|
-
rubocop (>= 1.48.1, < 2.0)
|
|
88
|
-
rubocop-ast (>= 1.31.1, < 2.0)
|
|
89
|
-
rubocop-rails (2.26.0)
|
|
90
|
-
activesupport (>= 4.2.0)
|
|
91
|
-
rack (>= 1.1)
|
|
92
|
-
rubocop (>= 1.52.0, < 2.0)
|
|
93
|
-
rubocop-ast (>= 1.31.1, < 2.0)
|
|
94
|
-
rubocop-rake (0.6.0)
|
|
95
|
-
rubocop (~> 1.0)
|
|
96
|
-
rubocop-rspec (3.0.4)
|
|
97
|
-
rubocop (~> 1.61)
|
|
98
|
-
ruby-progressbar (1.13.0)
|
|
99
|
-
securerandom (0.3.1)
|
|
100
|
-
simplecov (0.22.0)
|
|
101
|
-
docile (~> 1.1)
|
|
102
|
-
simplecov-html (~> 0.11)
|
|
103
|
-
simplecov_json_formatter (~> 0.1)
|
|
104
|
-
simplecov-html (0.12.3)
|
|
105
|
-
simplecov-rcov (0.3.7)
|
|
106
|
-
simplecov (>= 0.4.1)
|
|
107
|
-
simplecov_json_formatter (0.1.4)
|
|
108
|
-
strscan (3.1.0)
|
|
109
|
-
thor (1.3.1)
|
|
110
|
-
timeout (0.4.1)
|
|
111
|
-
tzinfo (2.0.6)
|
|
112
|
-
concurrent-ruby (~> 1.0)
|
|
113
|
-
unicode-display_width (2.5.0)
|
|
114
|
-
|
|
115
|
-
PLATFORMS
|
|
116
|
-
x86_64-linux
|
|
117
|
-
|
|
118
|
-
DEPENDENCIES
|
|
119
|
-
bundler
|
|
120
|
-
bundler-audit
|
|
121
|
-
friendly_fk!
|
|
122
|
-
fuubar
|
|
123
|
-
mysql2
|
|
124
|
-
pg
|
|
125
|
-
rake
|
|
126
|
-
rspec
|
|
127
|
-
rubocop
|
|
128
|
-
rubocop-performance
|
|
129
|
-
rubocop-rails
|
|
130
|
-
rubocop-rake
|
|
131
|
-
rubocop-rspec
|
|
132
|
-
simplecov
|
|
133
|
-
simplecov-rcov
|
|
134
|
-
|
|
135
|
-
BUNDLED WITH
|
|
136
|
-
2.5.3
|
data/Rakefile
DELETED
data/bin/console
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
|
|
3
|
-
require 'bundler/setup'
|
|
4
|
-
require 'friendly_fk'
|
|
5
|
-
|
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
-
|
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
-
# require "pry"
|
|
11
|
-
# Pry.start
|
|
12
|
-
|
|
13
|
-
require 'irb'
|
|
14
|
-
IRB.start(__FILE__)
|
data/bin/setup
DELETED
data/friendly_fk.gemspec
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
lib = File.expand_path('lib', __dir__)
|
|
2
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
|
-
require 'friendly_fk/version'
|
|
4
|
-
|
|
5
|
-
Gem::Specification.new do |spec|
|
|
6
|
-
spec.name = 'friendly_fk'
|
|
7
|
-
spec.version = FriendlyFk::VERSION
|
|
8
|
-
spec.authors = ['Denis Kiselyov']
|
|
9
|
-
spec.email = ['denis.kiselyov@gmail.com']
|
|
10
|
-
spec.license = 'MIT'
|
|
11
|
-
spec.summary = 'Creates foreign keys with friendly names'
|
|
12
|
-
spec.description = 'Uses parent and child table names to create FK with neat ids'
|
|
13
|
-
spec.homepage = 'https://github.com/marinazzio/friendly_fk'
|
|
14
|
-
|
|
15
|
-
spec.metadata = {
|
|
16
|
-
'bug_tracker_uri' => 'https://github.com/marinazzio/friendly_fk/issues',
|
|
17
|
-
'documentation_uri' => 'https://github.com/marinazzio/friendly_fk/blob/master/README.md',
|
|
18
|
-
'homepage_uri' => 'https://github.com/marinazzio/friendly_fk',
|
|
19
|
-
'source_code_uri' => 'https://github.com/marinazzio/friendly_fk',
|
|
20
|
-
'rubygems_mfa_required' => 'true'
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
spec.required_ruby_version = '>= 2.6.0'
|
|
24
|
-
|
|
25
|
-
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
|
26
|
-
|
|
27
|
-
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
28
|
-
f.match(%r{^(test|spec|features)/})
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
spec.bindir = 'exe'
|
|
32
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
33
|
-
spec.require_paths = ['lib']
|
|
34
|
-
|
|
35
|
-
spec.add_dependency 'activerecord'
|
|
36
|
-
end
|