gaskit 0.1.0 → 0.1.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: 730e79d1901d9f1387a4017012b826e8770721d54091c51ce39e06516fe79d02
4
- data.tar.gz: 13d90e62fe463f95363a06fc23d006c6548684a7154e4694a4506c163100b5f6
3
+ metadata.gz: 027472a523376db0fa6b2083f1c298f39552630b66f92cf44d7156f92112a441
4
+ data.tar.gz: 3d36a0dc67131520cca1b751cd001793ecb8d163c86826ab68f34416dee80cf0
5
5
  SHA512:
6
- metadata.gz: c79fab8c3710d603b82478efabe67bc137325590a1af10c65b6abb4d8c4936bdd52111e9c0901d2815acf3e6e4a7d226715d40e5a0e1f3cf4462d1946671e548
7
- data.tar.gz: a54df89b8f1b9a32b8c86ab37b7cb9c0b6034dc8a113aa1f29dca36a871ab5300df7d27075962877299fc627735547719d5d95677d91c2a38deb35a813cf25a6
6
+ metadata.gz: 895d318451f0d0264e3fcad3fd7e157eb309d064ede5ead7120a0c16a735948da7243b04961affb24adbb2b6f9efb6d2be1a7f0e6b36a2069a19fe9f50bf4daa
7
+ data.tar.gz: b8f56f2826b3824143df936f98d7d8569a5693d99059b0cbc6aec2f0523fb38ca0c3bf03b808234e2e9f416d306e71e51caa82f3cc69b76b19509f3fbc22e1ad
data/.rspec_status CHANGED
@@ -1,18 +1,18 @@
1
1
  example_id | status | run_time |
2
2
  ---------------------------------------------- | ------ | --------------- |
3
- ./spec/gaskit/configuration_spec.rb[1:1:1] | passed | 0.0011 seconds |
3
+ ./spec/gaskit/configuration_spec.rb[1:1:1] | passed | 0.00092 seconds |
4
4
  ./spec/gaskit/configuration_spec.rb[1:2:1] | passed | 0.00006 seconds |
5
- ./spec/gaskit/configuration_spec.rb[1:2:2] | passed | 0.00004 seconds |
5
+ ./spec/gaskit/configuration_spec.rb[1:2:2] | passed | 0.00005 seconds |
6
6
  ./spec/gaskit/configuration_spec.rb[1:2:3] | passed | 0.00004 seconds |
7
- ./spec/gaskit/configuration_spec.rb[1:2:4] | passed | 0.00003 seconds |
8
- ./spec/gaskit/configuration_spec.rb[1:3:1] | passed | 0.00052 seconds |
7
+ ./spec/gaskit/configuration_spec.rb[1:2:4] | passed | 0.00004 seconds |
8
+ ./spec/gaskit/configuration_spec.rb[1:3:1] | passed | 0.00053 seconds |
9
9
  ./spec/gaskit/configuration_spec.rb[1:4:1] | passed | 0.00004 seconds |
10
10
  ./spec/gaskit/configuration_spec.rb[1:4:2] | passed | 0.00004 seconds |
11
- ./spec/gaskit/configuration_spec.rb[1:5:1] | passed | 0.00005 seconds |
12
- ./spec/gaskit/configuration_spec.rb[1:5:2] | passed | 0.00122 seconds |
11
+ ./spec/gaskit/configuration_spec.rb[1:5:1] | passed | 0.00004 seconds |
12
+ ./spec/gaskit/configuration_spec.rb[1:5:2] | passed | 0.00107 seconds |
13
13
  ./spec/gaskit/contract_registry_spec.rb[1:1:1] | passed | 0.00006 seconds |
14
14
  ./spec/gaskit/contract_registry_spec.rb[1:1:2] | passed | 0.00006 seconds |
15
- ./spec/gaskit/contract_registry_spec.rb[1:2:1] | passed | 0.00042 seconds |
15
+ ./spec/gaskit/contract_registry_spec.rb[1:2:1] | passed | 0.00032 seconds |
16
16
  ./spec/gaskit/contract_registry_spec.rb[1:2:2] | passed | 0.00007 seconds |
17
17
  ./spec/gaskit/contract_registry_spec.rb[1:2:3] | passed | 0.00006 seconds |
18
18
  ./spec/gaskit/contract_registry_spec.rb[1:2:4] | passed | 0.00004 seconds |
@@ -24,52 +24,123 @@ example_id | status | run_time |
24
24
  ./spec/gaskit/contract_registry_spec.rb[1:5:2] | passed | 0.00004 seconds |
25
25
  ./spec/gaskit/core_spec.rb[1:1:1] | passed | 0.00003 seconds |
26
26
  ./spec/gaskit/core_spec.rb[1:1:2] | passed | 0.00003 seconds |
27
- ./spec/gaskit/core_spec.rb[1:2:1] | passed | 0.00089 seconds |
28
- ./spec/gaskit/core_spec.rb[1:3:1] | passed | 0.00337 seconds |
29
- ./spec/gaskit/core_spec.rb[1:4:1] | passed | 0.00008 seconds |
30
- ./spec/gaskit/core_spec.rb[1:5:1] | passed | 0.00004 seconds |
31
- ./spec/gaskit/core_spec.rb[1:5:2] | passed | 0.00003 seconds |
32
- ./spec/gaskit/core_spec.rb[1:6:1] | passed | 0.00005 seconds |
33
- ./spec/gaskit/flow_spec.rb[1:1:1] | passed | 0.00098 seconds |
34
- ./spec/gaskit/flow_spec.rb[1:1:2] | passed | 0.0002 seconds |
35
- ./spec/gaskit/flow_spec.rb[1:1:3] | passed | 0.00019 seconds |
36
- ./spec/gaskit/flow_spec.rb[1:2:1] | passed | 0.00014 seconds |
37
- ./spec/gaskit/flow_spec.rb[1:3:1] | passed | 0.00022 seconds |
27
+ ./spec/gaskit/core_spec.rb[1:2:1] | passed | 0.00085 seconds |
28
+ ./spec/gaskit/flow_spec.rb[1:1:1] | passed | 0.00005 seconds |
29
+ ./spec/gaskit/flow_spec.rb[1:2:1] | passed | 0.00004 seconds |
30
+ ./spec/gaskit/flow_spec.rb[1:3:1] | passed | 0.00003 seconds |
31
+ ./spec/gaskit/flow_spec.rb[1:4:1] | passed | 0.00014 seconds |
32
+ ./spec/gaskit/flow_spec.rb[1:4:2] | passed | 0.00014 seconds |
33
+ ./spec/gaskit/flow_spec.rb[1:4:3:1:1] | passed | 0.00083 seconds |
34
+ ./spec/gaskit/flow_spec.rb[1:4:4:1:1] | passed | 0.0001 seconds |
35
+ ./spec/gaskit/flow_spec.rb[1:4:5:1:1] | passed | 0.00008 seconds |
36
+ ./spec/gaskit/flow_spec.rb[1:5:1] | passed | 0.00008 seconds |
37
+ ./spec/gaskit/flow_spec.rb[1:5:2] | passed | 0.00012 seconds |
38
+ ./spec/gaskit/flow_spec.rb[1:5:3:1:1] | passed | 0.0001 seconds |
39
+ ./spec/gaskit/flow_spec.rb[1:5:4:1:1] | passed | 0.00009 seconds |
40
+ ./spec/gaskit/flow_spec.rb[1:5:5:1:1] | passed | 0.0001 seconds |
41
+ ./spec/gaskit/flow_spec.rb[1:6:1] | passed | 0.00007 seconds |
42
+ ./spec/gaskit/flow_spec.rb[1:7:1] | passed | 0.0001 seconds |
43
+ ./spec/gaskit/flow_spec.rb[1:8:1] | passed | 0.00004 seconds |
44
+ ./spec/gaskit/flow_spec.rb[1:8:2] | passed | 0.00007 seconds |
45
+ ./spec/gaskit/flow_spec.rb[1:9:1] | passed | 0.00006 seconds |
46
+ ./spec/gaskit/flow_spec.rb[1:9:2] | passed | 0.00008 seconds |
47
+ ./spec/gaskit/flow_spec.rb[1:9:3] | passed | 0.00007 seconds |
48
+ ./spec/gaskit/flow_spec.rb[1:9:4] | passed | 0.00006 seconds |
49
+ ./spec/gaskit/flow_spec.rb[1:10:1] | passed | 0.00007 seconds |
50
+ ./spec/gaskit/flow_spec.rb[1:10:2] | passed | 0.00006 seconds |
51
+ ./spec/gaskit/flow_spec.rb[1:11:1] | passed | 0.00007 seconds |
52
+ ./spec/gaskit/flow_spec.rb[1:12:1] | passed | 0.00006 seconds |
53
+ ./spec/gaskit/flow_spec.rb[1:13:1] | passed | 0.00008 seconds |
54
+ ./spec/gaskit/flow_spec.rb[1:14:1] | passed | 0.00287 seconds |
55
+ ./spec/gaskit/hook_registry_spec.rb[1:1:1] | passed | 0.00005 seconds |
56
+ ./spec/gaskit/hook_registry_spec.rb[1:1:2] | passed | 0.00003 seconds |
57
+ ./spec/gaskit/hook_registry_spec.rb[1:1:3] | passed | 0.00004 seconds |
58
+ ./spec/gaskit/hook_registry_spec.rb[1:1:4] | passed | 0.00004 seconds |
59
+ ./spec/gaskit/hook_registry_spec.rb[1:2:1] | passed | 0.00004 seconds |
60
+ ./spec/gaskit/hook_registry_spec.rb[1:2:2] | passed | 0.00003 seconds |
61
+ ./spec/gaskit/hook_registry_spec.rb[1:3:1] | passed | 0.00168 seconds |
62
+ ./spec/gaskit/hook_registry_spec.rb[1:3:2] | passed | 0.00007 seconds |
63
+ ./spec/gaskit/hook_registry_spec.rb[1:3:3] | passed | 0.00004 seconds |
64
+ ./spec/gaskit/hook_registry_spec.rb[1:4:1] | passed | 0.00005 seconds |
65
+ ./spec/gaskit/hookable_spec.rb[1:1:1:1] | passed | 0.00006 seconds |
66
+ ./spec/gaskit/hookable_spec.rb[1:1:1:2] | passed | 0.00004 seconds |
67
+ ./spec/gaskit/hookable_spec.rb[1:1:2:1] | passed | 0.00005 seconds |
68
+ ./spec/gaskit/hookable_spec.rb[1:1:2:2] | passed | 0.00005 seconds |
69
+ ./spec/gaskit/hookable_spec.rb[1:1:2:3] | passed | 0.00004 seconds |
70
+ ./spec/gaskit/hookable_spec.rb[1:1:3:1] | passed | 0.00005 seconds |
71
+ ./spec/gaskit/hookable_spec.rb[1:1:4:1] | passed | 0.00005 seconds |
72
+ ./spec/gaskit/hookable_spec.rb[1:1:5:1] | passed | 0.00004 seconds |
73
+ ./spec/gaskit/hookable_spec.rb[1:1:6:1] | passed | 0.00004 seconds |
74
+ ./spec/gaskit/hookable_spec.rb[1:1:7:1] | passed | 0.00004 seconds |
75
+ ./spec/gaskit/hookable_spec.rb[1:1:8:1] | passed | 0.00004 seconds |
76
+ ./spec/gaskit/hookable_spec.rb[1:1:9:1] | passed | 0.00004 seconds |
77
+ ./spec/gaskit/hookable_spec.rb[1:2:1:1] | passed | 0.00006 seconds |
78
+ ./spec/gaskit/hookable_spec.rb[1:2:1:2] | passed | 0.00005 seconds |
79
+ ./spec/gaskit/hookable_spec.rb[1:2:2:1] | passed | 0.00007 seconds |
80
+ ./spec/gaskit/hookable_spec.rb[1:2:3:1] | passed | 0.00211 seconds |
81
+ ./spec/gaskit/hookable_spec.rb[1:2:4:1] | passed | 0.00006 seconds |
38
82
  ./spec/gaskit/logger_spec.rb[1:1:1] | passed | 0.00008 seconds |
39
- ./spec/gaskit/logger_spec.rb[1:2:1] | passed | 0.00134 seconds |
83
+ ./spec/gaskit/logger_spec.rb[1:2:1] | passed | 0.00008 seconds |
40
84
  ./spec/gaskit/logger_spec.rb[1:2:2] | passed | 0.00006 seconds |
41
85
  ./spec/gaskit/logger_spec.rb[1:3:1] | passed | 0.00005 seconds |
42
- ./spec/gaskit/logger_spec.rb[1:4:1] | passed | 0.00006 seconds |
43
- ./spec/gaskit/logger_spec.rb[1:4:2] | passed | 0.00004 seconds |
44
- ./spec/gaskit/logger_spec.rb[1:4:3] | passed | 0.00004 seconds |
45
- ./spec/gaskit/operation_exit_spec.rb[1:1:1] | passed | 0.00003 seconds |
46
- ./spec/gaskit/operation_exit_spec.rb[1:1:2] | passed | 0.00002 seconds |
47
- ./spec/gaskit/operation_exit_spec.rb[1:2:1] | passed | 0.00002 seconds |
86
+ ./spec/gaskit/logger_spec.rb[1:4:1] | passed | 0.00005 seconds |
87
+ ./spec/gaskit/logger_spec.rb[1:4:2] | passed | 0.00011 seconds |
88
+ ./spec/gaskit/logger_spec.rb[1:4:3] | passed | 0.00005 seconds |
89
+ ./spec/gaskit/operation_exit_spec.rb[1:1:1] | passed | 0.00004 seconds |
90
+ ./spec/gaskit/operation_exit_spec.rb[1:1:2] | passed | 0.00003 seconds |
91
+ ./spec/gaskit/operation_exit_spec.rb[1:2:1] | passed | 0.00003 seconds |
48
92
  ./spec/gaskit/operation_exit_spec.rb[1:2:2] | passed | 0.00003 seconds |
49
- ./spec/gaskit/operation_exit_spec.rb[1:3:1] | passed | 0.00002 seconds |
50
- ./spec/gaskit/operation_result_spec.rb[1:1:1] | passed | 0.00004 seconds |
93
+ ./spec/gaskit/operation_exit_spec.rb[1:3:1] | passed | 0.00003 seconds |
94
+ ./spec/gaskit/operation_result_spec.rb[1:1:1] | passed | 0.00005 seconds |
51
95
  ./spec/gaskit/operation_result_spec.rb[1:1:2] | passed | 0.00003 seconds |
52
- ./spec/gaskit/operation_result_spec.rb[1:2:1] | passed | 0.00003 seconds |
53
- ./spec/gaskit/operation_result_spec.rb[1:2:2] | passed | 0.00003 seconds |
54
- ./spec/gaskit/operation_result_spec.rb[1:2:3] | passed | 0.00003 seconds |
55
- ./spec/gaskit/operation_result_spec.rb[1:3:1] | passed | 0.00003 seconds |
96
+ ./spec/gaskit/operation_result_spec.rb[1:2:1] | passed | 0.00004 seconds |
97
+ ./spec/gaskit/operation_result_spec.rb[1:2:2] | passed | 0.00004 seconds |
98
+ ./spec/gaskit/operation_result_spec.rb[1:2:3] | passed | 0.0001 seconds |
99
+ ./spec/gaskit/operation_result_spec.rb[1:3:1] | passed | 0.00004 seconds |
56
100
  ./spec/gaskit/operation_result_spec.rb[1:4:1] | passed | 0.00003 seconds |
57
101
  ./spec/gaskit/operation_result_spec.rb[1:4:2] | passed | 0.00003 seconds |
58
- ./spec/gaskit/operation_result_spec.rb[1:4:3] | passed | 0.00003 seconds |
59
- ./spec/gaskit/operation_spec.rb[1:1:1] | passed | 0.00005 seconds |
60
- ./spec/gaskit/operation_spec.rb[1:1:2] | passed | 0.00014 seconds |
61
- ./spec/gaskit/operation_spec.rb[1:1:3] | passed | 0.00006 seconds |
62
- ./spec/gaskit/operation_spec.rb[1:1:4] | passed | 0.00006 seconds |
63
- ./spec/gaskit/operation_spec.rb[1:2:1] | passed | 0.00007 seconds |
64
- ./spec/gaskit/operation_spec.rb[1:3:1] | passed | 0.0001 seconds |
65
- ./spec/gaskit/operation_spec.rb[1:4:1] | passed | 0.00015 seconds |
66
- ./spec/gaskit/operation_spec.rb[1:5:1] | passed | 0.00005 seconds |
102
+ ./spec/gaskit/operation_result_spec.rb[1:4:3] | passed | 0.00004 seconds |
103
+ ./spec/gaskit/operation_spec.rb[1:1:1:1] | passed | 0.0001 seconds |
104
+ ./spec/gaskit/operation_spec.rb[1:1:1:2] | passed | 0.0001 seconds |
105
+ ./spec/gaskit/operation_spec.rb[1:1:2:1] | passed | 0.00004 seconds |
106
+ ./spec/gaskit/operation_spec.rb[1:1:2:2] | passed | 0.00007 seconds |
107
+ ./spec/gaskit/operation_spec.rb[1:1:2:3] | passed | 0.00004 seconds |
108
+ ./spec/gaskit/operation_spec.rb[1:1:3:1] | passed | 0.00008 seconds |
109
+ ./spec/gaskit/operation_spec.rb[1:1:3:2] | passed | 0.00004 seconds |
110
+ ./spec/gaskit/operation_spec.rb[1:1:3:3] | passed | 0.00003 seconds |
111
+ ./spec/gaskit/operation_spec.rb[1:1:3:4] | passed | 0.00003 seconds |
112
+ ./spec/gaskit/operation_spec.rb[1:1:3:5] | passed | 0.00017 seconds |
113
+ ./spec/gaskit/operation_spec.rb[1:1:4:1] | passed | 0.00005 seconds |
114
+ ./spec/gaskit/operation_spec.rb[1:1:5:1:1:1] | passed | 0.00027 seconds |
115
+ ./spec/gaskit/operation_spec.rb[1:1:5:2:1] | passed | 0.00072 seconds |
116
+ ./spec/gaskit/operation_spec.rb[1:1:5:3:1:1] | passed | 0.00012 seconds |
117
+ ./spec/gaskit/operation_spec.rb[1:1:5:3:2] | passed | 0.00018 seconds |
118
+ ./spec/gaskit/operation_spec.rb[1:1:5:4:1:1] | passed | 0.00025 seconds |
119
+ ./spec/gaskit/operation_spec.rb[1:1:5:5:1:1] | passed | 0.00016 seconds |
120
+ ./spec/gaskit/operation_spec.rb[1:1:5:6:1:1] | passed | 0.00017 seconds |
121
+ ./spec/gaskit/operation_spec.rb[1:1:6:1:1:1] | passed | 0.0001 seconds |
122
+ ./spec/gaskit/operation_spec.rb[1:1:6:2:1] | passed | 0.00014 seconds |
123
+ ./spec/gaskit/operation_spec.rb[1:1:6:3:1:1] | passed | 0.00014 seconds |
124
+ ./spec/gaskit/operation_spec.rb[1:1:6:4:1:1] | passed | 0.00031 seconds |
125
+ ./spec/gaskit/operation_spec.rb[1:1:6:5:1:1] | passed | 0.00026 seconds |
126
+ ./spec/gaskit/operation_spec.rb[1:2:1:1] | passed | 0.00004 seconds |
127
+ ./spec/gaskit/operation_spec.rb[1:2:1:2] | passed | 0.00003 seconds |
128
+ ./spec/gaskit/operation_spec.rb[1:2:1:3] | passed | 0.00003 seconds |
129
+ ./spec/gaskit/operation_spec.rb[1:2:2:1] | passed | 0.00004 seconds |
130
+ ./spec/gaskit/operation_spec.rb[1:2:3:1:1] | passed | 0.0001 seconds |
131
+ ./spec/gaskit/operation_spec.rb[1:2:3:2:1] | passed | 0.00008 seconds |
132
+ ./spec/gaskit/operation_spec.rb[1:2:3:3:1] | passed | 0.00012 seconds |
133
+ ./spec/gaskit/operation_spec.rb[1:2:3:4:1] | passed | 0.00006 seconds |
134
+ ./spec/gaskit/operation_spec.rb[1:3:1] | passed | 0.00007 seconds |
135
+ ./spec/gaskit/operation_spec.rb[1:4:1:1:1] | passed | 0.00014 seconds |
136
+ ./spec/gaskit/operation_spec.rb[1:4:1:2:1] | passed | 0.00007 seconds |
137
+ ./spec/gaskit/operation_spec.rb[1:4:1:2:2] | passed | 0.00013 seconds |
67
138
  ./spec/gaskit/repository_spec.rb[1:1:1] | passed | 0.00006 seconds |
68
- ./spec/gaskit/repository_spec.rb[1:2:1] | passed | 0.00014 seconds |
69
- ./spec/gaskit/repository_spec.rb[1:2:2] | passed | 0.00009 seconds |
70
- ./spec/gaskit/repository_spec.rb[1:3:1] | passed | 0.00006 seconds |
71
- ./spec/gaskit/repository_spec.rb[1:3:2] | passed | 0.00013 seconds |
139
+ ./spec/gaskit/repository_spec.rb[1:2:1] | passed | 0.00004 seconds |
140
+ ./spec/gaskit/repository_spec.rb[1:2:2] | passed | 0.00004 seconds |
141
+ ./spec/gaskit/repository_spec.rb[1:3:1] | passed | 0.00004 seconds |
142
+ ./spec/gaskit/repository_spec.rb[1:3:2] | passed | 0.00004 seconds |
72
143
  ./spec/gaskit/repository_spec.rb[1:4:1] | passed | 0.00018 seconds |
73
- ./spec/gaskit/repository_spec.rb[1:4:2] | passed | 0.00014 seconds |
74
- ./spec/gaskit_spec.rb[1:1] | passed | 0.00004 seconds |
75
- ./spec/gaskit_spec.rb[1:2] | passed | 0.00013 seconds |
144
+ ./spec/gaskit/repository_spec.rb[1:4:2] | passed | 0.0001 seconds |
145
+ ./spec/gaskit_spec.rb[1:1] | passed | 0.00003 seconds |
146
+ ./spec/gaskit_spec.rb[1:2] | passed | 0.0001 seconds |
data/.rubocop.yml CHANGED
@@ -22,7 +22,7 @@ Layout/LineLength:
22
22
  Max: 120
23
23
 
24
24
  Metrics/ClassLength:
25
- Max: 150
25
+ Max: 200
26
26
 
27
27
  Metrics/BlockLength:
28
28
  Exclude:
data/CHANGELOG.md CHANGED
@@ -1,110 +1,21 @@
1
- ## [0.1.4] - 2025-04-08
1
+ # Changelog
2
2
 
3
- ### Added
4
-
5
- - Error registration support in `Gaskit::Operation` via the `error` class method. This allows declaring symbolic exit keys with associated messages and optional codes.
6
-
7
- ```ruby
8
- class MyOperation < Gaskit::Operation
9
- error :unauthorized, 'User must be authorized', code: 401
10
-
11
- def call
12
- exit(:unauthorized)
13
- end
14
- end
15
- ```
16
-
17
- - Structured `exit` and `error` payloads in `OperationResult#to_h`:
18
- - `:exit` is present when an operation exited early (via `exit(:key)`), containing:
19
- - `key`: the symbolic reason (e.g. `:unauthorized`)
20
- - `message`: a friendly message
21
- - `code`: optional numeric code if defined
22
- - `:error` is present for handled errors, containing:
23
- - `type`: class name of the error
24
- - `message`: error message
25
- - `backtrace`: full Ruby backtrace (if available)
26
- - `:meta` contains duration and context
27
-
28
- - `OperationResult#to_json` for automatic JSON serialization of the result object.
29
-
30
- ### Changed
31
-
32
- - `OperationResult#to_h` now returns:
33
- - `success`: boolean
34
- - `status`: one of `:success`, `:failure`, `:early_exit`
35
- - `value`: only present on success
36
- - `exit`: structured hash for early exits
37
- - `error`: structured hash for raised errors
38
- - `meta`: always includes `duration` and optionally includes `context`
39
-
40
- ## [0.1.3] - 2025-04-08
3
+ All notable changes to this project will be documented in this file.
41
4
 
42
- ### Added
43
- - `Gaskit::Repository` base class for service-layer data access patterns:
44
- - Prevents instantiation (`.new` raises `TypeError`)
45
- - Adds structured logging and execution time measurement via `.log_execution_time`
46
- - Supports assigning a model with `.model(ModelClass)`
47
- - Delegates common ActiveRecord-style methods (e.g., `find`, `where`, `create!`, etc.)
48
- - Repository generator:
49
- `rails generate gaskit:repository User`
50
- Generates a file like `UserRepository` with `model User` already declared.
51
-
52
- ### Changed
53
- - `Repository.model` now enforces that a model can only be set once. Attempting to redefine the model raises a `RuntimeError`.
54
- - `Repository.logger` returns a class-scoped `Gaskit::Logger` for structured log formatting with optional context.
55
- - Refactored `.log_execution_time` to use `Gaskit::Helpers.time_execution` internally for cleaner timing logic.
56
-
57
- ### Fixed
58
- - Specs for `Gaskit::Repository` now use isolated, dynamically generated anonymous classes to avoid model assignment clashes across examples.
59
- - Error messages in `.model` now include the class name for clarity (e.g., `UserRepository already has a model set`).
60
-
61
- ### Specs
62
- - Full test coverage
63
-
64
- ## [0.1.2] - 2025-04-08
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
65
6
 
66
- ### Changed
67
- - General cleanup and test coverage.
68
-
69
- ## [0.1.1] - 2025-04-08
7
+ ## [0.1.1] - 2025-04-10
70
8
 
71
9
  ### Added
72
- - `Gaskit::Flow` and `Gaskit::FlowResult` for composing multi-step operation pipelines with full step tracking, duration timing, and input/output logging.
73
- - Support for inline and class-based `Flow` definitions using `step` DSL.
74
- - `step_input` and `compile_step_entry` helpers to track arguments and keyword arguments passed to each flow step.
75
- - `Gaskit::ContractRegistry` with result class validation, contract registration, and fetching.
76
- - `Gaskit::Configuration` with customizable:
77
- - `logger`, `log_level`, `log_formatter`, and `disable_logging`
78
- - dynamic `context` provider (e.g., for request or user metadata)
79
- - contract registration and access
80
- - `Gaskit::OperationResult` class:
81
- - Unified result structure for all operations
82
- - Success/failure helpers, `#to_h` serialization, and human-readable `#inspect`
83
- - `Gaskit::OperationExit` for early exits with symbolic keys and messages.
84
-
85
- ### Changed
86
- - `Operation.result_class` now falls back to the superclass's contract when not explicitly set.
87
- - `Operation.invoke` raises a clear `NotImplementedError` if no contract is defined.
88
- - `Operation.call` and `call!` now log duration in a readable format (`"0.000123"`).
89
- - Refined flow step result propagation:
90
- - Arrays are passed as positional args
91
- - Hashes as keyword args
92
- - Single values are normalized into `[value], {}`
93
-
94
- ### Fixed
95
- - Resolved double-registration issues in test contracts by using randomized contract names in specs.
96
- - Ensured each step’s inputs and outputs are correctly logged and serialized in `FlowResult#steps`.
97
-
98
- ### Specs
99
- - Full test coverage added for:
100
- - `Gaskit::Operation` (contract handling, success/failure, early exits)
101
- - `Gaskit::ContractRegistry` (validation, fetch, override, registration errors)
102
- - `Gaskit::Configuration` (logger settings, contract management)
103
- - `Gaskit::OperationResult` and `OperationExit`
104
- - `Gaskit::Flow` and `FlowResult`, including multi-step execution and error propagation
105
10
 
106
- ---
11
+ - Hook system with support for `before`, `after`, and `around` hooks.
12
+ - `HookRegistry` for globally registered hooks, similar to `ContractRegistry`.
13
+ - `Hookable` concern, enabling hooks for `Operation`, `Flow`, and `Repository`.
14
+ - `use_hooks` to enable hooks in a class with optional tag filtering.
15
+ - Support for class-level inline hooks via `.before`, `.after`, `.around`.
16
+ - `execute_with_hooks` helper for wrapped hook execution.
17
+ - Specs for `HookRegistry`, `Hookable`, and integration with `Operation`.
107
18
 
108
- ## [0.1.0] - 2025-04-06
19
+ ## [0.1.0] - 2025-04-08
109
20
 
110
21
  - Initial release
data/README.md CHANGED
@@ -10,6 +10,7 @@ Gaskit is a flexible, pluggable, and structured operations framework for Ruby an
10
10
  - 🧪 Built-in error declarations and early exits via `exit(:key)`
11
11
  - ⏱ Integrated duration tracking and structured logging
12
12
  - 🧰 Generators for Rails to scaffold operations, services, queries, flows, and repositories
13
+ - 🪝 Hook system for before/after/around instrumentation and auditing
13
14
 
14
15
  ## 📦 Installation
15
16
 
@@ -98,6 +99,35 @@ end
98
99
  result = CheckoutFlow.call(user_id: 123)
99
100
  ```
100
101
 
102
+ ## 🪝 Hooks
103
+
104
+ Use `use_hooks` to activate instrumentation:
105
+
106
+ ```ruby
107
+ class HookedOp < Gaskit::Operation
108
+ use_contract :service
109
+ use_hooks :audit
110
+
111
+ before do |op|
112
+ op.logger.info("Starting operation")
113
+ end
114
+
115
+ after do |op, result:, error:|
116
+ op.logger.info("Finished with result=#{result.inspect} error=#{error.inspect}")
117
+ end
118
+
119
+ def call
120
+ "hello"
121
+ end
122
+ end
123
+ ```
124
+
125
+ Register global hooks via:
126
+
127
+ ```ruby
128
+ Gaskit.hooks.register(:before, :audit) { |op| puts "Before: #{op.class}" }
129
+ ```
130
+
101
131
  ## 🧪 Generators
102
132
 
103
133
  ```bash
@@ -124,7 +154,7 @@ You can define contracts using registered result types:
124
154
  ```ruby
125
155
  class MyResult < Gaskit::OperationResult; end
126
156
 
127
- Gaskit.register_contract(:custom, MyResult)
157
+ Gaskit.contracts.register(:custom, MyResult)
128
158
 
129
159
  class CustomOp < Gaskit::Operation
130
160
  use_contract :custom
@@ -146,7 +176,7 @@ end
146
176
  ```ruby
147
177
  class UserRepository < Gaskit::Repository
148
178
  model User
149
-
179
+
150
180
  def find_by_name_or_slug(name, profile_slug)
151
181
  where(name: name).or(where(profile_slug: profile_slug))
152
182
  end
data/gaskit-0.1.0.gem ADDED
Binary file
@@ -12,7 +12,7 @@ module Gaskit
12
12
  # end
13
13
  class QueryResult < OperationResult; end
14
14
 
15
- Gaskit.register_contract(:query, QueryResult)
15
+ Gaskit.contracts.register(:query, QueryResult)
16
16
 
17
17
  # A base class for query-style operations.
18
18
  #
@@ -10,7 +10,7 @@ module Gaskit
10
10
  # end
11
11
  class ServiceResult < OperationResult; end
12
12
 
13
- Gaskit.register_contract(:service, ServiceResult)
13
+ Gaskit.contracts.register(:service, ServiceResult)
14
14
 
15
15
  # A base class for service-style operations.
16
16
  #
@@ -2,6 +2,9 @@
2
2
 
3
3
  require "logger"
4
4
 
5
+ require_relative "contract_registry"
6
+ require_relative "hook_registry"
7
+
5
8
  module Gaskit
6
9
  # Gaskit::Configuration holds global configuration for the Gaskit gem.
7
10
  #
@@ -58,6 +61,7 @@ module Gaskit
58
61
  @disable_logging = false
59
62
  @context_provider = -> { {} }
60
63
  @contract_registry = ContractRegistry.new
64
+ @hook_registry = HookRegistry.new
61
65
 
62
66
  setup_logger
63
67
  end
@@ -104,41 +108,18 @@ module Gaskit
104
108
  @context_provider = provider
105
109
  end
106
110
 
107
- # Registers a contract with a name and associated result class.
108
- #
109
- # @param name [Symbol, String] The name of the contract.
110
- # @param result_class [Class] The class that represents the result for the contract.
111
- # @param override [Boolean] Whether to override an existing contract (default: false).
112
- # @raise [Gaskit::ContractError] If the contract is already registered and override is not allowed.
113
- # @raise [Gaskit::ResultTypeError] If the result_class does not inherit from `Gaskit::OperationResult`.
114
- # @return [void]
115
- def register_contract(name, result_class, override: false)
116
- @contract_registry.register(name, result_class, override: override)
117
- end
118
-
119
- # Fetches a registered contract's result class by its name.
120
- #
121
- # @param name [Symbol, String] The name of the contract.
122
- # @return [Class] The result class associated with the contract.
123
- # @raise [Gaskit::ContractError] If the contract is not registered.
124
- def fetch_contract(name)
125
- @contract_registry.fetch(name)
126
- end
127
-
128
- # Checks if a contract is registered.
111
+ # Returns the ContractRegistry instance.
129
112
  #
130
- # @param name [Symbol, String] The name of the contract.
131
- # @return [Boolean] true if the contract is registered, otherwise false.
132
- def contract_registered?(name)
133
- @contract_registry.registered?(name)
113
+ # @return [Gaskit::ContractRegistry] The ContractRegistry instance.
114
+ def contracts
115
+ @contract_registry
134
116
  end
135
117
 
136
- # Lists all registered contracts.
118
+ # Returns the HookRegistry instance.
137
119
  #
138
- # @return [Hash<Symbol, Class>] A hash of all registered contracts where keys are
139
- # contract names and values are their corresponding result classes.
140
- def registered_contracts
141
- @contract_registry.all
120
+ # @return [Gaskit::HookRegistry] The HookRegistry instance.
121
+ def hooks
122
+ @hook_registry
142
123
  end
143
124
  end
144
125
  end
@@ -60,7 +60,7 @@ module Gaskit
60
60
  def fetch(name)
61
61
  @contracts.fetch(name.to_sym) do
62
62
  raise Gaskit::ContractError, "Contract #{name} not registered, register it with " \
63
- "Gaskit.configuration.register_contract(name, result_class)"
63
+ "Gaskit.configuration.contracts.register(name, result_class)"
64
64
  end
65
65
  end
66
66
 
@@ -68,7 +68,7 @@ module Gaskit
68
68
  #
69
69
  # @return [Hash<Symbol, Class>] A hash of all registered contracts where keys are
70
70
  # contract names and values are their corresponding result classes
71
- def all
71
+ def registered
72
72
  @contracts.dup
73
73
  end
74
74
  end
data/lib/gaskit/core.rb CHANGED
@@ -30,35 +30,18 @@ module Gaskit
30
30
  Gaskit.configuration.debug
31
31
  end
32
32
 
33
- # Registers a new operation contract.
33
+ # Returns configuration.contracts.
34
34
  #
35
- # @param name [Symbol, String] Contract name
36
- # @param result_class [Class<Gaskit::OperationResult>] Result class for the operation
37
- def register_contract(name, result_class, override: false)
38
- configuration.register_contract(name, result_class, override: override)
35
+ # @return [Gaskit::ContractRegistry] The ContractRegistry instance.
36
+ def contracts
37
+ configuration.contracts
39
38
  end
40
39
 
41
- # Fetches the result and exit classes for the given contract name.
40
+ # Returns configuration.hooks.
42
41
  #
43
- # @param name [Symbol, String]
44
- # @return [Class]
45
- def fetch_contract(name)
46
- configuration.fetch_contract(name)
47
- end
48
-
49
- # Returns whether the contract is registered.
50
- #
51
- # @param name [Symbol, String]
52
- # @return [Boolean]
53
- def contract_registered?(name)
54
- configuration.contract_registered?(name)
55
- end
56
-
57
- # Returns all registered contracts.
58
- #
59
- # @return [Hash{Symbol=>Hash}]
60
- def registered_contracts
61
- configuration.registered_contracts
42
+ # @return [Gaskit::HookRegistry] The HookRegistry instance.
43
+ def hooks
44
+ configuration.hooks
62
45
  end
63
46
  end
64
47
  end