callback-collection 0.2.0 → 0.2.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: 1b8d078e3adf404673581fa27324c5047a56f553607ed5a061cfd2235beda3af
4
- data.tar.gz: 46b3b5395ebe4f3b28613abe64aa0732d4e5b090cdada60680706c6552e73a1a
3
+ metadata.gz: 7b15736a4210e0b8985c8978498bfcde00f3d7c574626e2b51a61d65cf5f85ef
4
+ data.tar.gz: 51e8e8b26a322261f77fb27e0a5c23bd35cced8347da6ac6b0bc806079b40e6b
5
5
  SHA512:
6
- metadata.gz: bb5f40c036768f917b0b2478fb1abfac644cc1514cb770c012503f03e3a5aea4c7f1607cd5f88ad74a9de4febad7b01096ca415c972654ff54c2febd0877ad6a
7
- data.tar.gz: 3579c01beef765ea0388ee4ce0344fc89ddfbc35ecd524b9307c0536fbe14529ce77b9eee1da348c3271ed948a2649297c2f905bb37438ce27261bb0844ea81f
6
+ metadata.gz: 52cacd005d07848b64da529f35c3dfbcaef61c0851e2384e453e9e6f09e9de22eacc1a478f528941f8a0a8abd66f1df7792d22449e18c66beed3e24f9fe7bc49
7
+ data.tar.gz: 2fba1f3f416d764d261dc0fff5f516521898b9ee8af4242079ffecad87057d8ac8ab9d67a44770f7fd84c98de3a941264de02eaffda7028adbcaddb6971a6bf5
data/README.md CHANGED
@@ -6,45 +6,74 @@
6
6
  [![Documentation Status](https://img.shields.io/badge/docs-RubyDoc.info-blue.svg)](https://www.rubydoc.info/gems/callback-collection)
7
7
  [![Downloads](https://img.shields.io/gem/dt/callback-collection.svg?style=flat)](https://rubygems.org/gems/callback-collection)
8
8
 
9
- Une petite gem Ruby permettant de définir une collection immuable de callbacks
10
- nommés.
9
+ A small Ruby gem for defining an immutable collection of named callbacks.
10
+
11
+ ## Why Callback Collection?
12
+
13
+ `CallbackCollection` groups callback definitions during initialization and
14
+ exposes a single `respond_with` interface for invoking them. The registry
15
+ becomes immutable once constructed, preventing late additions and making its
16
+ behavior easier to test and reason about.
17
+
18
+ The gem does not replace framework callbacks or start threads or Ractors
19
+ itself. It provides an independent container that applications can use within
20
+ their own execution model.
21
+
22
+ ## Architectural highlights
23
+
24
+ - **Immutable after initialization:** the collection and its internal registry
25
+ are frozen when the configuration block completes. Callback definitions can
26
+ then be read concurrently by multiple threads without mutating shared
27
+ registry state.
28
+ - **Optional Ractor compatibility:** on Ruby 3.0 and later, `register` stores a
29
+ receiver and method name instead of a closure. The collection is shareable
30
+ when the receiver and all the state it uses are also Ractor-shareable.
31
+ - **Ruby 2.7 and later:** the standard API and `register` do not depend on
32
+ `Ractor`. Applications running Ruby 2.7 retain the immutable registry and
33
+ concurrent thread-read behavior.
34
+ - **Direct lookup:** `respond_with` uses `Hash#fetch` to find a callback in one
35
+ operation and raises an explicit error when it does not exist.
36
+
37
+ Immutability protects the registry, not automatically the code executed by its
38
+ callbacks. A callback that accesses mutable shared state remains responsible
39
+ for its own synchronization.
11
40
 
12
41
  ## Installation
13
42
 
14
- Installez la gem depuis RubyGems :
43
+ Install the gem from RubyGems:
15
44
 
16
45
  ```sh
17
46
  gem install callback-collection
18
47
  ```
19
48
 
20
- Avec Bundler, ajoutez-la au `Gemfile` :
49
+ With Bundler, add it to your `Gemfile`:
21
50
 
22
51
  ```ruby
23
52
  gem "callback-collection"
24
53
  ```
25
54
 
26
- ## Utilisation
55
+ ## Usage
27
56
 
28
57
  ```ruby
29
58
  require "callback_collection"
30
59
 
31
60
  callbacks = CallbackCollection.new do |collection|
32
- collection.success { |name| "Bienvenue, #{name} !" }
33
- collection.failure { |error| "Erreur : #{error.message}" }
61
+ collection.success { |name| "Welcome, #{name}!" }
62
+ collection.failure { |error| "Error: #{error.message}" }
34
63
  end
35
64
 
36
65
  callbacks.respond_with(:success, "Ruby")
37
- # => "Bienvenue, Ruby !"
66
+ # => "Welcome, Ruby!"
38
67
  ```
39
68
 
40
- La collection est figée à la fin de son initialisation. Toute tentative
41
- d'ajouter ensuite un callback lève une `FrozenError`.
69
+ The collection is frozen at the end of initialization. Attempting to add a
70
+ callback afterward raises `FrozenError`.
42
71
 
43
- ### Ractors (Ruby 3.0 et versions ultérieures)
72
+ ### Ractors (Ruby 3.0 and later)
44
73
 
45
- Les blocs conservent leur contexte lexical et ne peuvent donc pas être partagés
46
- entre Ractors. Pour créer une collection partageable, enregistrez plutôt un
47
- objet partageable et l'une de ses méthodes :
74
+ Blocks retain their lexical context and therefore cannot be shared between
75
+ Ractors. To create a shareable collection, register a shareable receiver and
76
+ one of its methods instead:
48
77
 
49
78
  ```ruby
50
79
  module Handlers
@@ -69,46 +98,47 @@ result
69
98
  # => 42
70
99
  ```
71
100
 
72
- Le troisième argument de `register` permet d'utiliser un nom de méthode
73
- différent du nom du callback :
101
+ The third argument to `register` lets you use a method name that differs from
102
+ the callback name:
74
103
 
75
104
  ```ruby
76
105
  collection.register(:total, Handlers, :sum)
77
106
  ```
78
107
 
79
- Le receveur enregistré et les données qu'il utilise doivent eux-mêmes respecter
80
- les règles de partage des Ractors. L'appel à `respond_with` reste identique.
81
- Sous Ruby 2.7, la gem et `register` restent utilisables normalement ; seule
82
- l'exécution avec `Ractor` est indisponible.
108
+ The registered receiver and the data it uses must follow Ractor shareability
109
+ rules. Calls to `respond_with` remain unchanged. On Ruby 2.7, the gem and
110
+ `register` remain fully usable; only Ractor execution is unavailable. The gem
111
+ does not create workers: the application retains control over their lifecycle
112
+ and exchanged messages.
83
113
 
84
- ## Développement
114
+ ## Development
85
115
 
86
116
  ```sh
87
117
  bundle install
88
118
  bundle exec rake
89
119
  ```
90
120
 
91
- La tâche par défaut exécute la suite Minitest et construit la gem dans `pkg/`.
92
- L'intégration continue GitHub Actions vérifie le projet avec Ruby 2.7 à 3.4,
93
- ainsi qu'avec la dernière version stable, Ruby 4.0.
121
+ The default task runs the Minitest suite and builds the gem in `pkg/`. GitHub
122
+ Actions checks the project with Ruby 2.7 through 3.4 and the latest stable
123
+ release, Ruby 4.0.
94
124
 
95
- ## Publication
125
+ ## Publishing
96
126
 
97
- La publication sur RubyGems utilise
98
- [Trusted Publishing](https://guides.rubygems.org/trusted-publishing/) et ne
99
- nécessite aucune clé API dans les secrets GitHub.
127
+ RubyGems releases use
128
+ [Trusted Publishing](https://guides.rubygems.org/trusted-publishing/) and do
129
+ not require an API key in GitHub secrets.
100
130
 
101
- Avant la première publication, créez un *Pending Trusted Publisher* dans votre
102
- profil RubyGems avec les paramètres suivants :
131
+ Before the first release, create a *Pending Trusted Publisher* in your RubyGems
132
+ profile with these settings:
103
133
 
104
- - gem : `callback-collection`
105
- - propriétaire du dépôt : `nicolasva`
106
- - dépôt : `callback-collection`
107
- - workflow : `release.yml`
108
- - environnement GitHub : `release`
134
+ - gem: `callback-collection`
135
+ - repository owner: `nicolasva`
136
+ - repository: `callback-collection`
137
+ - workflow: `release.yml`
138
+ - GitHub environment: `release`
109
139
 
110
- Publiez ensuite une version en poussant le tag correspondant à
111
- `CallbackCollection::VERSION` :
140
+ Release a version by pushing the tag that matches
141
+ `CallbackCollection::VERSION`:
112
142
 
113
143
  ```sh
114
144
  VERSION=$(ruby -Ilib -rcallback_collection/version -e 'print CallbackCollection::VERSION')
@@ -116,6 +146,6 @@ git tag "v${VERSION}"
116
146
  git push origin "v${VERSION}"
117
147
  ```
118
148
 
119
- GitHub Actions construit et publie alors la gem. RubyDoc génère
120
- automatiquement sa documentation, et les badges de version et de
121
- téléchargements deviennent actifs après la première publication.
149
+ GitHub Actions then builds and publishes the gem. RubyDoc generates its
150
+ documentation automatically, and the version and download badges update after
151
+ publication.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class CallbackCollection
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: callback-collection
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicolas Vandenbogaerde
@@ -56,7 +56,7 @@ homepage: https://github.com/nicolasva/callback-collection
56
56
  licenses: []
57
57
  metadata:
58
58
  rubygems_mfa_required: 'true'
59
- documentation_uri: https://www.rubydoc.info/gems/callback-collection/0.2.0
59
+ documentation_uri: https://www.rubydoc.info/gems/callback-collection/0.2.1
60
60
  source_code_uri: https://github.com/nicolasva/callback-collection
61
61
  rdoc_options: []
62
62
  require_paths: