jace 0.1.2 → 1.0.0
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 +4 -4
- data/.circleci/config.yml +7 -8
- data/.claude/agents/architect.md +56 -0
- data/.claude/agents/docs.md +35 -0
- data/.claude/agents/ruby.md +43 -0
- data/.claude/agents/security.md +26 -0
- data/.claude/configuration/arcanum-repo-config.json +9 -0
- data/.claude/configuration/auto-fix-all.json +3 -0
- data/.claude/scripts/check_ruby.sh +7 -0
- data/.claude/settings.json +10 -0
- data/.github/commit_message_template-2.0.md +32 -0
- data/.github/commit_message_template.md +8 -0
- data/.github/copilot-instructions.md +1 -99
- data/.github/pull_request_template.md +17 -0
- data/.gitignore +1 -0
- data/AGENTS.md +140 -0
- data/CLAUDE.md +1 -0
- data/Dockerfile +3 -2
- data/Gemfile +9 -9
- data/README.md +3 -3
- data/docs/agents/arcanum-split-issue.md +9 -0
- data/docs/agents/architecture.md +46 -0
- data/docs/agents/contributing.md +207 -0
- data/docs/agents/flow.md +27 -0
- data/docs/agents/folder-structure.md +60 -0
- data/docs/agents/issue-enhancement.md +10 -0
- data/docs/agents/issues/.gitkeep +1 -0
- data/docs/agents/plans/.gitkeep +1 -0
- data/docs/guides/jace/api-reference.md +20 -0
- data/docs/guides/jace/basic-usage.md +40 -0
- data/docs/guides/jace/core-concepts.md +43 -0
- data/docs/guides/jace/execution-model.md +19 -0
- data/docs/guides/jace/handlers.md +61 -0
- data/docs/guides/jace/installation.md +23 -0
- data/docs/guides/jace/integration-pattern.md +32 -0
- data/docs/guides/jace-usage.md +24 -0
- data/lib/jace/version.rb +1 -1
- data/scripts/bump_version.sh +62 -0
- data/spec/integration/yard/jace/registry_spec.rb +1 -2
- metadata +33 -7
- data/.github/jace-usage.md +0 -241
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Usage: scripts/bump_version.sh [major|minor|patch|X.Y.Z]
|
|
3
|
+
# Without arguments, bumps the patch version of the current version.
|
|
4
|
+
|
|
5
|
+
set -euo pipefail
|
|
6
|
+
|
|
7
|
+
ROOT="$(git rev-parse --show-toplevel)"
|
|
8
|
+
README="$ROOT/README.md"
|
|
9
|
+
VERSION_FILE="$ROOT/lib/jace/version.rb"
|
|
10
|
+
LOCKFILE="$ROOT/Gemfile.lock"
|
|
11
|
+
GEM="jace"
|
|
12
|
+
|
|
13
|
+
current=$(grep -oE "VERSION = '[0-9]+\.[0-9]+\.[0-9]+'" "$VERSION_FILE" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
|
|
14
|
+
IFS='.' read -r cmajor cminor cpatch <<< "$current"
|
|
15
|
+
|
|
16
|
+
arg="${1:-patch}"
|
|
17
|
+
|
|
18
|
+
case "$arg" in
|
|
19
|
+
major) new_version="$((cmajor + 1)).0.0" ;;
|
|
20
|
+
minor) new_version="${cmajor}.$((cminor + 1)).0" ;;
|
|
21
|
+
patch) new_version="${cmajor}.${cminor}.$((cpatch + 1))" ;;
|
|
22
|
+
*) new_version="$arg" ;;
|
|
23
|
+
esac
|
|
24
|
+
|
|
25
|
+
# Validate semver format
|
|
26
|
+
if ! echo "$new_version" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
|
|
27
|
+
echo "Error: version must be major, minor, patch or X.Y.Z" >&2
|
|
28
|
+
exit 1
|
|
29
|
+
fi
|
|
30
|
+
|
|
31
|
+
# Next release: following minor
|
|
32
|
+
IFS='.' read -r major minor _patch <<< "$new_version"
|
|
33
|
+
next_release="${major}.$((minor + 1)).0"
|
|
34
|
+
|
|
35
|
+
echo "Current version: $current"
|
|
36
|
+
echo "New version: $new_version"
|
|
37
|
+
echo "Next release: $next_release"
|
|
38
|
+
|
|
39
|
+
# version.rb
|
|
40
|
+
sed -i '' "s|VERSION = '[0-9.]*'|VERSION = '${new_version}'|" "$VERSION_FILE"
|
|
41
|
+
|
|
42
|
+
# README: YARD docs link
|
|
43
|
+
sed -i '' \
|
|
44
|
+
"s|rubydoc.info/gems/${GEM}/[0-9.]*|rubydoc.info/gems/${GEM}/${new_version}|g" \
|
|
45
|
+
"$README"
|
|
46
|
+
|
|
47
|
+
# README: Current Release line
|
|
48
|
+
sed -i '' \
|
|
49
|
+
"s|\*\*Current Release\*\*: \[[0-9.]*\](https://github.com/darthjee/jace/tree/[0-9.]*)|**Current Release**: [${new_version}](https://github.com/darthjee/jace/tree/${new_version})|" \
|
|
50
|
+
"$README"
|
|
51
|
+
|
|
52
|
+
# README: Next release line
|
|
53
|
+
sed -i '' \
|
|
54
|
+
"s|\*\*Next release\*\*: \[[0-9.]*\](https://github.com/darthjee/jace/compare/[0-9.]*\.\.\.main)|**Next release**: [${next_release}](https://github.com/darthjee/jace/compare/${new_version}...main)|" \
|
|
55
|
+
"$README"
|
|
56
|
+
|
|
57
|
+
# Gemfile.lock
|
|
58
|
+
if [ -f "$LOCKFILE" ]; then
|
|
59
|
+
sed -i '' "s|^\( *${GEM} (\)[0-9.]*)|\1${new_version})|" "$LOCKFILE"
|
|
60
|
+
fi
|
|
61
|
+
|
|
62
|
+
echo "Done."
|
|
@@ -6,7 +6,7 @@ describe Jace::Registry do
|
|
|
6
6
|
describe 'yard' do
|
|
7
7
|
subject(:registry) { described_class.new }
|
|
8
8
|
|
|
9
|
-
# rubocop:disable RSpec/NoExpectationExample
|
|
9
|
+
# rubocop:disable-next RSpec/NoExpectationExample
|
|
10
10
|
describe '#register' do
|
|
11
11
|
it 'register a new handler for an event' do
|
|
12
12
|
registry.register(:the_event) do
|
|
@@ -20,7 +20,6 @@ describe Jace::Registry do
|
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
22
|
end
|
|
23
|
-
# rubocop:enable RSpec/NoExpectationExample
|
|
24
23
|
|
|
25
24
|
describe '#trigger' do
|
|
26
25
|
let(:context) { SomeContext.new }
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: jace
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- DarthJee
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies: []
|
|
13
12
|
description: Gem focused on events for meta-programing
|
|
14
13
|
email:
|
|
@@ -18,12 +17,24 @@ extensions: []
|
|
|
18
17
|
extra_rdoc_files: []
|
|
19
18
|
files:
|
|
20
19
|
- ".circleci/config.yml"
|
|
20
|
+
- ".claude/agents/architect.md"
|
|
21
|
+
- ".claude/agents/docs.md"
|
|
22
|
+
- ".claude/agents/ruby.md"
|
|
23
|
+
- ".claude/agents/security.md"
|
|
24
|
+
- ".claude/configuration/arcanum-repo-config.json"
|
|
25
|
+
- ".claude/configuration/auto-fix-all.json"
|
|
26
|
+
- ".claude/scripts/check_ruby.sh"
|
|
27
|
+
- ".claude/settings.json"
|
|
28
|
+
- ".github/commit_message_template-2.0.md"
|
|
29
|
+
- ".github/commit_message_template.md"
|
|
21
30
|
- ".github/copilot-instructions.md"
|
|
22
|
-
- ".github/
|
|
31
|
+
- ".github/pull_request_template.md"
|
|
23
32
|
- ".gitignore"
|
|
24
33
|
- ".rspec"
|
|
25
34
|
- ".rubocop.yml"
|
|
26
35
|
- ".rubocop_todo.yml"
|
|
36
|
+
- AGENTS.md
|
|
37
|
+
- CLAUDE.md
|
|
27
38
|
- Dockerfile
|
|
28
39
|
- Gemfile
|
|
29
40
|
- LICENSE
|
|
@@ -35,6 +46,22 @@ files:
|
|
|
35
46
|
- config/yardstick.rb
|
|
36
47
|
- config/yardstick.yml
|
|
37
48
|
- docker-compose.yml
|
|
49
|
+
- docs/agents/arcanum-split-issue.md
|
|
50
|
+
- docs/agents/architecture.md
|
|
51
|
+
- docs/agents/contributing.md
|
|
52
|
+
- docs/agents/flow.md
|
|
53
|
+
- docs/agents/folder-structure.md
|
|
54
|
+
- docs/agents/issue-enhancement.md
|
|
55
|
+
- docs/agents/issues/.gitkeep
|
|
56
|
+
- docs/agents/plans/.gitkeep
|
|
57
|
+
- docs/guides/jace-usage.md
|
|
58
|
+
- docs/guides/jace/api-reference.md
|
|
59
|
+
- docs/guides/jace/basic-usage.md
|
|
60
|
+
- docs/guides/jace/core-concepts.md
|
|
61
|
+
- docs/guides/jace/execution-model.md
|
|
62
|
+
- docs/guides/jace/handlers.md
|
|
63
|
+
- docs/guides/jace/installation.md
|
|
64
|
+
- docs/guides/jace/integration-pattern.md
|
|
38
65
|
- jace.gemspec
|
|
39
66
|
- jace.png
|
|
40
67
|
- lib/jace.rb
|
|
@@ -43,6 +70,7 @@ files:
|
|
|
43
70
|
- lib/jace/handler.rb
|
|
44
71
|
- lib/jace/registry.rb
|
|
45
72
|
- lib/jace/version.rb
|
|
73
|
+
- scripts/bump_version.sh
|
|
46
74
|
- spec/integration/readme/.keep
|
|
47
75
|
- spec/integration/readme/jace/registry_spec.rb
|
|
48
76
|
- spec/integration/yard/.keep
|
|
@@ -60,7 +88,6 @@ files:
|
|
|
60
88
|
homepage: https://github.com/darthjee/jace
|
|
61
89
|
licenses: []
|
|
62
90
|
metadata: {}
|
|
63
|
-
post_install_message:
|
|
64
91
|
rdoc_options: []
|
|
65
92
|
require_paths:
|
|
66
93
|
- lib
|
|
@@ -75,8 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
75
102
|
- !ruby/object:Gem::Version
|
|
76
103
|
version: '0'
|
|
77
104
|
requirements: []
|
|
78
|
-
rubygems_version:
|
|
79
|
-
signing_key:
|
|
105
|
+
rubygems_version: 4.0.23
|
|
80
106
|
specification_version: 4
|
|
81
107
|
summary: Gem focused on events for meta-programing
|
|
82
108
|
test_files: []
|
data/.github/jace-usage.md
DELETED
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
# Using the Jace Gem
|
|
2
|
-
|
|
3
|
-
## What is Jace?
|
|
4
|
-
|
|
5
|
-
**Jace** is a Ruby gem for event-driven development **within a single application**.
|
|
6
|
-
It is not about distributed architecture or message queues — it is about building
|
|
7
|
-
internal event-oriented logic inside a Ruby gem or application.
|
|
8
|
-
|
|
9
|
-
With Jace, you register handlers for named events and trigger those events from
|
|
10
|
-
anywhere in your codebase. When an event is triggered, Jace executes the registered
|
|
11
|
-
`before` handlers (inside the context via `instance_eval`), then the main block,
|
|
12
|
-
then the `after` handlers (also inside the context via `instance_eval`).
|
|
13
|
-
|
|
14
|
-
---
|
|
15
|
-
|
|
16
|
-
## Installation
|
|
17
|
-
|
|
18
|
-
Add `jace` to your `Gemfile`:
|
|
19
|
-
|
|
20
|
-
```ruby
|
|
21
|
-
gem 'jace'
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
Then run:
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
bundle install
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
Or install it directly:
|
|
31
|
-
|
|
32
|
-
```bash
|
|
33
|
-
gem install jace
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
---
|
|
37
|
-
|
|
38
|
-
## Core Concepts
|
|
39
|
-
|
|
40
|
-
### `Jace::Registry`
|
|
41
|
-
|
|
42
|
-
The central object. It stores event-to-handler mappings and exposes two public
|
|
43
|
-
methods: `register` and `trigger`.
|
|
44
|
-
|
|
45
|
-
```ruby
|
|
46
|
-
registry = Jace::Registry.new
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
### `register(event, instant = :after, &block)`
|
|
50
|
-
|
|
51
|
-
Adds a handler block for a named event. The `instant` parameter controls whether
|
|
52
|
-
the block runs before or after the main event block.
|
|
53
|
-
|
|
54
|
-
| `instant` | When the handler runs |
|
|
55
|
-
|-----------|----------------------|
|
|
56
|
-
| `:after` (default) | After the main block |
|
|
57
|
-
| `:before` | Before the main block |
|
|
58
|
-
|
|
59
|
-
```ruby
|
|
60
|
-
registry.register(:payment_processed) { send_receipt }
|
|
61
|
-
registry.register(:payment_processed, :before) { validate_payment }
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
### `trigger(event, context, &block)`
|
|
65
|
-
|
|
66
|
-
Fires the named event. Jace runs the `before` handlers, then the given block,
|
|
67
|
-
then the `after` handlers. The `before` and `after` handlers are `instance_eval`'d
|
|
68
|
-
inside `context`, so bare method calls in handlers resolve against the context.
|
|
69
|
-
The main block is called normally (not `instance_eval`'d), so it uses the
|
|
70
|
-
surrounding scope's receiver.
|
|
71
|
-
|
|
72
|
-
```ruby
|
|
73
|
-
registry.trigger(:payment_processed, payment_object) do
|
|
74
|
-
charge_credit_card
|
|
75
|
-
end
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
---
|
|
79
|
-
|
|
80
|
-
## Basic Usage
|
|
81
|
-
|
|
82
|
-
```ruby
|
|
83
|
-
class Order
|
|
84
|
-
attr_reader :log
|
|
85
|
-
|
|
86
|
-
def initialize
|
|
87
|
-
@log = []
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
def validate
|
|
91
|
-
log << 'validated'
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
def persist
|
|
95
|
-
log << 'persisted'
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
def notify
|
|
99
|
-
log << 'notified'
|
|
100
|
-
end
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
registry = Jace::Registry.new
|
|
104
|
-
order = Order.new
|
|
105
|
-
|
|
106
|
-
registry.register(:save, :before) { validate }
|
|
107
|
-
registry.register(:save) { notify }
|
|
108
|
-
|
|
109
|
-
registry.trigger(:save, order) do
|
|
110
|
-
order.persist # main block uses the surrounding scope, so explicit receiver is needed
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
order.log
|
|
114
|
-
# => ['validated', 'persisted', 'notified']
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
---
|
|
118
|
-
|
|
119
|
-
## Handler Types
|
|
120
|
-
|
|
121
|
-
Handlers are registered as **blocks** (procs) and are `instance_eval`'d inside
|
|
122
|
-
the context object when the event fires, so bare method calls resolve against
|
|
123
|
-
the context.
|
|
124
|
-
|
|
125
|
-
```ruby
|
|
126
|
-
registry.register(:shipment_sent) { send_confirmation_email }
|
|
127
|
-
registry.register(:shipment_sent, :before) { freeze_order }
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
---
|
|
131
|
-
|
|
132
|
-
## Multiple Handlers per Event
|
|
133
|
-
|
|
134
|
-
You can register as many `before` and `after` handlers as you like for the same
|
|
135
|
-
event. They execute in registration order.
|
|
136
|
-
|
|
137
|
-
```ruby
|
|
138
|
-
registry.register(:user_created, :before) { sanitize_input }
|
|
139
|
-
registry.register(:user_created, :before) { check_duplicates }
|
|
140
|
-
registry.register(:user_created) { send_welcome_email }
|
|
141
|
-
registry.register(:user_created) { notify_admin }
|
|
142
|
-
|
|
143
|
-
registry.trigger(:user_created, user_context) do
|
|
144
|
-
persist_user
|
|
145
|
-
end
|
|
146
|
-
# Order: sanitize_input → check_duplicates → persist_user
|
|
147
|
-
# → send_welcome_email → notify_admin
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
---
|
|
151
|
-
|
|
152
|
-
## Triggering Events Without a Main Block
|
|
153
|
-
|
|
154
|
-
The main block is optional. If omitted, only the registered handlers run:
|
|
155
|
-
|
|
156
|
-
```ruby
|
|
157
|
-
registry.trigger(:cache_invalidated, cache_context)
|
|
158
|
-
# Runs all :before handlers, then all :after handlers; no main block
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
---
|
|
162
|
-
|
|
163
|
-
## Triggering an Unregistered Event
|
|
164
|
-
|
|
165
|
-
Triggering an event that has no registered handlers is safe. The main block is
|
|
166
|
-
still executed, and no error is raised:
|
|
167
|
-
|
|
168
|
-
```ruby
|
|
169
|
-
registry.trigger(:unknown_event, some_context) do
|
|
170
|
-
do_work
|
|
171
|
-
end
|
|
172
|
-
# do_work runs normally; no handlers fire
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
---
|
|
176
|
-
|
|
177
|
-
## Typical Integration Pattern
|
|
178
|
-
|
|
179
|
-
The most common pattern is to hold a `Jace::Registry` instance inside a service
|
|
180
|
-
or module and expose `register` to callers so they can hook into lifecycle events:
|
|
181
|
-
|
|
182
|
-
```ruby
|
|
183
|
-
module PaymentService
|
|
184
|
-
REGISTRY = Jace::Registry.new
|
|
185
|
-
|
|
186
|
-
def self.on(event, instant = :after, &block)
|
|
187
|
-
REGISTRY.register(event, instant, &block)
|
|
188
|
-
end
|
|
189
|
-
|
|
190
|
-
def self.process(payment)
|
|
191
|
-
REGISTRY.trigger(:payment_processed, payment) do
|
|
192
|
-
payment.charge!
|
|
193
|
-
end
|
|
194
|
-
end
|
|
195
|
-
end
|
|
196
|
-
|
|
197
|
-
# In an initializer or plugin:
|
|
198
|
-
PaymentService.on(:payment_processed) { send_receipt }
|
|
199
|
-
PaymentService.on(:payment_processed, :before) { log_attempt }
|
|
200
|
-
|
|
201
|
-
# Elsewhere in the application:
|
|
202
|
-
PaymentService.process(payment)
|
|
203
|
-
# Runs: log_attempt → payment.charge! → send_receipt
|
|
204
|
-
```
|
|
205
|
-
|
|
206
|
-
---
|
|
207
|
-
|
|
208
|
-
## Execution Model (summary)
|
|
209
|
-
|
|
210
|
-
```
|
|
211
|
-
registry.trigger(:event, context) { main_block }
|
|
212
|
-
|
|
213
|
-
Execution order:
|
|
214
|
-
1. All :before handlers (in registration order, instance_eval'd in context)
|
|
215
|
-
2. main_block (called as-is, context is NOT the receiver)
|
|
216
|
-
3. All :after handlers (in registration order, instance_eval'd in context)
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
> **Note:** The `before` and `after` handlers are `instance_eval`'d inside the
|
|
220
|
-
> context object, so bare method calls inside them (`send_receipt`, `validate`,
|
|
221
|
-
> etc.) resolve against the context. The main block, however, is a regular
|
|
222
|
-
> `call` (not `instance_eval`), so its receiver is the surrounding scope.
|
|
223
|
-
|
|
224
|
-
---
|
|
225
|
-
|
|
226
|
-
## API Reference
|
|
227
|
-
|
|
228
|
-
| Method | Signature | Description |
|
|
229
|
-
|--------|-----------|-------------|
|
|
230
|
-
| `Registry#register` | `(event, instant = :after, &block)` | Adds a handler to the named event |
|
|
231
|
-
| `Registry#trigger` | `(event, context, &block)` | Fires the event, running handlers around the block |
|
|
232
|
-
| `Registry#events` | `()` | Returns all registered event names as `Array<Symbol>` |
|
|
233
|
-
| `Registry#registry` | `()` | Returns the raw `Hash` of event → `Dispatcher` mappings |
|
|
234
|
-
|
|
235
|
-
---
|
|
236
|
-
|
|
237
|
-
## YARD Documentation
|
|
238
|
-
|
|
239
|
-
Full API docs: [https://www.rubydoc.info/gems/jace](https://www.rubydoc.info/gems/jace)
|
|
240
|
-
|
|
241
|
-
Source: [https://github.com/darthjee/jace](https://github.com/darthjee/jace)
|