active_record-associated_object 0.3.0 → 0.4.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: 9b5e7079fe6ffefe707c65a2a88b92c20ff3c8b91601cdef75bd638adbb73166
4
- data.tar.gz: 1e59dbc65c54baa19c8bac770ebd52a469aa95855c7758c020bfd8b72a51b3f0
3
+ metadata.gz: 20d91687ec83cbc70efb318377c15ce1e2e79b28d350322b0d91ad6618073cc2
4
+ data.tar.gz: 59f19eea143da23bd980f0d6bca5a96670e13c7859d0db860741bf314d949822
5
5
  SHA512:
6
- metadata.gz: 7f2c7de0292ac2ce3ed011be69f6c887cf93873ab4b80c2288b4cd66ff22ec0780cb9872476656227eec164cf73ed9fc2e0ced1dcde154db6377343c408fbef5
7
- data.tar.gz: 783ca5c727bb5718aa7436b0252b83b9f4c904f28829635cc117f83920a740d2361cce9708707b8ba2f084148b6a5968e6e6a6f8cca56d9b9526d4b30fa59a76
6
+ metadata.gz: a41fc155e625c0d04d01f39a55a6c80155b8e275abb1c9be9ef5fac6c927cd6c36b83a13a9f621c73c344b333b246bd86e76bb49773579b2605fb1d2ede636b3
7
+ data.tar.gz: 3de159d609ac4ab8eedbe03d681cd6d8295ca4831c7eb4430ca760f86dfa243906bd9c7d62cc2cd60cf44ba0aa271116114703bd59a784780260d4b961f3e725
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,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_record-associated_object (0.3.0)
4
+ active_record-associated_object (0.4.0)
5
+ active_job-performs
5
6
  activerecord (>= 6.1)
6
7
 
7
8
  GEM
@@ -20,6 +21,8 @@ GEM
20
21
  erubi (~> 1.4)
21
22
  rails-dom-testing (~> 2.0)
22
23
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
24
+ active_job-performs (0.1.1)
25
+ activejob (>= 6.1)
23
26
  activejob (7.0.2.3)
24
27
  activesupport (= 7.0.2.3)
25
28
  globalid (>= 0.3.6)
@@ -55,10 +58,13 @@ GEM
55
58
  nokogiri (>= 1.5.9)
56
59
  method_source (1.0.0)
57
60
  minitest (5.15.0)
61
+ minitest-sprint (1.2.2)
62
+ path_expander (~> 1.1)
58
63
  nokogiri (1.13.4-arm64-darwin)
59
64
  racc (~> 1.4)
60
65
  nokogiri (1.13.4-x86_64-linux)
61
66
  racc (~> 1.4)
67
+ path_expander (1.1.1)
62
68
  racc (1.6.0)
63
69
  rack (2.2.3)
64
70
  rack-test (1.1.0)
@@ -95,6 +101,7 @@ DEPENDENCIES
95
101
  debug
96
102
  kredis
97
103
  minitest (~> 5.0)
104
+ minitest-sprint (~> 1.2)
98
105
  railties
99
106
  rake (~> 13.0)
100
107
  sqlite3
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.0"
6
6
  end
7
7
  end
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.0
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: 2022-09-27 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
@@ -40,7 +54,6 @@ files:
40
54
  - active_record-associated_object.gemspec
41
55
  - lib/active_record/associated_object.rb
42
56
  - lib/active_record/associated_object/object_association.rb
43
- - lib/active_record/associated_object/performs.rb
44
57
  - lib/active_record/associated_object/railtie.rb
45
58
  - lib/active_record/associated_object/version.rb
46
59
  homepage: https://github.com/kaspth/active_record-associated_object
@@ -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