equation 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -0
- data/lib/equation.rb +8 -6
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc3a0622cdb38f0db990030f8ec8b9c70fec671e1dbe5d26167787e272ed4bbc
|
4
|
+
data.tar.gz: 1c4ca3a83d2cb17b0fb954f84ed53ae6f919aef866a05cb87ea219092cf13165
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: edf2c16a123be3141a6757b95423fae213ee3b5028f48ea00fab72a75cb5bf1bd3d19ba4f7509466b9f8bfc4a5f572e0781beff8d5d152dc9b7d0d9e660dff8d
|
7
|
+
data.tar.gz: e3d07dc903426b9d718b0cd4d32cfefd08e2eeb09ab5069079fc95100302a74f0ae526a96d618827810d4834a0cbe5e98f7371b43ef20916f264f3aba423a109
|
data/README.md
CHANGED
@@ -10,6 +10,9 @@ Use cases include:
|
|
10
10
|
|
11
11
|
Modeled loosely after [Symfony Expression Language](https://symfony.com/doc/current/components/expression_language.html).
|
12
12
|
|
13
|
+
## Demos
|
14
|
+
|
15
|
+
Take a look at the examples directory for some demonstrations of Equation's capabilities. The main example is a [web application firewall](https://github.com/ancat/equation/tree/main/examples/rails_waf) for Rails; rules can be managed from any ActiveStorage compatible backend (e.g. filesystem, Amazon AWS, etc) and updated independently of application code, allowing for faster and more expressive blocking logic without having to wait for a deploy to go through.
|
13
16
|
|
14
17
|
## Example
|
15
18
|
|
data/lib/equation.rb
CHANGED
@@ -19,13 +19,15 @@ class Context
|
|
19
19
|
assert_defined!(identifier: identifier)
|
20
20
|
child = symbols[identifier.to_sym]
|
21
21
|
path.each{|segment|
|
22
|
-
segment_name = segment.elements[1].text_value
|
23
|
-
if child.respond_to?(segment_name)
|
24
|
-
child = child.send(segment_name)
|
25
|
-
elsif child.include?(segment_name)
|
26
|
-
child = child[segment_name]
|
22
|
+
segment_name = segment.elements[1].text_value
|
23
|
+
if child.respond_to?(segment_name.to_sym)
|
24
|
+
child = child.send(segment_name.to_sym)
|
25
|
+
elsif child.is_a? Hash and child.include?(segment_name.to_sym)
|
26
|
+
child = child[segment_name.to_sym]
|
27
|
+
elsif child.is_a? Hash and child.include?(segment_name.to_s)
|
28
|
+
child = child[segment_name.to_s]
|
27
29
|
else
|
28
|
-
|
30
|
+
return nil
|
29
31
|
end
|
30
32
|
}
|
31
33
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: equation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- OMAR
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Equation exposes a minimal environment to allow safe execution of Ruby
|
14
14
|
code represented via a custom expression language.
|
@@ -40,7 +40,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
requirements: []
|
43
|
-
rubygems_version: 3.
|
43
|
+
rubygems_version: 3.1.6
|
44
44
|
signing_key:
|
45
45
|
specification_version: 4
|
46
46
|
summary: A rules engine for your Ruby apps.
|