jobify 0.2.0 → 0.3.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: befabb328f9f8f32e568d4042eea00aa168159e586a8b536ebe461fd534cc356
4
- data.tar.gz: 6e5a56168fd43ce015f2859108ea51f57440c3b71422c5ff6d2f4c56e290cbc8
3
+ metadata.gz: 8c34bf93e6019d918312706b17ed0503044d2dc4ea16de824702223afa879d49
4
+ data.tar.gz: 2328a20bc2654f9053d85694d062bda712762d00100747f0a68166436df56729
5
5
  SHA512:
6
- metadata.gz: 5f14cc62d1e8cf7aa53635d1ce346cd10b4a1949d959295489b9e0a86d461fed9165f42ed36965292356fa93d8bd7c1f7bbb7652cca8daca76ace6d5e38386cd
7
- data.tar.gz: 3928441745d55e247e45c398b14688d8926dd49d1c3e01fb4ff972e3346b3e489ec367ad47cef8e6e1f60e7095067184cd5dc35139e0b535642d1ad9582fcdc8
6
+ metadata.gz: 5ed50a875bdff43a912fa392cc852c4f80ddc43c10d453037ecc5c64c1407a93d83a23f3ae078d27a6ba63d8588ef3d2c5bdc3dd148a5e190e0e19020c577ce5
7
+ data.tar.gz: 9dd6f7b8765756f3ec85979e75564254970ac8851b42d23431b8434f24a79d5114a6bb61aa181b230d6889c2d4aa906cecb9c2fd349c5d878586d97fb63f79a3
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.7.6
data/CHANGELOG.md CHANGED
@@ -13,3 +13,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
13
13
  - Add support for my_method?
14
14
  - Add support for my_method!
15
15
  - Allow POROs with same-name class and instance methods to jobify class methods
16
+
17
+ ## [0.3.0] - 2022-11-13
18
+ - Add support for private methods
data/Gemfile CHANGED
@@ -6,7 +6,3 @@ source "https://rubygems.org"
6
6
  gemspec
7
7
 
8
8
  gem "rake", "~> 13.0"
9
-
10
- gem "minitest", "~> 5.0"
11
-
12
- gem "rubocop", "~> 1.21"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jobify (0.2.0)
4
+ jobify (0.3.0)
5
5
  activejob
6
6
  activesupport
7
7
 
@@ -31,14 +31,14 @@ GEM
31
31
  rake (13.0.6)
32
32
  regexp_parser (2.6.0)
33
33
  rexml (3.2.5)
34
- rubocop (1.37.0)
34
+ rubocop (1.38.0)
35
35
  json (~> 2.3)
36
36
  parallel (~> 1.10)
37
37
  parser (>= 3.1.2.1)
38
38
  rainbow (>= 2.2.2, < 4.0)
39
39
  regexp_parser (>= 1.8, < 3.0)
40
40
  rexml (>= 3.2.5, < 4.0)
41
- rubocop-ast (>= 1.22.0, < 2.0)
41
+ rubocop-ast (>= 1.23.0, < 2.0)
42
42
  ruby-progressbar (~> 1.7)
43
43
  unicode-display_width (>= 1.4.0, < 3.0)
44
44
  rubocop-ast (1.23.0)
@@ -50,6 +50,7 @@ GEM
50
50
 
51
51
  PLATFORMS
52
52
  x86_64-darwin-20
53
+ x86_64-darwin-21
53
54
  x86_64-linux
54
55
 
55
56
  DEPENDENCIES
@@ -59,4 +60,4 @@ DEPENDENCIES
59
60
  rubocop (~> 1.21)
60
61
 
61
62
  BUNDLED WITH
62
- 2.3.14
63
+ 2.3.18
data/jobify.gemspec CHANGED
@@ -34,6 +34,9 @@ Gem::Specification.new do |spec|
34
34
  # Uncomment to register a new dependency of your gem
35
35
  spec.add_dependency "activejob"
36
36
  spec.add_dependency "activesupport"
37
+
38
+ spec.add_development_dependency "minitest", "~> 5.0"
39
+ spec.add_development_dependency "rubocop", "~> 1.21"
37
40
 
38
41
  # For more information and examples about making a new gem, check out our
39
42
  # guide at: https://bundler.io/guides/creating_gem.html
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jobify
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
data/lib/jobify.rb CHANGED
@@ -27,13 +27,13 @@ module Jobify
27
27
  method_name = method_name.to_s
28
28
  job_method_name = job_method_name(method_name, job_method_name)
29
29
 
30
- if respond_to?(method_name) && !@jobified_methods[:singleton][method_name]
30
+ if has_class_method?(method_name) && !@jobified_methods[:singleton][method_name]
31
31
  # Class methods are jobified first,
32
32
  # so that class methods can be jobified by POROs with same-name instance methods
33
33
  params = method(method_name).parameters
34
34
  _define_job_class(method_name, job_method_name, params, singleton_method: true)
35
35
  @jobified_methods[:singleton][method_name] = true
36
- elsif method_defined?(method_name) && !@jobified_methods[:instance][method_name]
36
+ elsif has_instance_method?(method_name) && !@jobified_methods[:instance][method_name]
37
37
  # Instance method
38
38
  params = instance_method(method_name).parameters
39
39
  _define_job_class(method_name, job_method_name, params, singleton_method: false)
@@ -69,9 +69,9 @@ module Jobify
69
69
  def self.singleton__define_job_perform_method(job_class, caller_class, method_name)
70
70
  job_class.define_method(:perform) do |*args, **kw_args|
71
71
  if kw_args.empty?
72
- caller_class.public_send(method_name, *args)
72
+ caller_class.send(method_name, *args)
73
73
  else
74
- caller_class.public_send(method_name, *args, **kw_args)
74
+ caller_class.send(method_name, *args, **kw_args)
75
75
  end
76
76
  end
77
77
  end
@@ -98,7 +98,7 @@ module Jobify
98
98
  raise "Something has gone wrong. Record id is required" unless id
99
99
 
100
100
  record = caller_class.find(id)
101
- record.public_send(method_name, *args, **kw_args)
101
+ record.send(method_name, *args, **kw_args)
102
102
  end
103
103
  end
104
104
 
@@ -139,5 +139,14 @@ module Jobify
139
139
  def ensure_all_args_present!(req_args, args)
140
140
  self.class.ensure_all_args_present!(req_args, args)
141
141
  end
142
+
143
+ def self.has_class_method?(method_name)
144
+ respond_to?(method_name, true)
145
+ end
146
+
147
+ def self.has_instance_method?(method_name)
148
+ method_defined?(method_name) || private_method_defined?(method_name)
149
+ end
150
+
142
151
  end
143
152
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jobify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Søren Houen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-10-27 00:00:00.000000000 Z
11
+ date: 2022-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activejob
@@ -38,6 +38,34 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.21'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.21'
41
69
  description:
42
70
  email:
43
71
  - s@houen.net
@@ -46,6 +74,7 @@ extensions: []
46
74
  extra_rdoc_files: []
47
75
  files:
48
76
  - ".rubocop.yml"
77
+ - ".ruby-version"
49
78
  - CHANGELOG.md
50
79
  - Gemfile
51
80
  - Gemfile.lock
@@ -80,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
109
  - !ruby/object:Gem::Version
81
110
  version: '0'
82
111
  requirements: []
83
- rubygems_version: 3.2.32
112
+ rubygems_version: 3.1.6
84
113
  signing_key:
85
114
  specification_version: 4
86
115
  summary: Turn any method into a background job (`jobify :hello_world` generates `def