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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 46d129da8737c28750b4aa51f1234bbce39b047eac599d248735ae6b5eff199c
4
- data.tar.gz: 045e55121094f5e8a5a2cb2512b745c2d82c9de7f3dc0fcb5d1f9fbe88764683
3
+ metadata.gz: 243e6f2e2f7f65919f41fae1eddf877796e6221674e41dc5d32a36c708efab03
4
+ data.tar.gz: 8649def0a1299dd416d00480daa9fb0dfe3b6e418c4ea6c1ad869c873ad3eedf
5
5
  SHA512:
6
- metadata.gz: 207e8e9c14f083c660af9d16e418f8f7b2ee753989adb22c107acfb062bdedb334160a7978f6ad33dce463dd8faee6b7016068689f0c3678ebf52d117328cef2
7
- data.tar.gz: 7cddb20e40da3b55361281abaebd37a12276b1e4e6418453aa4f199ec680eaff714060411f0b0b5a3faf0e199161f3dddc3f2c94da2bd8e3a3e2e2ec4321a871
6
+ metadata.gz: e677d95d1ef34f8144b1f829259ad716e8f3822ab216957cf34a0058b4f7651843232202dc485a62e4c44077761a91b4db419963b649fae4a429042bf49be410
7
+ data.tar.gz: 3e7795238333d362f35c71b9478b01f4ff396110dc517a320dc304288a1ab8deac0a3af8b99c3d8f87cfd47a9a91f1bbd46509eb0055db4faa042b9b6ca14bd9
data/README.md CHANGED
@@ -1,9 +1,22 @@
1
1
  # Kumi
2
2
 
3
+ [![CI](https://github.com/amuta/kumi/workflows/CI/badge.svg)](https://github.com/amuta/kumi/actions)
4
+ [![Gem Version](https://badge.fury.io/rb/kumi.svg)](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:**
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Kumi
2
4
  EvaluationWrapper = Struct.new(:ctx) do
3
5
  def initialize(ctx)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kumi
4
- VERSION = "0.0.3"
4
+ VERSION = "0.0.4"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kumi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - André Muta