active_record-associated_object 0.3.0 → 0.4.1

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: 9b5e7079fe6ffefe707c65a2a88b92c20ff3c8b91601cdef75bd638adbb73166
4
- data.tar.gz: 1e59dbc65c54baa19c8bac770ebd52a469aa95855c7758c020bfd8b72a51b3f0
3
+ metadata.gz: 2c4701ccba7500ef91ffd5d4c6978c9cef567bb8150a5e8724e6654f22688020
4
+ data.tar.gz: 8848a32bb16888dfda3a77f11c14c01e14d59532a19aa3a063b38bea7042fd18
5
5
  SHA512:
6
- metadata.gz: 7f2c7de0292ac2ce3ed011be69f6c887cf93873ab4b80c2288b4cd66ff22ec0780cb9872476656227eec164cf73ed9fc2e0ced1dcde154db6377343c408fbef5
7
- data.tar.gz: 783ca5c727bb5718aa7436b0252b83b9f4c904f28829635cc117f83920a740d2361cce9708707b8ba2f084148b6a5968e6e6a6f8cca56d9b9526d4b30fa59a76
6
+ metadata.gz: 6756cbb26cacb5279fa40ddda01f82d9e9a61956f4dafcfa45a8a0c61afa8b62df9a1b2ec86b31a995aef058a1c0989c14fb304680310e8c09e78fab95be7e31
7
+ data.tar.gz: 78f334424f4df172b084c1fb1c3f42094804a99bec24e5870dd53e95727b28c54f7ad5e36af196f71270ff86dc303f26fe530572b3f5f209865b8d92d9ceb0d1
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 3.2.2
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [0.4.0] - 2022-09-25
2
+
3
+ - Extract `performs` into the `active_job-performs` gem with some fixes and extra features, but include it as a dependency.
4
+
1
5
  ## [0.3.0] - 2022-09-25
2
6
 
3
7
  - Add `performs` to help cut down Active Job boilerplate.
data/Gemfile CHANGED
@@ -15,3 +15,5 @@ gem "sqlite3"
15
15
  gem "kredis"
16
16
  gem "activejob"
17
17
  gem "railties"
18
+
19
+ gem "minitest-sprint", "~> 1.2"
data/Gemfile.lock CHANGED
@@ -1,92 +1,135 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_record-associated_object (0.3.0)
4
+ active_record-associated_object (0.4.1)
5
+ active_job-performs
5
6
  activerecord (>= 6.1)
6
7
 
7
8
  GEM
8
9
  remote: https://rubygems.org/
9
10
  specs:
10
- actionpack (7.0.2.3)
11
- actionview (= 7.0.2.3)
12
- activesupport (= 7.0.2.3)
13
- rack (~> 2.0, >= 2.2.0)
11
+ actionpack (7.1.1)
12
+ actionview (= 7.1.1)
13
+ activesupport (= 7.1.1)
14
+ nokogiri (>= 1.8.5)
15
+ rack (>= 2.2.4)
16
+ rack-session (>= 1.0.1)
14
17
  rack-test (>= 0.6.3)
15
- rails-dom-testing (~> 2.0)
16
- rails-html-sanitizer (~> 1.0, >= 1.2.0)
17
- actionview (7.0.2.3)
18
- activesupport (= 7.0.2.3)
18
+ rails-dom-testing (~> 2.2)
19
+ rails-html-sanitizer (~> 1.6)
20
+ actionview (7.1.1)
21
+ activesupport (= 7.1.1)
19
22
  builder (~> 3.1)
20
- erubi (~> 1.4)
21
- rails-dom-testing (~> 2.0)
22
- rails-html-sanitizer (~> 1.1, >= 1.2.0)
23
- activejob (7.0.2.3)
24
- activesupport (= 7.0.2.3)
23
+ erubi (~> 1.11)
24
+ rails-dom-testing (~> 2.2)
25
+ rails-html-sanitizer (~> 1.6)
26
+ active_job-performs (0.2.0)
27
+ activejob (>= 6.1)
28
+ activejob (7.1.1)
29
+ activesupport (= 7.1.1)
25
30
  globalid (>= 0.3.6)
26
- activemodel (7.0.2.3)
27
- activesupport (= 7.0.2.3)
28
- activerecord (7.0.2.3)
29
- activemodel (= 7.0.2.3)
30
- activesupport (= 7.0.2.3)
31
- activesupport (7.0.2.3)
31
+ activemodel (7.1.1)
32
+ activesupport (= 7.1.1)
33
+ activerecord (7.1.1)
34
+ activemodel (= 7.1.1)
35
+ activesupport (= 7.1.1)
36
+ timeout (>= 0.4.0)
37
+ activesupport (7.1.1)
38
+ base64
39
+ bigdecimal
32
40
  concurrent-ruby (~> 1.0, >= 1.0.2)
41
+ connection_pool (>= 2.2.5)
42
+ drb
33
43
  i18n (>= 1.6, < 2)
34
44
  minitest (>= 5.1)
45
+ mutex_m
35
46
  tzinfo (~> 2.0)
47
+ base64 (0.1.1)
48
+ bigdecimal (3.1.4)
36
49
  builder (3.2.4)
37
- concurrent-ruby (1.1.10)
50
+ concurrent-ruby (1.2.2)
51
+ connection_pool (2.4.1)
38
52
  crass (1.0.6)
39
- debug (1.5.0)
40
- irb (>= 1.3.6)
41
- reline (>= 0.2.7)
42
- erubi (1.10.0)
43
- globalid (1.0.0)
44
- activesupport (>= 5.0)
45
- i18n (1.10.0)
53
+ debug (1.8.0)
54
+ irb (>= 1.5.0)
55
+ reline (>= 0.3.1)
56
+ drb (2.1.1)
57
+ ruby2_keywords
58
+ erubi (1.12.0)
59
+ globalid (1.2.1)
60
+ activesupport (>= 6.1)
61
+ i18n (1.14.1)
46
62
  concurrent-ruby (~> 1.0)
47
- io-console (0.5.11)
48
- irb (1.4.1)
49
- reline (>= 0.3.0)
50
- kredis (1.1.0)
63
+ io-console (0.6.0)
64
+ irb (1.8.3)
65
+ rdoc
66
+ reline (>= 0.3.8)
67
+ kredis (1.6.0)
68
+ activemodel (>= 6.0.0)
51
69
  activesupport (>= 6.0.0)
52
- redis (~> 4.2)
53
- loofah (2.16.0)
70
+ redis (>= 4.2, < 6)
71
+ loofah (2.21.4)
54
72
  crass (~> 1.0.2)
55
- nokogiri (>= 1.5.9)
56
- method_source (1.0.0)
57
- minitest (5.15.0)
58
- nokogiri (1.13.4-arm64-darwin)
73
+ nokogiri (>= 1.12.0)
74
+ minitest (5.20.0)
75
+ minitest-sprint (1.2.2)
76
+ path_expander (~> 1.1)
77
+ mutex_m (0.1.2)
78
+ nokogiri (1.15.4-arm64-darwin)
59
79
  racc (~> 1.4)
60
- nokogiri (1.13.4-x86_64-linux)
80
+ nokogiri (1.15.4-x86_64-linux)
61
81
  racc (~> 1.4)
62
- racc (1.6.0)
63
- rack (2.2.3)
64
- rack-test (1.1.0)
65
- rack (>= 1.0, < 3)
66
- rails-dom-testing (2.0.3)
67
- activesupport (>= 4.2.0)
82
+ path_expander (1.1.1)
83
+ psych (5.1.1.1)
84
+ stringio
85
+ racc (1.7.1)
86
+ rack (3.0.8)
87
+ rack-session (2.0.0)
88
+ rack (>= 3.0.0)
89
+ rack-test (2.1.0)
90
+ rack (>= 1.3)
91
+ rackup (2.1.0)
92
+ rack (>= 3)
93
+ webrick (~> 1.8)
94
+ rails-dom-testing (2.2.0)
95
+ activesupport (>= 5.0.0)
96
+ minitest
68
97
  nokogiri (>= 1.6)
69
- rails-html-sanitizer (1.4.2)
70
- loofah (~> 2.3)
71
- railties (7.0.2.3)
72
- actionpack (= 7.0.2.3)
73
- activesupport (= 7.0.2.3)
74
- method_source
98
+ rails-html-sanitizer (1.6.0)
99
+ loofah (~> 2.21)
100
+ nokogiri (~> 1.14)
101
+ railties (7.1.1)
102
+ actionpack (= 7.1.1)
103
+ activesupport (= 7.1.1)
104
+ irb
105
+ rackup (>= 1.0.0)
75
106
  rake (>= 12.2)
76
- thor (~> 1.0)
77
- zeitwerk (~> 2.5)
78
- rake (13.0.6)
79
- redis (4.6.0)
80
- reline (0.3.1)
107
+ thor (~> 1.0, >= 1.2.2)
108
+ zeitwerk (~> 2.6)
109
+ rake (13.1.0)
110
+ rdoc (6.5.0)
111
+ psych (>= 4.0.0)
112
+ redis (5.0.8)
113
+ redis-client (>= 0.17.0)
114
+ redis-client (0.18.0)
115
+ connection_pool
116
+ reline (0.3.9)
81
117
  io-console (~> 0.5)
82
- sqlite3 (1.4.2)
83
- thor (1.2.1)
84
- tzinfo (2.0.4)
118
+ ruby2_keywords (0.0.5)
119
+ sqlite3 (1.6.7-arm64-darwin)
120
+ sqlite3 (1.6.7-x86_64-linux)
121
+ stringio (3.0.8)
122
+ thor (1.3.0)
123
+ timeout (0.4.0)
124
+ tzinfo (2.0.6)
85
125
  concurrent-ruby (~> 1.0)
86
- zeitwerk (2.5.4)
126
+ webrick (1.8.1)
127
+ zeitwerk (2.6.12)
87
128
 
88
129
  PLATFORMS
89
130
  arm64-darwin-20
131
+ arm64-darwin-21
132
+ arm64-darwin-22
90
133
  x86_64-linux
91
134
 
92
135
  DEPENDENCIES
@@ -95,9 +138,10 @@ DEPENDENCIES
95
138
  debug
96
139
  kredis
97
140
  minitest (~> 5.0)
141
+ minitest-sprint (~> 1.2)
98
142
  railties
99
143
  rake (~> 13.0)
100
144
  sqlite3
101
145
 
102
146
  BUNDLED WITH
103
- 2.3.11
147
+ 2.4.21
data/README.md CHANGED
@@ -46,6 +46,8 @@ end
46
46
 
47
47
  ### How `performs` removes Active Job boilerplate
48
48
 
49
+ `performs` comes from the `active_job-performs` gem and is automatically bundled with `ActiveRecord::AssociatedObject`.
50
+
49
51
  With an associated object like this:
50
52
 
51
53
  ```ruby
data/Rakefile CHANGED
@@ -1,12 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "bundler/gem_tasks"
4
- require "rake/testtask"
5
-
6
- Rake::TestTask.new(:test) do |t|
7
- t.libs << "test"
8
- t.libs << "lib"
9
- t.test_files = FileList["test/**/test_*.rb"]
10
- end
11
-
12
- task default: :test
@@ -24,12 +24,11 @@ Gem::Specification.new do |spec|
24
24
  (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
25
25
  end
26
26
  end
27
- spec.bindir = "exe"
28
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
29
27
  spec.require_paths = ["lib"]
30
28
 
31
29
  # Uncomment to register a new dependency of your gem
32
30
  spec.add_dependency "activerecord", ">= 6.1"
31
+ spec.add_dependency "active_job-performs"
33
32
 
34
33
  # For more information and examples about making a new gem, check out our
35
34
  # guide at: https://bundler.io/guides/creating_gem.html
@@ -4,8 +4,8 @@ class ActiveRecord::AssociatedObject::Railtie < Rails::Railtie
4
4
  ActiveRecord::AssociatedObject.include GlobalID::Identification if defined?(GlobalID)
5
5
 
6
6
  ActiveSupport.on_load :active_job do
7
- require "active_record/associated_object/performs"
8
- ActiveRecord::AssociatedObject.extend ActiveRecord::AssociatedObject::Performs
7
+ require "active_job/performs"
8
+ ActiveRecord::AssociatedObject.extend ActiveJob::Performs
9
9
  end
10
10
  end
11
11
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ActiveRecord
4
4
  class AssociatedObject
5
- VERSION = "0.3.0"
5
+ VERSION = "0.4.1"
6
6
  end
7
7
  end
@@ -16,7 +16,7 @@ class ActiveRecord::AssociatedObject
16
16
  end
17
17
 
18
18
  def respond_to_missing?(...) = record_klass.respond_to?(...) || super
19
- delegate :unscoped, :transaction, to: :record_klass
19
+ delegate :unscoped, :transaction, :primary_key, to: :record_klass
20
20
 
21
21
  def method_missing(method, ...)
22
22
  if !record_klass.respond_to?(method) then super else
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record-associated_object
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kasper Timm Hansen
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-25 00:00:00.000000000 Z
11
+ date: 2023-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '6.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: active_job-performs
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  description:
28
42
  email:
29
43
  - hey@kaspth.com
@@ -31,6 +45,7 @@ executables: []
31
45
  extensions: []
32
46
  extra_rdoc_files: []
33
47
  files:
48
+ - ".tool-versions"
34
49
  - CHANGELOG.md
35
50
  - Gemfile
36
51
  - Gemfile.lock
@@ -40,7 +55,6 @@ files:
40
55
  - active_record-associated_object.gemspec
41
56
  - lib/active_record/associated_object.rb
42
57
  - lib/active_record/associated_object/object_association.rb
43
- - lib/active_record/associated_object/performs.rb
44
58
  - lib/active_record/associated_object/railtie.rb
45
59
  - lib/active_record/associated_object/version.rb
46
60
  homepage: https://github.com/kaspth/active_record-associated_object
@@ -65,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
65
79
  - !ruby/object:Gem::Version
66
80
  version: '0'
67
81
  requirements: []
68
- rubygems_version: 3.3.21
82
+ rubygems_version: 3.4.19
69
83
  signing_key:
70
84
  specification_version: 4
71
85
  summary: Associate a Ruby PORO with an Active Record class and have it quack like
@@ -1,36 +0,0 @@
1
- module ActiveRecord::AssociatedObject::Performs
2
- def performs(method = nil, **configs, &block)
3
- @job ||= safe_define("Job") { ApplicationJob }
4
-
5
- if method.nil?
6
- apply_performs_to(@job, **configs, &block)
7
- else
8
- job = safe_define("#{method}_job".classify) { @job }
9
- apply_performs_to(job, **configs, &block)
10
-
11
- job.class_eval <<~RUBY, __FILE__, __LINE__ + 1 unless job.instance_method(:perform).owner == job
12
- def perform(object, *arguments, **options)
13
- object.#{method}(*arguments, **options)
14
- end
15
- RUBY
16
-
17
- class_eval <<~RUBY, __FILE__, __LINE__ + 1
18
- def #{method}_later(*arguments, **options)
19
- #{job}.perform_later(self, *arguments, **options)
20
- end
21
- RUBY
22
- end
23
- end
24
-
25
- private
26
- def safe_define(name)
27
- name.safe_constantize || const_set(name, Class.new(yield))
28
- end
29
-
30
- def apply_performs_to(job_class, **configs, &block)
31
- job_class.class_eval do
32
- configs.each { public_send(_1, _2) }
33
- yield if block_given?
34
- end
35
- end
36
- end