philiprehberger-rule_engine 0.4.0 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6632ea70fd2a2bd623fdbd89fdd2f1a399254742af0fc9dd737ac3fae82c9e04
4
- data.tar.gz: 67207e22ad77f60478e22343957f298bd1c431cb5c8410688087b54bb65b1004
3
+ metadata.gz: 2026fcc1381bc79e330be05f98fc32579e148927732b54f6d77b77361961fead
4
+ data.tar.gz: add66f1853785eefe6ec55ab5f365396ef991092429e0695025e79b97d64ced3
5
5
  SHA512:
6
- metadata.gz: 4b32d00eedfedbf1e00d49ec7728594d86b222f047135dfd3acbd3d485ff72900b1271e91ac4c358ee40e54f76ffad646e39a3cf939155c9487ac31a4e321087
7
- data.tar.gz: 7b9d1b7ef2d0173e1c7385f05b3c3af4db9b7af7c0d1afbc7e6cde4aaa042d47b09fa973509613419bbcf2960ab0749138a2f2318bf842c7321b8bfa6fe45dce
6
+ metadata.gz: e9e1dd6aa851778dd10fa1b8b953571b99222cb557c0c68553102884abe05a07e742efad8eabea6c6527289692fb81c14acafeb764e90c77c2d90d3e8b47a13e
7
+ data.tar.gz: 534e0b19a5bd9f986ec474b4a789aa7efa46a3512e970f3df32056aed4954f749744610281c54409aa3a8d544f5142a51497c43a3aff9e72f311b2e6532d91c7
data/CHANGELOG.md CHANGED
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.5.0] - 2026-04-22
11
+
12
+ ### Added
13
+ - `Engine#clear_rules!` — remove all rules and reset statistics in one call.
14
+ - `Engine#rule_names` — return an array of rule names in declaration order.
15
+
10
16
  ## [0.4.0] - 2026-04-10
11
17
 
12
18
  ### Added
@@ -57,6 +63,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
57
63
  - Rule evaluation against arbitrary facts
58
64
  - Results with rule name and action output
59
65
 
66
+ [0.5.0]: https://github.com/philiprehberger/rb-rule-engine/releases/tag/v0.5.0
60
67
  [0.4.0]: https://github.com/philiprehberger/rb-rule-engine/releases/tag/v0.4.0
61
68
  [0.3.0]: https://github.com/philiprehberger/rb-rule-engine/releases/tag/v0.3.0
62
69
  [0.2.1]: https://github.com/philiprehberger/rb-rule-engine/releases/tag/v0.2.1
data/README.md CHANGED
@@ -141,6 +141,9 @@ engine.enable_rule('dynamic')
141
141
  engine.evaluate({ ready: true }) # => [{ rule: 'dynamic', result: 'go' }]
142
142
 
143
143
  engine.remove_rule('dynamic')
144
+
145
+ engine.rule_names # => []
146
+ engine.clear_rules! # removes all rules and resets stats
144
147
  ```
145
148
 
146
149
  ### Rule Chaining
@@ -240,6 +243,8 @@ end
240
243
  | `#to_h` | Serialize engine configuration to hash |
241
244
  | `#add_rule(name) { }` | Add a rule after engine creation |
242
245
  | `#remove_rule(name)` | Remove a rule by name |
246
+ | `Engine#clear_rules!` | Remove all rules and reset statistics |
247
+ | `Engine#rule_names` | Return an array of rule names in declaration order |
243
248
  | `#disable_rule(name)` | Disable a rule (skipped during evaluation) |
244
249
  | `#enable_rule(name)` | Re-enable a disabled rule |
245
250
  | `#chain(*rule_names)` | Execute rules sequentially as a pipeline |
@@ -91,6 +91,25 @@ module Philiprehberger
91
91
  @rules.select { |r| r.tags.include?(tag.to_sym) }
92
92
  end
93
93
 
94
+ # Remove all rules and reset execution statistics.
95
+ #
96
+ # Clears the internal rule list and discards all per-rule stat entries,
97
+ # returning the engine to a fresh state while preserving its mode.
98
+ #
99
+ # @return [self] the engine, for chaining
100
+ def clear_rules!
101
+ @rules.clear
102
+ @stats.clear
103
+ self
104
+ end
105
+
106
+ # Return the names of all registered rules in declaration order.
107
+ #
108
+ # @return [Array<String>] rule names in the order they were added
109
+ def rule_names
110
+ @rules.map(&:name)
111
+ end
112
+
94
113
  # Evaluate all rules against the given facts.
95
114
  #
96
115
  # @param facts [Object] the facts to evaluate
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Philiprehberger
4
4
  module RuleEngine
5
- VERSION = '0.4.0'
5
+ VERSION = '0.5.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: philiprehberger-rule_engine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philip Rehberger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-04-10 00:00:00.000000000 Z
11
+ date: 2026-04-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A lightweight rule engine with a declarative DSL for defining conditions
14
14
  and actions. Supports priority-based ordering, rule tagging with selective evaluation,