subroutine 2.3.1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0a85a75ee28c2c27b1d144059b1af01681aee27987ca2fdad9a0736b2270c824
4
- data.tar.gz: 73bf392120764aa30da22c18b756ea8483f35b34e14e473fae6f7d495a4cbc9f
3
+ metadata.gz: 1d089cc45475bdb88ee182f34ef6cbfc2fcb4c77d039fce887fd3bd420a2f210
4
+ data.tar.gz: 454b7650e82cccfe16af31d8bb7ca5739763cacdcd1cab4ef810a25634dab480
5
5
  SHA512:
6
- metadata.gz: ea38c80c4bbf80eb1763f1052b5f0a906268b1eb6416bcd6e4f2f39a678af16395555ddc02b56867671413076680fb65343d7462974e594f112e8cdb2136f52b
7
- data.tar.gz: b5590640ea893a227ef850fb052fb04cac6d46ccc0af2cb33b7b86972518c1b5b7988114fab0faa6472b215f8f927825c9699a08266fd6713ed8c84a88846065
6
+ metadata.gz: 43420206b0becfd866a4ec01aa757d20c780bb939ed666c94878c8c73645561672646b230850aa199652776204f50562c0b675b37973d6efcb9ce831fc3b4d9c
7
+ data.tar.gz: dc313998225594aac7480cbf9df3e5b539589c13ef041adccb39ef97c583f0608d8a5b7b7e55245d58816b98db159a8d4fedd42d39f6b72317add6670a3ac7cc
@@ -0,0 +1 @@
1
+ .github/workflows @guideline-tech/engineering
@@ -0,0 +1,24 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "github-actions"
4
+ directory: "/"
5
+ open-pull-requests-limit: 20
6
+ schedule:
7
+ interval: "daily"
8
+ time: "09:00"
9
+ timezone: "America/New_York"
10
+ commit-message:
11
+ prefix: "[github-actions] "
12
+ - package-ecosystem: "bundler"
13
+ directory: "/"
14
+ schedule:
15
+ interval: "daily"
16
+ time: "08:30"
17
+ timezone: "America/New_York"
18
+ versioning-strategy: increase
19
+ open-pull-requests-limit: 20
20
+ insecure-external-code-execution: deny
21
+ allow:
22
+ - dependency-type: "all"
23
+ commit-message:
24
+ prefix: "[bundler] "
@@ -7,7 +7,7 @@ jobs:
7
7
  strategy:
8
8
  fail-fast: false
9
9
  matrix:
10
- ruby-version: [2.7.5, 2.7.6]
10
+ ruby-version: [2.7.8]
11
11
  experimental: [false]
12
12
  include:
13
13
  - ruby-version: 3.0
@@ -15,7 +15,7 @@ jobs:
15
15
  - ruby-version: 3.1
16
16
  experimental: true
17
17
  steps:
18
- - uses: actions/checkout@v2
18
+ - uses: actions/checkout@v3
19
19
  - uses: ruby/setup-ruby@v1
20
20
  with:
21
21
  ruby-version: ${{ matrix.ruby-version }}
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.7.5
1
+ 2.7.8
data/CHANGELOG.MD CHANGED
@@ -1,3 +1,7 @@
1
+ ## Subroutine 3.0
2
+
3
+ Add support for Rails 6.1. Drop support for Rails 6.0 and lower.
4
+
1
5
  ## Subroutine 2.2
2
6
 
3
7
  Add `type` validation for Output.
data/Gemfile CHANGED
@@ -5,4 +5,4 @@ source "https://rubygems.org"
5
5
  # Specify your gem's dependencies in subroutine.gemspec
6
6
  gemspec
7
7
 
8
- eval_gemfile "gemfiles/am60.gemfile"
8
+ eval_gemfile "gemfiles/am61.gemfile"
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'activemodel', '~> 6.1.0'
4
+ gem 'actionpack', '~> 6.1.0'
data/lib/subroutine/op.rb CHANGED
@@ -112,9 +112,10 @@ module Subroutine
112
112
  end
113
113
 
114
114
  def inherit_errors(error_object, prefix: nil)
115
- error_object = error_object.errors if error_object.respond_to?(:errors)
115
+ error_object = error_object.errors if error_object.respond_to?(:errors) && !error_object.is_a?(ActiveModel::Errors)
116
116
 
117
- error_object.each do |field_name, error|
117
+ error_object.each do |error|
118
+ field_name = error.attribute
118
119
  field_name = "#{prefix}#{field_name}" if prefix
119
120
  field_name = field_name.to_sym
120
121
 
@@ -125,9 +126,9 @@ module Subroutine
125
126
  end
126
127
 
127
128
  if field_config
128
- errors.add(field_config.field_name, error)
129
+ errors.add(field_config.field_name, error.message)
129
130
  else
130
- errors.add(:base, error_object.full_message(field_name, error))
131
+ errors.add(:base, error_object.full_message(field_name, error.message))
131
132
  end
132
133
  end
133
134
 
@@ -65,9 +65,11 @@ end
65
65
 
66
66
  ::Subroutine::TypeCaster.register :foreign_key do |value, options = {}|
67
67
  next nil if value.blank?
68
-
69
- next ::Subroutine::TypeCaster.cast(value, type: options[:foreign_key_type].call) if options[:foreign_key_type].respond_to?(:call)
70
- next ::Subroutine::TypeCaster.cast(value, type: options[:foreign_key_type]) if options[:foreign_key_type]
68
+
69
+ calculated_type = options[:foreign_key_type].respond_to?(:call)
70
+ calculated_value = calculated_type ? options[:foreign_key_type].call : options[:foreign_key_type]
71
+
72
+ next ::Subroutine::TypeCaster.cast(value, type: calculated_value) if calculated_value
71
73
  next ::Subroutine::TypeCaster.cast(value, type: :integer) if options[:name] && options[:name].to_s.end_with?("_id")
72
74
 
73
75
  value
@@ -2,9 +2,9 @@
2
2
 
3
3
  module Subroutine
4
4
 
5
- MAJOR = 2
6
- MINOR = 3
7
- PATCH = 1
5
+ MAJOR = 3
6
+ MINOR = 0
7
+ PATCH = 0
8
8
  PRE = nil
9
9
 
10
10
  VERSION = [MAJOR, MINOR, PATCH, PRE].compact.join(".")
data/subroutine.gemspec CHANGED
@@ -19,10 +19,10 @@ Gem::Specification.new do |spec|
19
19
  spec.test_files = spec.files.grep(%r{^(gemfiles|test)/})
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.add_dependency "activemodel", ">= 4.0.0"
23
- spec.add_dependency "activesupport", ">= 4.0.0"
22
+ spec.add_dependency "activemodel", ">= 6.1"
23
+ spec.add_dependency "activesupport", ">= 6.1"
24
24
 
25
- spec.add_development_dependency "actionpack", ">= 4.0"
25
+ spec.add_development_dependency "actionpack", ">= 6.1"
26
26
  spec.add_development_dependency "bundler"
27
27
  spec.add_development_dependency "byebug"
28
28
  spec.add_development_dependency "m"
@@ -231,6 +231,11 @@ module Subroutine
231
231
  assert_equal true, op.field_provided?(:admin_id)
232
232
  assert_equal true, op.field_provided?(:admin_type)
233
233
 
234
+ op = PolymorphicAssociationOp.new admin_type: doug.class.name, admin_id: doug.id.to_s
235
+ assert_equal true, op.field_provided?(:admin)
236
+ assert_equal true, op.field_provided?(:admin_id)
237
+ assert_equal true, op.field_provided?(:admin_type)
238
+
234
239
  op = PolymorphicAssociationOp.new admin_id: doug.id
235
240
  assert_equal false, op.field_provided?(:admin)
236
241
  assert_equal true, op.field_provided?(:admin_id)
@@ -293,6 +298,18 @@ module Subroutine
293
298
  assert_equal({ "admin_id" => 1, "admin_type" => "User" }, op.params)
294
299
  end
295
300
 
301
+ def test_params_id_type_as_integer_for_polymorphic_associations
302
+ user = ::User.new(id: 1)
303
+
304
+ op = PolymorphicAssociationOp.new(admin_id: user.id)
305
+ op.admin
306
+ assert_equal({ "admin_id" => 1 }, op.params)
307
+
308
+ op = PolymorphicAssociationOp.new(admin_id: user.id.to_s)
309
+ op.admin
310
+ assert_equal({ "admin_id" => 1 }, op.params)
311
+ end
312
+
296
313
  def test_params_can_be_accessed_with_associations_loaded
297
314
  user = User.new(id: 1)
298
315
  op = SimpleAssociationOp.new(user: user)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: subroutine
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Nelson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-15 00:00:00.000000000 Z
11
+ date: 2023-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -16,42 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 4.0.0
19
+ version: '6.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 4.0.0
26
+ version: '6.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 4.0.0
33
+ version: '6.1'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 4.0.0
40
+ version: '6.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: actionpack
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '4.0'
47
+ version: '6.1'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '4.0'
54
+ version: '6.1'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -157,6 +157,8 @@ executables: []
157
157
  extensions: []
158
158
  extra_rdoc_files: []
159
159
  files:
160
+ - ".github/CODEOWNERS"
161
+ - ".github/dependabot.yml"
160
162
  - ".github/workflows/build.yml"
161
163
  - ".gitignore"
162
164
  - ".ruby-gemset"
@@ -166,12 +168,7 @@ files:
166
168
  - LICENSE.txt
167
169
  - README.md
168
170
  - Rakefile
169
- - gemfiles/am41.gemfile
170
- - gemfiles/am42.gemfile
171
- - gemfiles/am50.gemfile
172
- - gemfiles/am51.gemfile
173
- - gemfiles/am52.gemfile
174
- - gemfiles/am60.gemfile
171
+ - gemfiles/am61.gemfile
175
172
  - lib/subroutine.rb
176
173
  - lib/subroutine/association_fields.rb
177
174
  - lib/subroutine/association_fields/association_type_mismatch_error.rb
@@ -220,17 +217,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
220
217
  - !ruby/object:Gem::Version
221
218
  version: '0'
222
219
  requirements: []
223
- rubygems_version: 3.3.23
220
+ rubygems_version: 3.4.10
224
221
  signing_key:
225
222
  specification_version: 4
226
223
  summary: Feature-driven operation objects.
227
224
  test_files:
228
- - gemfiles/am41.gemfile
229
- - gemfiles/am42.gemfile
230
- - gemfiles/am50.gemfile
231
- - gemfiles/am51.gemfile
232
- - gemfiles/am52.gemfile
233
- - gemfiles/am60.gemfile
225
+ - gemfiles/am61.gemfile
234
226
  - test/subroutine/association_test.rb
235
227
  - test/subroutine/auth_test.rb
236
228
  - test/subroutine/base_test.rb
@@ -1,7 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec :path => '../'
4
-
5
- gem 'rack'
6
- gem 'activemodel', '~> 4.1.0'
7
- gem 'actionpack', '~> 4.1.0'
@@ -1,7 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec :path => '../'
4
-
5
- gem 'rack'
6
- gem 'activemodel', '~> 4.2.0'
7
- gem 'actionpack', '~> 4.2.0'
@@ -1,6 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec :path => '../'
4
-
5
- gem 'activemodel', '~> 5.0.0'
6
- gem 'actionpack', '~> 5.0.0'
@@ -1,6 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec :path => '../'
4
-
5
- gem 'activemodel', '~> 5.1.0'
6
- gem 'actionpack', '~> 5.1.0'
@@ -1,6 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec :path => '../'
4
-
5
- gem 'activemodel', '~> 5.2.0'
6
- gem 'actionpack', '~> 5.2.0'
@@ -1,6 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec :path => '../'
4
-
5
- gem 'activemodel', '~> 6.0.0'
6
- gem 'actionpack', '~> 6.0.0'