kumi 0.0.3 → 0.0.4
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/README.md +13 -0
- data/lib/kumi/evaluation_wrapper.rb +2 -0
- data/lib/kumi/explain.rb +1 -2
- data/lib/kumi/function_registry/string_functions.rb +1 -1
- data/lib/kumi/parser/guard_rails.rb +2 -2
- data/lib/kumi/parser/schema_builder.rb +1 -1
- data/lib/kumi/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 243e6f2e2f7f65919f41fae1eddf877796e6221674e41dc5d32a36c708efab03
|
4
|
+
data.tar.gz: 8649def0a1299dd416d00480daa9fb0dfe3b6e418c4ea6c1ad869c873ad3eedf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e677d95d1ef34f8144b1f829259ad716e8f3822ab216957cf34a0058b4f7651843232202dc485a62e4c44077761a91b4db419963b649fae4a429042bf49be410
|
7
|
+
data.tar.gz: 3e7795238333d362f35c71b9478b01f4ff396110dc517a320dc304288a1ab8deac0a3af8b99c3d8f87cfd47a9a91f1bbd46509eb0055db4faa042b9b6ca14bd9
|
data/README.md
CHANGED
@@ -1,9 +1,22 @@
|
|
1
1
|
# Kumi
|
2
2
|
|
3
|
+
[](https://github.com/amuta/kumi/actions)
|
4
|
+
[](https://badge.fury.io/rb/kumi)
|
5
|
+
|
3
6
|
Kumi is a declarative rule‑and‑calculation DSL for Ruby that turns scattered business logic into a statically‑checked dependency graph.
|
4
7
|
|
5
8
|
Every input, trait, and formula is compiled into a typed AST node, so the entire graph is explicit and introspectable.
|
6
9
|
|
10
|
+
Note: The examples here are small for the sake of readability. I would not recommend using this gem unless you need to keep track of 100+ conditions/variables.
|
11
|
+
|
12
|
+
|
13
|
+
## How to get started
|
14
|
+
|
15
|
+
Install Kumi and try running the examples below or explore the `./examples` directory of this repository.
|
16
|
+
```
|
17
|
+
gem install kumi
|
18
|
+
```
|
19
|
+
|
7
20
|
## Example
|
8
21
|
|
9
22
|
**Instead of scattered logic:**
|
data/lib/kumi/explain.rb
CHANGED
@@ -85,7 +85,6 @@ module Kumi
|
|
85
85
|
end
|
86
86
|
evaluated_format = evaluated_operands.join(" #{get_operator_symbol(fn_name)} ")
|
87
87
|
|
88
|
-
"#{symbolic_format} = #{evaluated_format}"
|
89
88
|
else
|
90
89
|
# Regular pretty formatting for non-chain expressions
|
91
90
|
symbolic_args = expr.args.map { |arg| format_expression(arg, indent_context: 0, nested: true) }
|
@@ -106,8 +105,8 @@ module Kumi
|
|
106
105
|
end
|
107
106
|
evaluated_format = get_display_format(fn_name, evaluated_args)
|
108
107
|
|
109
|
-
"#{symbolic_format} = #{evaluated_format}"
|
110
108
|
end
|
109
|
+
"#{symbolic_format} = #{evaluated_format}"
|
111
110
|
else
|
112
111
|
# For nested expressions, just show the symbolic form without evaluation details
|
113
112
|
args = expr.args.map { |arg| format_expression(arg, indent_context: 0, nested: true) }
|
@@ -34,7 +34,7 @@ module Kumi
|
|
34
34
|
string_include?: FunctionBuilder.string_binary(:include?, "Check if string contains substring", :include?, return_type: :boolean),
|
35
35
|
includes?: FunctionBuilder.string_binary(:include?, "Check if string contains substring", :include?, return_type: :boolean),
|
36
36
|
contains?: FunctionBuilder.string_binary(:include?, "Check if string contains substring", :include?, return_type: :boolean),
|
37
|
-
|
37
|
+
|
38
38
|
start_with?: FunctionBuilder.string_binary(:start_with?, "Check if string starts with prefix", :start_with?,
|
39
39
|
return_type: :boolean),
|
40
40
|
end_with?: FunctionBuilder.string_binary(:end_with?, "Check if string ends with suffix", :end_with?, return_type: :boolean),
|
@@ -16,13 +16,13 @@ module Kumi
|
|
16
16
|
# Check if this is a redefinition by looking at the call stack
|
17
17
|
# We want to allow the original definition but prevent redefinition
|
18
18
|
calling_location = caller_locations(1, 1).first
|
19
|
-
|
19
|
+
|
20
20
|
# Allow the original definition from schema_builder.rb
|
21
21
|
if calling_location&.path&.include?("schema_builder.rb")
|
22
22
|
super
|
23
23
|
return
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
# This is a redefinition attempt, prevent it
|
27
27
|
raise Kumi::Errors::SemanticError,
|
28
28
|
"DSL keyword `#{name}` is reserved; " \
|
@@ -73,7 +73,7 @@ module Kumi
|
|
73
73
|
# Use caller_locations(2, 1) to skip the DSL method and get the actual user code location
|
74
74
|
# Stack: [0] update_location, [1] DSL method (value/trait/etc), [2] user's DSL code
|
75
75
|
caller_location = caller_locations(2, 1).first
|
76
|
-
|
76
|
+
|
77
77
|
@context.current_location = Location.new(
|
78
78
|
file: caller_location.path,
|
79
79
|
line: caller_location.lineno,
|
data/lib/kumi/version.rb
CHANGED