Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions bpmn/lib/bpmn/execution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def evaluate_expression(expression, variables: parent&.variables || {}.with_indi
return nil if expression.nil?

if expression.start_with?("=")
DMN.evaluate(expression.delete_prefix("="), variables: variables)
FEEL.evaluate(expression.delete_prefix("="), variables: variables)
else
expression
end
Expand Down Expand Up @@ -393,10 +393,14 @@ def print_children
end

def print_child(child, index)
str = "#{index} #{child.step.class.name.demodulize} #{child.step.id}: #{child.status} #{JSON.pretty_generate(child.variables, { indent: '', object_nl: ' ' }) unless child.variables.empty? }".strip
vars = child.variables.empty? ? '' : JSON.pretty_generate(child.variables, { indent: '', object_nl: ' ' })
name = child.step.name.present? ? " <#{child.step.name}>" : ""

str = "#{index} #{child.step.class.name.demodulize} #{child.step.id}#{name}: #{child.status} #{vars}".strip
str = "#{str} * in: #{child.tokens_in.join(', ')}" if child.tokens_in.present?
str = "#{str} * out: #{child.tokens_out.join(', ')}" if child.tokens_out.present?
puts str

child.children.each_with_index do |grandchild, grandindex|
print_child(grandchild, "#{index}.#{grandindex}")
end
Expand Down
2 changes: 1 addition & 1 deletion dmn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

A light-weight DMN (Decision Model and Notation) business rule ruby gem.

This gem depends on the [FEEL](https://github.com/connectedbits/bpmn/tree/main/feel) gem to evaluate DMN decision tables and expressions.
This gem depends on the [FEEL](https://github.com/connectedbits/workflow-kit/tree/main/feel) gem to evaluate DMN decision tables and expressions.

## Usage

Expand Down
12 changes: 0 additions & 12 deletions dmn/lib/dmn.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,6 @@ module DMN
class SyntaxError < StandardError; end
class EvaluationError < StandardError; end

def self.evaluate(expression_text, variables: {})
literal_expression = FEEL::LiteralExpression.new(text: expression_text)
raise SyntaxError, "Expression is not valid" unless literal_expression.valid?
literal_expression.evaluate(variables)
end

def self.test(input, unary_tests_text, variables: {})
unary_tests = FEEL::UnaryTests.new(text: unary_tests_text)
raise SyntaxError, "Unary tests are not valid" unless unary_tests.valid?
unary_tests.test(input, variables)
end

def self.decide(decision_id, definitions: nil, definitions_json: nil, definitions_xml: nil, variables: {})
if definitions_xml.present?
definitions = DMN::Definitions.from_xml(definitions_xml)
Expand Down
6 changes: 5 additions & 1 deletion feel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Calling a user-defined function:
FEEL.config.functions = {
"reverse": ->(s) { s.reverse }
}
DMN.evaluate('reverse("Hello World!")', functions:)
FEEL.evaluate('reverse("Hello World!")')
# => "!dlroW olleH"
```

Expand Down Expand Up @@ -138,6 +138,10 @@ UnaryTests.new(text: '> speed - speed_limit').variable_names
- [x] Context: `get entries`, `get value`, `get keys`
- [x] Temporal: `now`, `today`, `day of week`, `day of year`, `month of year`, `week of year`

### Comments
- [ ] Single-line
- [ ] Multi-line

## Installation

Execute:
Expand Down
4 changes: 2 additions & 2 deletions feel/lib/feel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ class EvaluationError < StandardError; end

def self.evaluate(expression_text, variables: {})
literal_expression = FEEL::LiteralExpression.new(text: expression_text)
raise SyntaxError, "Expression is not valid" unless literal_expression.valid?
raise SyntaxError, "Expression is not valid: #{expression_text}" unless literal_expression.valid?
literal_expression.evaluate(variables)
end

def self.test(input, unary_tests_text, variables: {})
unary_tests = FEEL::UnaryTests.new(text: unary_tests_text)
raise SyntaxError, "Unary tests are not valid" unless unary_tests.valid?
raise SyntaxError, "Unary tests are not valid: #{unary_tests_text}" unless unary_tests.valid?
unary_tests.test(input, variables)
end

Expand Down