chaotic_job 0.7.0 → 0.8.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 94de9ce766a9042a925882e70f29a8022fbd3b22fbd175ed3254260e04962cba
4
- data.tar.gz: e05d2546038d72cd9181fef3eff223d7adec84225b0fa1267d89d0b3880351ef
3
+ metadata.gz: 849d42915a7b67d65b21d094c0484175003ada6435f04292fd5d25701e591e46
4
+ data.tar.gz: 3b2c99e71c3d90986f3bec08c85404262f9a93ae06871a6cc2d93aeefadb5a69
5
5
  SHA512:
6
- metadata.gz: 29fedcda5ca8ec4c98fa68d4f1e0661194c558a72a7a70b6b19a445de0e4bb0741e873c1365911315a8be73461248ccbca3005dd604e0a1f8229cf75aa4f7f69
7
- data.tar.gz: 93423ffd252f3faf4b3c0e0c0e7097fc9e14468d884935fed12421ca653cc99a47819ab80833d4068e0c8ebf23752e45385923384c56e4072e08554d7fe872f2
6
+ metadata.gz: e1cf5362e18f450c04c71e65b81375b77f216430239732756c471c521b4da6b8dc4e698c2eb1dc120cea439453be48fcf9511fed7a807ca3f8e7099323487835
7
+ data.tar.gz: 313c74e725dfc3ac4a85e8a065a72b3d5ba27f5d353adf78678eead045cc92c4a5769541ab9ed6b038ac182b507c40d97a9c7e650dc6307d3b53bdf62d53495f
data/.standard.yml CHANGED
@@ -5,3 +5,5 @@ ruby_version: 3.0
5
5
  ignore:
6
6
  - 'test/**/*':
7
7
  - Lint/ConstantDefinitionInBlock
8
+ - 'lib/**/*':
9
+ - Style/YodaCondition
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.8.1] - 2025-06-12
4
+
5
+ - Add pretty `to_s` methods for Scenario and Glitch [#11](https://github.com/fractaledmind/chaotic_job/pull/11)
6
+
7
+ ## [0.8.0] - 2025-06-11
8
+
9
+ - Add methods to allow checking if a Scenario matches a particular Glitch key + event pair [#10](https://github.com/fractaledmind/chaotic_job/pull/10)
10
+
3
11
  ## [0.7.0] - 2025-06-09
4
12
 
5
13
  - Glitch only works with singular event + key definition [#6](https://github.com/fractaledmind/chaotic_job/pull/6)
@@ -19,6 +19,8 @@ module ChaoticJob
19
19
  new(key, :return, retval: return_type, &block)
20
20
  end
21
21
 
22
+ attr_reader :key, :event
23
+
22
24
  def initialize(key, event, *args, retval: nil, **kwargs, &block)
23
25
  @event = event
24
26
  @key = key
@@ -53,6 +55,25 @@ module ChaoticJob
53
55
  @executed
54
56
  end
55
57
 
58
+ def to_s
59
+ # ChaoticJob::Glitch(
60
+ # event: String,
61
+ # key: String,
62
+ # args: [Array],
63
+ # kwargs: [Hash],
64
+ # retval: [Object]
65
+ # )
66
+ buffer = +"ChaoticJob::Glitch(\n"
67
+ buffer << " event: #{@event}\n"
68
+ buffer << " key: #{@key}\n"
69
+ buffer << " args: #{@args}\n" if @args.any?
70
+ buffer << " kwargs: #{@kwargs}\n" if @kwargs.any?
71
+ buffer << " retval: #{@retval}\n" if @retval
72
+ buffer << ")"
73
+
74
+ buffer
75
+ end
76
+
56
77
  private
57
78
 
58
79
  # :nocov: SimpleCov cannot track code executed _within_ a TracePoint
@@ -36,5 +36,46 @@ module ChaoticJob
36
36
  def glitched?
37
37
  @glitch.executed?
38
38
  end
39
+
40
+ def before_line?(key)
41
+ return false unless :line == @glitch.event
42
+
43
+ key == @glitch.key
44
+ end
45
+
46
+ def before_call?(key)
47
+ return false unless :call == @glitch.event
48
+
49
+ key == @glitch.key
50
+ end
51
+
52
+ def before_return?(key)
53
+ return false unless :return == @glitch.event
54
+
55
+ key == @glitch.key
56
+ end
57
+
58
+ def to_s
59
+ # ChaoticJob::Scenario(
60
+ # job: Job(arguments),
61
+ # glitch: Glitch()
62
+ # )
63
+ buffer = +"ChaoticJob::Scenario(\n"
64
+
65
+ job_attributes = @job.serialize
66
+ buffer << " job: #{job_attributes["job_class"]}"
67
+ buffer << "("
68
+ buffer << job_attributes["arguments"].join(", ")
69
+ buffer << "),\n"
70
+
71
+ glitch_start, *glitch_lines = @glitch.to_s.split("\n")
72
+ buffer << " glitch: #{glitch_start}\n"
73
+ glitch_lines.each do |line|
74
+ buffer << " #{line}\n"
75
+ end
76
+ buffer << ")"
77
+
78
+ buffer
79
+ end
39
80
  end
40
81
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ChaoticJob
4
- VERSION = "0.7.0"
4
+ VERSION = "0.8.1"
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chaotic_job
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Margheim
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-06-09 00:00:00.000000000 Z
10
+ date: 2025-06-12 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: activejob