friendly_fk 1.0.13
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 +7 -0
- data/.gitignore +11 -0
- data/.rspec +2 -0
- data/.rubocop.yml +249 -0
- data/.rubocop_todo.yml +7 -0
- data/.travis.yml +24 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +95 -0
- data/LICENSE +21 -0
- data/README.md +19 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/friendly_fk.gemspec +41 -0
- data/lib/friendly_fk/version.rb +3 -0
- data/lib/friendly_fk.rb +21 -0
- metadata +148 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b1c3ddbcdb3fee465a72db4381fe027f4f5f1523e9cb54f0d34339ddc14d2368
|
4
|
+
data.tar.gz: 56d4fd652b2f9f23cfb5bea8bbfbb647c5a5b62645a52e61b0b6081c498a5180
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 84543754605dff5d522bb375220ba714223a81e9a82d2a230883c7aae617bce332c17ad57923585a37fe3adfae3a34a2d8e7e61f234770752680059b915633c1
|
7
|
+
data.tar.gz: 3702d2f050785320a9ba89cc657c9675e4b952500ae179982cbedc784a207b4fd0d6b721caf5d774c2cfc5f1461b54d216410a6ce59253e8a4a2873b9c9bbe33
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,249 @@
|
|
1
|
+
# softened a bit with http://relaxed.ruby.style/rubocop.yml
|
2
|
+
|
3
|
+
require:
|
4
|
+
- rubocop-rspec
|
5
|
+
|
6
|
+
inherit_from: .rubocop_todo.yml
|
7
|
+
|
8
|
+
AllCops:
|
9
|
+
TargetRubyVersion: 2.3
|
10
|
+
# Cop names are not d§splayed in offense messages by default. Change behavior
|
11
|
+
# by overriding DisplayCopNames, or by giving the -D/--display-cop-names
|
12
|
+
# option.
|
13
|
+
DisplayCopNames: true
|
14
|
+
# Style guide URLs are not displayed in offense messages by default. Change
|
15
|
+
# behavior by overriding DisplayStyleGuide, or by giving the
|
16
|
+
# -S/--display-style-guide option.
|
17
|
+
DisplayStyleGuide: false
|
18
|
+
|
19
|
+
# Gems in consecutive lines should be alphabetically sorted
|
20
|
+
Bundler/OrderedGems:
|
21
|
+
TreatCommentsAsGroupSeparators: true
|
22
|
+
|
23
|
+
Gemspec/OrderedDependencies:
|
24
|
+
Enabled: true
|
25
|
+
|
26
|
+
# Layout ######################################################################
|
27
|
+
# Checks that the closing brace in an array literal is either on the same line
|
28
|
+
# as the last array element, or a new line.
|
29
|
+
Layout/MultilineArrayBraceLayout:
|
30
|
+
Enabled: true
|
31
|
+
EnforcedStyle: symmetrical
|
32
|
+
|
33
|
+
# Checks that the closing brace in a hash literal is either on the same line as
|
34
|
+
# the last hash element, or a new line.
|
35
|
+
Layout/MultilineHashBraceLayout:
|
36
|
+
Enabled: true
|
37
|
+
EnforcedStyle: symmetrical
|
38
|
+
|
39
|
+
# Checks that the closing brace in a method call is either on the same line as
|
40
|
+
# the last method argument, or a new line.
|
41
|
+
Layout/MultilineMethodCallBraceLayout:
|
42
|
+
Enabled: true
|
43
|
+
EnforcedStyle: symmetrical
|
44
|
+
|
45
|
+
# Checks indentation of binary operations that span more than one line.
|
46
|
+
Layout/MultilineOperationIndentation:
|
47
|
+
Enabled: true
|
48
|
+
EnforcedStyle: indented
|
49
|
+
|
50
|
+
# Checks for padding/surrounding spaces inside string interpolation.
|
51
|
+
Layout/SpaceInsideStringInterpolation:
|
52
|
+
EnforcedStyle: no_space
|
53
|
+
Enabled: true
|
54
|
+
|
55
|
+
|
56
|
+
# Naming ######################################################################
|
57
|
+
# Check the naming of accessor methods for get_/set_.
|
58
|
+
Naming/AccessorMethodName:
|
59
|
+
Enabled: false
|
60
|
+
|
61
|
+
# Use the configured style when naming variables.
|
62
|
+
Naming/VariableName:
|
63
|
+
EnforcedStyle: snake_case
|
64
|
+
Enabled: true
|
65
|
+
|
66
|
+
# Use the configured style when numbering variables.
|
67
|
+
Naming/VariableNumber:
|
68
|
+
Enabled: false
|
69
|
+
|
70
|
+
|
71
|
+
# Style #######################################################################
|
72
|
+
# Use alias_method instead of alias.
|
73
|
+
Style/Alias:
|
74
|
+
EnforcedStyle: prefer_alias_method
|
75
|
+
Enabled: true
|
76
|
+
|
77
|
+
Style/AsciiComments:
|
78
|
+
Enabled: false
|
79
|
+
StyleGuide: http://relaxed.ruby.style/#styleasciicomments
|
80
|
+
|
81
|
+
# This cop checks that comment annotation keywords are written according
|
82
|
+
# to guidelines.
|
83
|
+
Style/CommentAnnotation:
|
84
|
+
Enabled: false
|
85
|
+
|
86
|
+
# Document classes and non-namespace modules.
|
87
|
+
Style/Documentation:
|
88
|
+
Enabled: false
|
89
|
+
|
90
|
+
# Checks if there is a magic comment to enforce string literals
|
91
|
+
Style/FrozenStringLiteralComment:
|
92
|
+
Enabled: false
|
93
|
+
|
94
|
+
Style/RegexpLiteral:
|
95
|
+
EnforcedStyle: mixed
|
96
|
+
Enabled: false
|
97
|
+
|
98
|
+
# Checks for proper usage of fail and raise.
|
99
|
+
Style/SignalException:
|
100
|
+
EnforcedStyle: only_raise
|
101
|
+
Enabled: true
|
102
|
+
|
103
|
+
# Check for the usage of parentheses around stabby lambda arguments.
|
104
|
+
Style/StabbyLambdaParentheses:
|
105
|
+
EnforcedStyle: require_parentheses
|
106
|
+
Enabled: true
|
107
|
+
|
108
|
+
# Checks if configured preferred methods are used over non-preferred.
|
109
|
+
Style/StringMethods:
|
110
|
+
PreferredMethods:
|
111
|
+
intern: to_sym
|
112
|
+
Enabled: true
|
113
|
+
|
114
|
+
# Checks for %q/%Q when single quotes or double quotes would do.
|
115
|
+
Style/UnneededPercentQ:
|
116
|
+
Enabled: false
|
117
|
+
|
118
|
+
# Metrics #####################################################################
|
119
|
+
|
120
|
+
# A calculated magnitude based on number of assignments,
|
121
|
+
# branches, and conditions.
|
122
|
+
Metrics/AbcSize:
|
123
|
+
Enabled: true
|
124
|
+
Max: 60
|
125
|
+
|
126
|
+
# This cop checks if the length of a block exceeds some maximum value.
|
127
|
+
Metrics/BlockLength:
|
128
|
+
Enabled: false
|
129
|
+
|
130
|
+
# Avoid excessive block nesting.
|
131
|
+
Metrics/BlockNesting:
|
132
|
+
Enabled: true
|
133
|
+
Max: 4
|
134
|
+
|
135
|
+
# Avoid classes longer than 100 lines of code.
|
136
|
+
Metrics/ClassLength:
|
137
|
+
Enabled: false
|
138
|
+
|
139
|
+
# A complexity metric that is strongly correlated to the number
|
140
|
+
# of test cases needed to validate a method.
|
141
|
+
Metrics/CyclomaticComplexity:
|
142
|
+
Enabled: true
|
143
|
+
Max: 17
|
144
|
+
|
145
|
+
# Limit lines to 80 characters.
|
146
|
+
Metrics/LineLength:
|
147
|
+
Max: 120
|
148
|
+
|
149
|
+
# Avoid methods longer than 10 lines of code.
|
150
|
+
Metrics/MethodLength:
|
151
|
+
Max: 50
|
152
|
+
|
153
|
+
# Avoid modules longer than 100 lines of code.
|
154
|
+
Metrics/ModuleLength:
|
155
|
+
Enabled: false
|
156
|
+
|
157
|
+
# Avoid parameter lists longer than three or four parameters.
|
158
|
+
Metrics/ParameterLists:
|
159
|
+
Enabled: true
|
160
|
+
Max: 8
|
161
|
+
|
162
|
+
# A complexity metric geared towards measuring complexity for a human reader.
|
163
|
+
Metrics/PerceivedComplexity:
|
164
|
+
Enabled: true
|
165
|
+
Max: 18
|
166
|
+
|
167
|
+
# Lint ########################################################################
|
168
|
+
|
169
|
+
# This cop checks for ambiguous regexp literals in the first argument of
|
170
|
+
# a method invocation without parentheses.
|
171
|
+
Lint/AmbiguousRegexpLiteral:
|
172
|
+
Enabled: false
|
173
|
+
|
174
|
+
# This cop looks for use of the same name as outer local variables
|
175
|
+
# for block arguments or block local variables.
|
176
|
+
Lint/ShadowingOuterLocalVariable:
|
177
|
+
Enabled: false
|
178
|
+
|
179
|
+
# Performance #################################################################
|
180
|
+
|
181
|
+
# This cop identifies places where `Hash#merge!` can be replaced by
|
182
|
+
# `Hash#[]=`.
|
183
|
+
Performance/RedundantMerge:
|
184
|
+
Enabled: true
|
185
|
+
MaxKeyValuePairs: 1
|
186
|
+
|
187
|
+
# Rails #######################################################################
|
188
|
+
|
189
|
+
# Enables Rails cops.
|
190
|
+
Rails:
|
191
|
+
Enabled: true
|
192
|
+
|
193
|
+
# Enforces consistent use of action filter methods.
|
194
|
+
Rails/ActionFilter:
|
195
|
+
Enabled: true
|
196
|
+
EnforcedStyle: action
|
197
|
+
|
198
|
+
# Prefer has_many :through to has_and_belongs_to_many.
|
199
|
+
Rails/HasAndBelongsToMany:
|
200
|
+
Enabled: false
|
201
|
+
|
202
|
+
# This cop checks that environments called with Rails.env predicates exist.
|
203
|
+
Rails/UnknownEnv:
|
204
|
+
Enabled: true
|
205
|
+
Environments: development, test, production, stage
|
206
|
+
|
207
|
+
# RSpec #######################################################################
|
208
|
+
|
209
|
+
# Checks for long example.
|
210
|
+
RSpec/ExampleLength:
|
211
|
+
Enabled: false
|
212
|
+
Max: 10
|
213
|
+
|
214
|
+
# Do not use should when describing your tests.
|
215
|
+
RSpec/ExampleWording:
|
216
|
+
Enabled: false
|
217
|
+
CustomTransform:
|
218
|
+
be: is
|
219
|
+
have: has
|
220
|
+
not: does not
|
221
|
+
IgnoredWords: []
|
222
|
+
|
223
|
+
# Checks the file and folder naming of the spec file.
|
224
|
+
RSpec/FilePath:
|
225
|
+
Enabled: true
|
226
|
+
CustomTransform:
|
227
|
+
RuboCop: rubocop
|
228
|
+
RSpec: rspec
|
229
|
+
|
230
|
+
RSpec/ImplicitExpect:
|
231
|
+
EnforcedStyle: should
|
232
|
+
Enabled: true
|
233
|
+
|
234
|
+
# Checks for the usage of instance variables.
|
235
|
+
RSpec/InstanceVariable:
|
236
|
+
Enabled: false
|
237
|
+
|
238
|
+
# Checks for `subject` definitions that come after `let` definitions.
|
239
|
+
RSpec/LeadingSubject:
|
240
|
+
Enabled: false
|
241
|
+
|
242
|
+
# Checks for explicitly referenced test subjects.
|
243
|
+
RSpec/NamedSubject:
|
244
|
+
Enabled: false
|
245
|
+
|
246
|
+
# Enforces the usage of the same method on all negative message expectations.
|
247
|
+
RSpec/NotToNot:
|
248
|
+
EnforcedStyle: not_to
|
249
|
+
Enabled: true
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,7 @@
|
|
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/.travis.yml
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
sudo: false
|
2
|
+
language: ruby
|
3
|
+
rvm:
|
4
|
+
- 2.3.8
|
5
|
+
- 2.4.5
|
6
|
+
- 2.5.3
|
7
|
+
|
8
|
+
services:
|
9
|
+
- mysql
|
10
|
+
- postgresql
|
11
|
+
|
12
|
+
env:
|
13
|
+
- DB=mysql
|
14
|
+
- DB=postgres
|
15
|
+
|
16
|
+
before_script:
|
17
|
+
- sh -c "if [ '$DB' = 'postgres' ]; then psql -c 'DROP DATABASE IF EXISTS friendly_fk_test;' -U postgres; fi"
|
18
|
+
- sh -c "if [ '$DB' = 'postgres' ]; then psql -c 'CREATE DATABASE friendly_fk_test;' -U postgres; fi"
|
19
|
+
- sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'CREATE DATABASE IF NOT EXISTS friendly_fk_test; CREATE DATABASE IF NOT EXISTS friendly_fk_test;'; fi"
|
20
|
+
|
21
|
+
before_install: gem install bundler -v 1.16.6
|
22
|
+
script:
|
23
|
+
- bundle exec rspec spec
|
24
|
+
- bundle exec rubocop
|
data/Gemfile
ADDED
@@ -0,0 +1,15 @@
|
|
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 'fuubar'
|
8
|
+
end
|
9
|
+
|
10
|
+
group :test do
|
11
|
+
gem 'rubocop', require: false
|
12
|
+
gem 'rubocop-rspec', require: false
|
13
|
+
gem 'simplecov', require: false
|
14
|
+
gem 'simplecov-rcov', require: false
|
15
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
friendly_fk (1.0.13)
|
5
|
+
activerecord
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activemodel (5.2.1)
|
11
|
+
activesupport (= 5.2.1)
|
12
|
+
activerecord (5.2.1)
|
13
|
+
activemodel (= 5.2.1)
|
14
|
+
activesupport (= 5.2.1)
|
15
|
+
arel (>= 9.0)
|
16
|
+
activesupport (5.2.1)
|
17
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
18
|
+
i18n (>= 0.7, < 2)
|
19
|
+
minitest (~> 5.1)
|
20
|
+
tzinfo (~> 1.1)
|
21
|
+
arel (9.0.0)
|
22
|
+
ast (2.4.0)
|
23
|
+
concurrent-ruby (1.1.2)
|
24
|
+
diff-lcs (1.3)
|
25
|
+
docile (1.3.1)
|
26
|
+
fuubar (2.3.2)
|
27
|
+
rspec-core (~> 3.0)
|
28
|
+
ruby-progressbar (~> 1.4)
|
29
|
+
i18n (1.1.1)
|
30
|
+
concurrent-ruby (~> 1.0)
|
31
|
+
jaro_winkler (1.5.1)
|
32
|
+
json (2.1.0)
|
33
|
+
minitest (5.11.3)
|
34
|
+
mysql2 (0.5.2)
|
35
|
+
parallel (1.12.1)
|
36
|
+
parser (2.5.3.0)
|
37
|
+
ast (~> 2.4.0)
|
38
|
+
pg (1.1.3)
|
39
|
+
powerpack (0.1.2)
|
40
|
+
rainbow (3.0.0)
|
41
|
+
rake (12.3.1)
|
42
|
+
rspec (3.8.0)
|
43
|
+
rspec-core (~> 3.8.0)
|
44
|
+
rspec-expectations (~> 3.8.0)
|
45
|
+
rspec-mocks (~> 3.8.0)
|
46
|
+
rspec-core (3.8.0)
|
47
|
+
rspec-support (~> 3.8.0)
|
48
|
+
rspec-expectations (3.8.2)
|
49
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
50
|
+
rspec-support (~> 3.8.0)
|
51
|
+
rspec-mocks (3.8.0)
|
52
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
53
|
+
rspec-support (~> 3.8.0)
|
54
|
+
rspec-support (3.8.0)
|
55
|
+
rubocop (0.60.0)
|
56
|
+
jaro_winkler (~> 1.5.1)
|
57
|
+
parallel (~> 1.10)
|
58
|
+
parser (>= 2.5, != 2.5.1.1)
|
59
|
+
powerpack (~> 0.1)
|
60
|
+
rainbow (>= 2.2.2, < 4.0)
|
61
|
+
ruby-progressbar (~> 1.7)
|
62
|
+
unicode-display_width (~> 1.4.0)
|
63
|
+
rubocop-rspec (1.30.1)
|
64
|
+
rubocop (>= 0.60.0)
|
65
|
+
ruby-progressbar (1.10.0)
|
66
|
+
simplecov (0.16.1)
|
67
|
+
docile (~> 1.1)
|
68
|
+
json (>= 1.8, < 3)
|
69
|
+
simplecov-html (~> 0.10.0)
|
70
|
+
simplecov-html (0.10.2)
|
71
|
+
simplecov-rcov (0.2.3)
|
72
|
+
simplecov (>= 0.4.1)
|
73
|
+
thread_safe (0.3.6)
|
74
|
+
tzinfo (1.2.5)
|
75
|
+
thread_safe (~> 0.1)
|
76
|
+
unicode-display_width (1.4.0)
|
77
|
+
|
78
|
+
PLATFORMS
|
79
|
+
ruby
|
80
|
+
|
81
|
+
DEPENDENCIES
|
82
|
+
bundler
|
83
|
+
friendly_fk!
|
84
|
+
fuubar
|
85
|
+
mysql2
|
86
|
+
pg
|
87
|
+
rake
|
88
|
+
rspec
|
89
|
+
rubocop
|
90
|
+
rubocop-rspec
|
91
|
+
simplecov
|
92
|
+
simplecov-rcov
|
93
|
+
|
94
|
+
BUNDLED WITH
|
95
|
+
1.17.1
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2018 Denis Kiselyov
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# FriendlyFk
|
2
|
+
|
3
|
+
Uses child and parent table names to give FK name by default. It doesn't use hash tail, so use it carefully, 'cause it may generate non-unique names.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'friendly_fk'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
Just use conventional call of `add_foreign_key` method.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
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
ADDED
data/friendly_fk.gemspec
ADDED
@@ -0,0 +1,41 @@
|
|
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
|
+
}
|
21
|
+
|
22
|
+
spec.required_ruby_version = '>= 2.3.8'
|
23
|
+
|
24
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
25
|
+
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
27
|
+
f.match(%r{^(test|spec|features)/})
|
28
|
+
end
|
29
|
+
|
30
|
+
spec.bindir = 'exe'
|
31
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
32
|
+
spec.require_paths = ['lib']
|
33
|
+
|
34
|
+
spec.add_dependency 'activerecord'
|
35
|
+
|
36
|
+
spec.add_development_dependency 'bundler'
|
37
|
+
spec.add_development_dependency 'mysql2'
|
38
|
+
spec.add_development_dependency 'pg'
|
39
|
+
spec.add_development_dependency 'rake'
|
40
|
+
spec.add_development_dependency 'rspec'
|
41
|
+
end
|
data/lib/friendly_fk.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'friendly_fk/version'
|
2
|
+
|
3
|
+
module ActiveRecord
|
4
|
+
module ConnectionAdapters # :nodoc:
|
5
|
+
module SchemaStatements
|
6
|
+
def foreign_key_options(from_table, to_table, options) # :nodoc:
|
7
|
+
options = options.dup
|
8
|
+
options[:to_table] = to_table
|
9
|
+
options[:column] ||= foreign_key_column_for(to_table)
|
10
|
+
options[:name] ||= foreign_key_name(from_table, options)
|
11
|
+
options
|
12
|
+
end
|
13
|
+
|
14
|
+
def foreign_key_name(from_table, options)
|
15
|
+
options.fetch(:name) do
|
16
|
+
"fk_#{from_table}__#{options[:to_table]}"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,148 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: friendly_fk
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.13
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Denis Kiselyov
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-11-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activerecord
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: mysql2
|
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: pg
|
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: rake
|
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
|
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
|
+
description: Uses parent and child table names to create FK with neat ids
|
98
|
+
email:
|
99
|
+
- denis.kiselyov@gmail.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".rspec"
|
106
|
+
- ".rubocop.yml"
|
107
|
+
- ".rubocop_todo.yml"
|
108
|
+
- ".travis.yml"
|
109
|
+
- Gemfile
|
110
|
+
- Gemfile.lock
|
111
|
+
- LICENSE
|
112
|
+
- README.md
|
113
|
+
- Rakefile
|
114
|
+
- bin/console
|
115
|
+
- bin/setup
|
116
|
+
- friendly_fk.gemspec
|
117
|
+
- lib/friendly_fk.rb
|
118
|
+
- lib/friendly_fk/version.rb
|
119
|
+
homepage: https://github.com/marinazzio/friendly_fk
|
120
|
+
licenses:
|
121
|
+
- MIT
|
122
|
+
metadata:
|
123
|
+
bug_tracker_uri: https://github.com/marinazzio/friendly_fk/issues
|
124
|
+
documentation_uri: https://github.com/marinazzio/friendly_fk/blob/master/README.md
|
125
|
+
homepage_uri: https://github.com/marinazzio/friendly_fk
|
126
|
+
source_code_uri: https://github.com/marinazzio/friendly_fk
|
127
|
+
allowed_push_host: https://rubygems.org
|
128
|
+
post_install_message:
|
129
|
+
rdoc_options: []
|
130
|
+
require_paths:
|
131
|
+
- lib
|
132
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: 2.3.8
|
137
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - ">="
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
requirements: []
|
143
|
+
rubyforge_project:
|
144
|
+
rubygems_version: 2.7.6
|
145
|
+
signing_key:
|
146
|
+
specification_version: 4
|
147
|
+
summary: Creates foreign keys with friendly names
|
148
|
+
test_files: []
|