belongs_to_one_of 0.3.0 → 1.0.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/.github/dependabot.yml +5 -5
- data/.github/workflows/tests.yml +32 -0
- data/.rubocop.yml +1 -8
- data/.ruby-version +1 -1
- data/CHANGELOG.md +5 -0
- data/Gemfile +11 -0
- data/README.md +41 -30
- data/belongs_to_one_of.gemspec +4 -12
- data/docs/COMPATABILITY.md +2 -6
- data/lib/belongs_to_one_of/belongs_to_one_of_model.rb +5 -5
- data/lib/belongs_to_one_of/version.rb +1 -1
- data/lib/belongs_to_one_of.rb +6 -6
- metadata +15 -103
- data/.circleci/config.yml +0 -57
- data/.rubocop_todo.yml +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbd36b371bf0f376c5c9a5b4c112f200eda2a5c47e9da5e2aa35c6a02c973233
|
4
|
+
data.tar.gz: c5ea5abc93e38741455991599720be1d08b0d3a8df986a2757cc9260c883411d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 599c6afe2cc5998c6d934c0048daf2cf7f74162a834a62e5b6a9cdb22deb870e86b32b43c43ebb0b6288ed37a5e07b2a108b8973ee5620da93c42841d02588ad
|
7
|
+
data.tar.gz: 8c55f5eae719ccc790dcd35b9f7b8ec08724ea71ddb64252105fec1e41ca0a13cf7192df79a383966b45544ad1ba23255ab56cdff65fbe7df384a4cf9d86ed08
|
data/.github/dependabot.yml
CHANGED
@@ -0,0 +1,32 @@
|
|
1
|
+
name: tests
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- "master"
|
7
|
+
pull_request:
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
tests:
|
11
|
+
strategy:
|
12
|
+
fail-fast: false
|
13
|
+
matrix:
|
14
|
+
ruby-version: ["3.1", "3.2", "3.3", "3.4"]
|
15
|
+
rails-version: ["7.0", "7.1", "7.2", "8.0"]
|
16
|
+
exclude:
|
17
|
+
- ruby-version: "3.1"
|
18
|
+
rails-version: "8.0"
|
19
|
+
runs-on: ubuntu-latest
|
20
|
+
env:
|
21
|
+
RAILS_VERSION: ${{ matrix.rails-version }}
|
22
|
+
steps:
|
23
|
+
- uses: actions/checkout@v3
|
24
|
+
- name: Set up Ruby
|
25
|
+
uses: ruby/setup-ruby@v1
|
26
|
+
with:
|
27
|
+
bundler-cache: true
|
28
|
+
ruby-version: "${{ matrix.ruby-version }}"
|
29
|
+
- name: Run tests
|
30
|
+
run: bundle exec rspec
|
31
|
+
- name: Run rubocop
|
32
|
+
run: bundle exec rubocop --parallel --extra-details --display-style-guide
|
data/.rubocop.yml
CHANGED
@@ -1,16 +1,9 @@
|
|
1
|
-
inherit_from: .rubocop_todo.yml
|
2
|
-
|
3
1
|
inherit_gem:
|
4
2
|
gc_ruboconfig: rubocop.yml
|
5
3
|
|
6
4
|
AllCops:
|
7
5
|
TargetRubyVersion: 3.1
|
8
|
-
|
9
|
-
Style/CaseLikeIf:
|
10
|
-
Enabled: false
|
6
|
+
NewCops: enable
|
11
7
|
|
12
8
|
Gemspec/RequiredRubyVersion:
|
13
9
|
Enabled: false
|
14
|
-
|
15
|
-
Style/HashSyntax:
|
16
|
-
Enabled: false
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.1
|
1
|
+
3.4.1
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
@@ -5,3 +5,14 @@ source "https://rubygems.org"
|
|
5
5
|
gemspec
|
6
6
|
|
7
7
|
gem "activerecord", "~> #{ENV['RAILS_VERSION']}" if ENV["RAILS_VERSION"]
|
8
|
+
|
9
|
+
group :test, :development do
|
10
|
+
gem "bundler"
|
11
|
+
gem "gc_ruboconfig", "~> 5"
|
12
|
+
gem "pry-byebug"
|
13
|
+
gem "rspec", "~> 3.9"
|
14
|
+
gem "rspec_junit_formatter", "~> 0.4"
|
15
|
+
|
16
|
+
# For integration testing
|
17
|
+
gem "sqlite3", "~> 2"
|
18
|
+
end
|
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# belongs_to_one_of
|
2
|
+
|
2
3
|
Gem to support activemodel relations where one model can be a child of one of many models.
|
3
4
|
In our examples, we will be targeting a class `Competitor` which can either belong to a `School` or a `College`.
|
4
5
|
We will consider this more general concept an `organisation`.
|
@@ -8,22 +9,23 @@ and some helper functions to safely set and get the associated model.
|
|
8
9
|
|
9
10
|
## What about rails polymorphic relations?
|
10
11
|
|
11
|
-
Unlike rails polymorphic relations, this supports having a separate `id` column for each parent
|
12
|
+
Unlike rails polymorphic relations, this supports having a separate `id` column for each parent
|
12
13
|
model type (e.g. `school_id` and `college_id` instead of just `organisation_id`). This is desirable
|
13
14
|
(in some cases) to enable the database to use foreign keys.
|
14
15
|
|
15
16
|
The gem will also error if you try to set a resource which isn't one of the specified classes, unlike
|
16
17
|
a rails polymorphic relation which will accept any model class.
|
17
18
|
|
18
|
-
|
19
19
|
## Installation
|
20
20
|
|
21
21
|
Install the package from Rubygems:
|
22
|
+
|
22
23
|
```shell script
|
23
24
|
gem install belongs_to_one_of
|
24
25
|
```
|
25
26
|
|
26
27
|
Or add it to your gemfile
|
28
|
+
|
27
29
|
```
|
28
30
|
gem 'belongs_to_one_of'
|
29
31
|
```
|
@@ -37,7 +39,7 @@ Our code will say:
|
|
37
39
|
> This model belongs to an organisation, which might be a School or might be a College
|
38
40
|
|
39
41
|
This allows us to store the association in the columns `school_id` and `college_id`, which can use foreign keys,
|
40
|
-
but for the 99% of your code which doesn't care which is which, they can just call a method `organisation` or
|
42
|
+
but for the 99% of your code which doesn't care which is which, they can just call a method `organisation` or
|
41
43
|
`organisation_id` to access the resource.
|
42
44
|
|
43
45
|
The library adds a new association to `ActiveRecord` called `belongs_to_one_of :organisation, `. To use it, simply call this
|
@@ -50,11 +52,11 @@ end
|
|
50
52
|
|
51
53
|
class School < ActiveRecord::Base
|
52
54
|
has_many :competitors
|
53
|
-
end
|
55
|
+
end
|
54
56
|
|
55
57
|
class College < ActiveRecord::Base
|
56
58
|
has_many :competitors
|
57
|
-
end
|
59
|
+
end
|
58
60
|
|
59
61
|
school = School.new
|
60
62
|
|
@@ -64,7 +66,7 @@ my_competitor.organisation
|
|
64
66
|
# => school
|
65
67
|
|
66
68
|
my_competitor.organisation_id == school.id
|
67
|
-
# => true
|
69
|
+
# => true
|
68
70
|
```
|
69
71
|
|
70
72
|
Note that this helper calls `belongs_to :school, optional:true` and `belongs_to :college, optional:true`, so you don't have to.
|
@@ -77,18 +79,22 @@ The hook defines a few methods on your class. The names are dynamic, we will use
|
|
77
79
|
### Validators
|
78
80
|
|
79
81
|
#### `belongs_to_exactly_one_[organisation]`
|
82
|
+
|
80
83
|
A validator that can be used to check that a model belongs to exactly one organisation
|
81
84
|
|
82
85
|
#### `belongs_to_at_most_one_[organisation]`
|
86
|
+
|
83
87
|
A validator that can be used to check that a model belongs to either no organisations or one organisation
|
84
88
|
|
85
89
|
#### `[organisation_type]_matches_[organisation]`
|
86
|
-
|
90
|
+
|
91
|
+
A validator that can be used to check that the type of model matches the model. Only relevant when
|
87
92
|
`include_type_column` is true
|
88
93
|
|
89
94
|
### Getters & Setters
|
90
95
|
|
91
96
|
#### `[organisation]=`
|
97
|
+
|
92
98
|
Allows you to create a new instance of the model with the interface:
|
93
99
|
|
94
100
|
```ruby
|
@@ -101,23 +107,30 @@ Competitor.new(
|
|
101
107
|
This will raise a `ModelNotFound` exception if the organisation is not one of the permitted model types
|
102
108
|
|
103
109
|
#### `[organisation]`
|
110
|
+
|
104
111
|
Allows you to get the linked resource via `.organisation` e.g.:
|
112
|
+
|
105
113
|
```ruby
|
106
114
|
my_competitor.organisation
|
107
115
|
```
|
116
|
+
|
108
117
|
#### `[organisation]_id`
|
118
|
+
|
109
119
|
Allows you to get the linked resource's id via `.organisation_id` e.g.:
|
120
|
+
|
110
121
|
```ruby
|
111
122
|
my_competitor.organisation_id
|
112
|
-
```
|
123
|
+
```
|
113
124
|
|
114
125
|
#### `[organisation]_type`
|
126
|
+
|
115
127
|
This is only set when the associations are configured with `include_type_column` (see below). This allows you to access the resource type via
|
116
128
|
`.organisation_type` e.g.:
|
129
|
+
|
117
130
|
```ruby
|
118
131
|
my_competitor.organisation_type
|
119
132
|
# => 'School'
|
120
|
-
```
|
133
|
+
```
|
121
134
|
|
122
135
|
## Configuration Options
|
123
136
|
|
@@ -125,10 +138,10 @@ my_competitor.organisation_type
|
|
125
138
|
|
126
139
|
By default, the library assumes that the underlying table looks like:
|
127
140
|
|
128
|
-
`id` | `name`
|
129
|
-
|
130
|
-
1
|
131
|
-
2
|
141
|
+
| `id` | `name` | `school_id` | `college_id` |
|
142
|
+
| ---- | ---------------- | ----------- | ------------ |
|
143
|
+
| 1 | Aaron J Aaronson | | COL123 |
|
144
|
+
| 2 | Betty F Parker | SCH456 |
|
132
145
|
|
133
146
|
however you can set `include_type_column: true` to explicitly store what type of model is connected, e.g.:
|
134
147
|
|
@@ -136,10 +149,10 @@ however you can set `include_type_column: true` to explicitly store what type of
|
|
136
149
|
belongs_to_one_of :organisation, %i[school college], include_type_column: true
|
137
150
|
```
|
138
151
|
|
139
|
-
`id` | `name`
|
140
|
-
|
141
|
-
1
|
142
|
-
2
|
152
|
+
| `id` | `name` | `organisation_type` | `school_id` | `college_id` |
|
153
|
+
| ---- | ---------------- | ------------------- | ----------- | ------------ |
|
154
|
+
| 1 | Aaron J Aaronson | College | | COL123 |
|
155
|
+
| 2 | Betty F Parker | School | SCH456 |
|
143
156
|
|
144
157
|
if the column is not called `[organisation]_type`, you can specify the column name e.g.
|
145
158
|
|
@@ -147,16 +160,15 @@ if the column is not called `[organisation]_type`, you can specify the column na
|
|
147
160
|
belongs_to_one_of :organisation, %i[school college], include_type_column: :type_of_organisation
|
148
161
|
```
|
149
162
|
|
150
|
-
`id` | `name`
|
151
|
-
|
152
|
-
1
|
153
|
-
2
|
154
|
-
|
163
|
+
| `id` | `name` | `type_of_organisation` | `school_id` | `college_id` |
|
164
|
+
| ---- | ---------------- | ---------------------- | ----------- | ------------ |
|
165
|
+
| 1 | Aaron J Aaronson | College | | COL123 |
|
166
|
+
| 2 | Betty F Parker | School | SCH456 |
|
155
167
|
|
156
168
|
### `type_column_value`
|
157
169
|
|
158
170
|
If you have `include_type_column: true` set, by default we assume you want to store the classname in the db.
|
159
|
-
However, there may be some logic that you want to apply. If you pass a Proc to `type_column_value`
|
171
|
+
However, there may be some logic that you want to apply. If you pass a Proc to `type_column_value`
|
160
172
|
you can add your own logic to determine what goes into the db.
|
161
173
|
|
162
174
|
```ruby
|
@@ -164,15 +176,14 @@ you can add your own logic to determine what goes into the db.
|
|
164
176
|
type_column_value: ->(resource) { resource.class.downcase }
|
165
177
|
```
|
166
178
|
|
167
|
-
`id` | `name`
|
168
|
-
|
169
|
-
1
|
170
|
-
2
|
171
|
-
|
179
|
+
| `id` | `name` | `organisation_type` | `school_id` | `college_id` |
|
180
|
+
| ---- | ---------------- | ------------------- | ----------- | ------------ |
|
181
|
+
| 1 | Aaron J Aaronson | college | | COL123 |
|
182
|
+
| 2 | Betty F Parker | school | SCH456 |
|
172
183
|
|
173
184
|
## License & Contributing
|
174
185
|
|
175
|
-
|
176
|
-
|
186
|
+
- BelongsToOneOf is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
187
|
+
- Bug reports and pull requests are welcome on GitHub at https://github.com/gocardless/belongs-to-one-of.
|
177
188
|
|
178
189
|
GoCardless ♥ open source. If you do too, come [join us](https://gocardless.com/about/careers/).
|
data/belongs_to_one_of.gemspec
CHANGED
@@ -23,17 +23,9 @@ Gem::Specification.new do |spec|
|
|
23
23
|
end
|
24
24
|
spec.require_paths = ["lib"]
|
25
25
|
|
26
|
-
spec.required_ruby_version = ">=
|
26
|
+
spec.required_ruby_version = ">= 3.1"
|
27
27
|
|
28
|
-
spec.
|
29
|
-
spec.
|
30
|
-
spec.
|
31
|
-
spec.add_development_dependency "rspec", "~> 3.9"
|
32
|
-
spec.add_development_dependency "rspec_junit_formatter", "~> 0.4"
|
33
|
-
|
34
|
-
# For integration testing
|
35
|
-
spec.add_development_dependency "sqlite3", "~> 1.4.1"
|
36
|
-
|
37
|
-
spec.add_dependency "activerecord", ">= 5.2", "< 8"
|
38
|
-
spec.add_dependency "activesupport", ">= 5.2", "< 8"
|
28
|
+
spec.add_dependency "activerecord", ">= 7.0", "< 9"
|
29
|
+
spec.add_dependency "activesupport", ">= 7.0", "< 9"
|
30
|
+
spec.metadata["rubygems_mfa_required"] = "true"
|
39
31
|
end
|
data/docs/COMPATABILITY.md
CHANGED
@@ -1,13 +1,9 @@
|
|
1
1
|
# Compatibility
|
2
2
|
|
3
3
|
Our goal as maintainers is for the library to be compatible with all supported
|
4
|
-
versions of Ruby.
|
4
|
+
versions of CRuby/MRI Ruby listed [here](https://endoflife.date/ruby).
|
5
5
|
|
6
|
-
|
7
|
-
([e.g. this notice for Ruby 2.1](https://www.ruby-lang.org/en/news/2017/04/01/support-of-ruby-2-1-has-ended/))
|
8
|
-
is supported.
|
9
|
-
|
10
|
-
To that end, [our build matrix](../.circleci/config.yml) includes all these versions.
|
6
|
+
To that end, [our build matrix](../.github/tests.yml) includes all these versions.
|
11
7
|
|
12
8
|
Any time BelongsToOneOf doesn't work on a supported version of Ruby, it's a bug, and can be
|
13
9
|
reported [here](https://github.com/gocardless/belongs-to-one-of/issues).
|
@@ -55,15 +55,15 @@ module BelongsToOneOf
|
|
55
55
|
return if resource.nil?
|
56
56
|
|
57
57
|
possible_resource_types.each_key do |resource_type|
|
58
|
-
model.public_send("#{resource_type}=", nil)
|
58
|
+
model.public_send(:"#{resource_type}=", nil)
|
59
59
|
end
|
60
60
|
|
61
|
-
model.instance_variable_set("@#{resource_key}", resource)
|
61
|
+
model.instance_variable_set(:"@#{resource_key}", resource)
|
62
62
|
resource_type_accessor = find_resource_accessor(resource, model)
|
63
63
|
|
64
64
|
unless resource_type_accessor
|
65
|
-
message = "one of #{possible_resource_types.keys.join(', ')} expected, "\
|
66
|
-
"got #{resource.inspect} which is an instance of "\
|
65
|
+
message = "one of #{possible_resource_types.keys.join(', ')} expected, " \
|
66
|
+
"got #{resource.inspect} which is an instance of " \
|
67
67
|
"#{resource.class}(##{resource.class.object_id})"
|
68
68
|
raise ActiveRecord::AssociationTypeMismatch, message
|
69
69
|
end
|
@@ -132,7 +132,7 @@ module BelongsToOneOf
|
|
132
132
|
raise InvalidParamsException, "expected a symbol, received #{classname}"
|
133
133
|
end
|
134
134
|
|
135
|
-
hash[classname] = "#{classname.to_s.underscore}_id"
|
135
|
+
hash[classname] = :"#{classname.to_s.underscore}_id"
|
136
136
|
end
|
137
137
|
elsif raw_possible_resource_types.is_a?(Hash)
|
138
138
|
raw_possible_resource_types
|
data/lib/belongs_to_one_of.rb
CHANGED
@@ -32,22 +32,22 @@ module ActiveRecord
|
|
32
32
|
)
|
33
33
|
|
34
34
|
# validators
|
35
|
-
define_method "belongs_to_exactly_one_#{resource_key}" do
|
35
|
+
define_method :"belongs_to_exactly_one_#{resource_key}" do
|
36
36
|
config_model.validate_exactly_one_resource(self)
|
37
37
|
end
|
38
38
|
|
39
|
-
define_method "belongs_to_at_most_one_#{resource_key}" do
|
39
|
+
define_method :"belongs_to_at_most_one_#{resource_key}" do
|
40
40
|
config_model.validate_at_most_one_resource(self)
|
41
41
|
end
|
42
42
|
|
43
43
|
if include_type_column
|
44
|
-
define_method "#{resource_type_field}_matches_#{resource_key}" do
|
44
|
+
define_method :"#{resource_type_field}_matches_#{resource_key}" do
|
45
45
|
config_model.validate_correct_resource_type(self)
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
49
|
# setters
|
50
|
-
define_method "#{resource_key}=" do |resource|
|
50
|
+
define_method :"#{resource_key}=" do |resource|
|
51
51
|
config_model.resource_setter(resource, self)
|
52
52
|
end
|
53
53
|
|
@@ -56,12 +56,12 @@ module ActiveRecord
|
|
56
56
|
config_model.resource_getter(self)
|
57
57
|
end
|
58
58
|
|
59
|
-
define_method "#{resource_key}_id" do
|
59
|
+
define_method :"#{resource_key}_id" do
|
60
60
|
config_model.resource_id_getter(self)
|
61
61
|
end
|
62
62
|
|
63
63
|
unless include_type_column
|
64
|
-
define_method "#{resource_key}_type" do
|
64
|
+
define_method :"#{resource_key}_type" do
|
65
65
|
config_model.resource_type_getter(self)
|
66
66
|
end
|
67
67
|
end
|
metadata
CHANGED
@@ -1,151 +1,64 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: belongs_to_one_of
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GoCardless Engineering
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-01-30 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: bundler
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :development
|
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: gc_ruboconfig
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 2.31.0
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 2.31.0
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: pry-byebug
|
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: rspec
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '3.9'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '3.9'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rspec_junit_formatter
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0.4'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0.4'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: sqlite3
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: 1.4.1
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: 1.4.1
|
97
12
|
- !ruby/object:Gem::Dependency
|
98
13
|
name: activerecord
|
99
14
|
requirement: !ruby/object:Gem::Requirement
|
100
15
|
requirements:
|
101
16
|
- - ">="
|
102
17
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
18
|
+
version: '7.0'
|
104
19
|
- - "<"
|
105
20
|
- !ruby/object:Gem::Version
|
106
|
-
version: '
|
21
|
+
version: '9'
|
107
22
|
type: :runtime
|
108
23
|
prerelease: false
|
109
24
|
version_requirements: !ruby/object:Gem::Requirement
|
110
25
|
requirements:
|
111
26
|
- - ">="
|
112
27
|
- !ruby/object:Gem::Version
|
113
|
-
version: '
|
28
|
+
version: '7.0'
|
114
29
|
- - "<"
|
115
30
|
- !ruby/object:Gem::Version
|
116
|
-
version: '
|
31
|
+
version: '9'
|
117
32
|
- !ruby/object:Gem::Dependency
|
118
33
|
name: activesupport
|
119
34
|
requirement: !ruby/object:Gem::Requirement
|
120
35
|
requirements:
|
121
36
|
- - ">="
|
122
37
|
- !ruby/object:Gem::Version
|
123
|
-
version: '
|
38
|
+
version: '7.0'
|
124
39
|
- - "<"
|
125
40
|
- !ruby/object:Gem::Version
|
126
|
-
version: '
|
41
|
+
version: '9'
|
127
42
|
type: :runtime
|
128
43
|
prerelease: false
|
129
44
|
version_requirements: !ruby/object:Gem::Requirement
|
130
45
|
requirements:
|
131
46
|
- - ">="
|
132
47
|
- !ruby/object:Gem::Version
|
133
|
-
version: '
|
48
|
+
version: '7.0'
|
134
49
|
- - "<"
|
135
50
|
- !ruby/object:Gem::Version
|
136
|
-
version: '
|
137
|
-
description:
|
51
|
+
version: '9'
|
138
52
|
email:
|
139
53
|
- engineering@gocardless.com
|
140
54
|
executables: []
|
141
55
|
extensions: []
|
142
56
|
extra_rdoc_files: []
|
143
57
|
files:
|
144
|
-
- ".circleci/config.yml"
|
145
58
|
- ".github/dependabot.yml"
|
59
|
+
- ".github/workflows/tests.yml"
|
146
60
|
- ".gitignore"
|
147
61
|
- ".rubocop.yml"
|
148
|
-
- ".rubocop_todo.yml"
|
149
62
|
- ".ruby-version"
|
150
63
|
- CHANGELOG.md
|
151
64
|
- Gemfile
|
@@ -159,8 +72,8 @@ files:
|
|
159
72
|
homepage: https://github.com/gocardless/belongs-to-one-of
|
160
73
|
licenses:
|
161
74
|
- MIT
|
162
|
-
metadata:
|
163
|
-
|
75
|
+
metadata:
|
76
|
+
rubygems_mfa_required: 'true'
|
164
77
|
rdoc_options: []
|
165
78
|
require_paths:
|
166
79
|
- lib
|
@@ -168,15 +81,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
168
81
|
requirements:
|
169
82
|
- - ">="
|
170
83
|
- !ruby/object:Gem::Version
|
171
|
-
version: '
|
84
|
+
version: '3.1'
|
172
85
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
173
86
|
requirements:
|
174
87
|
- - ">="
|
175
88
|
- !ruby/object:Gem::Version
|
176
89
|
version: '0'
|
177
90
|
requirements: []
|
178
|
-
rubygems_version: 3.2
|
179
|
-
signing_key:
|
91
|
+
rubygems_version: 3.6.2
|
180
92
|
specification_version: 4
|
181
93
|
summary: A small library that helps with models which can have multiple parent model
|
182
94
|
types
|
data/.circleci/config.yml
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
version: 2.1
|
2
|
-
|
3
|
-
jobs:
|
4
|
-
test:
|
5
|
-
parameters:
|
6
|
-
ruby-version:
|
7
|
-
type: string
|
8
|
-
rails-version:
|
9
|
-
type: string
|
10
|
-
|
11
|
-
docker:
|
12
|
-
- image: cimg/ruby:<<parameters.ruby-version>>
|
13
|
-
environment:
|
14
|
-
- RAILS_VERSION=<<parameters.rails-version>>
|
15
|
-
steps:
|
16
|
-
- checkout
|
17
|
-
|
18
|
-
- run: gem install bundler
|
19
|
-
- run: bundle install
|
20
|
-
|
21
|
-
- run: |
|
22
|
-
bundle exec rspec --profile 10 \
|
23
|
-
--format RspecJunitFormatter \
|
24
|
-
--out /tmp/test-results/rspec.xml \
|
25
|
-
--format progress \
|
26
|
-
spec
|
27
|
-
- store_test_results:
|
28
|
-
path: /tmp/test-results
|
29
|
-
|
30
|
-
rubocop:
|
31
|
-
docker:
|
32
|
-
- image: cimg/ruby:3.1
|
33
|
-
steps:
|
34
|
-
- checkout
|
35
|
-
- run: gem install bundler -v 2.3.4
|
36
|
-
- run: bundle install
|
37
|
-
- run:
|
38
|
-
name: Rubocop
|
39
|
-
command: bundle exec rubocop --parallel --extra-details --display-style-guide
|
40
|
-
|
41
|
-
workflows:
|
42
|
-
version: 2
|
43
|
-
tests:
|
44
|
-
jobs:
|
45
|
-
- test:
|
46
|
-
matrix:
|
47
|
-
parameters:
|
48
|
-
ruby-version: ["2.6", "2.7", "3.0", "3.1"]
|
49
|
-
rails-version: ["5.2", "6.0", "6.1", "7.0"]
|
50
|
-
exclude:
|
51
|
-
- ruby-version: "3.0"
|
52
|
-
rails-version: "5.2"
|
53
|
-
- ruby-version: "3.1"
|
54
|
-
rails-version: "5.2"
|
55
|
-
- ruby-version: "2.6"
|
56
|
-
rails-version: "7.0"
|
57
|
-
- rubocop
|
data/.rubocop_todo.yml
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
# This configuration was generated by
|
2
|
-
# `rubocop --auto-gen-config`
|
3
|
-
# on 2020-04-17 14:28:59 +0100 using RuboCop version 0.80.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.
|
8
|
-
|
9
|
-
# Offense count: 2
|
10
|
-
Metrics/AbcSize:
|
11
|
-
Max: 22
|
12
|
-
|
13
|
-
# Offense count: 3
|
14
|
-
# Configuration parameters: CountComments, ExcludedMethods.
|
15
|
-
Metrics/MethodLength:
|
16
|
-
Max: 37
|