rulezilla 0.4.4 → 0.4.6
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/.github/workflows/publish-docs.yaml +30 -0
- data/.github/workflows/version-forget-me-not.yaml +1 -1
- data/README.md +1 -115
- data/_pipeline/stage_publishdocs.yml +9 -0
- data/catalog-info.yaml +3 -1
- data/docs/index.md +115 -0
- data/lib/rulezilla/version.rb +1 -1
- data/mkdocs.yaml +8 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25e5e96ef53b4b3ba95b4e6fb01b0ff0536471199a6abbaf550f3051efce97f4
|
4
|
+
data.tar.gz: fa6e29ebec3ed0f5e11efdc2d36124bba8c13fda83eadf85ae2b72508c674a90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9cae51299b0c421375b732273a5fb27e34f6a4429f567a5f6f8ba4ed653b9acfaad99f980ac2099f82591c1cc14971af42829280d47feecc1f0c1d923ed0d867
|
7
|
+
data.tar.gz: 83c14cb9fd566df2f86dd55c7eddb72ff4675be453c3fdf0a162346d0d4e9a2afb96ef004e45faf32571a7c837a4f0bbfc1e69042e4f9d8c1dd5704a5ac48851
|
@@ -0,0 +1,30 @@
|
|
1
|
+
name: Huxley TechDocs
|
2
|
+
|
3
|
+
on:
|
4
|
+
workflow_dispatch:
|
5
|
+
push:
|
6
|
+
branches: master
|
7
|
+
paths:
|
8
|
+
- "docs/**"
|
9
|
+
- "mkdocs.yml"
|
10
|
+
- ".github/workflows/publish-docs.yaml"
|
11
|
+
pull_request:
|
12
|
+
branches: master
|
13
|
+
paths:
|
14
|
+
- "docs/**"
|
15
|
+
- "mkdocs.yaml"
|
16
|
+
- ".github/workflows/publish-docs.yaml"
|
17
|
+
schedule:
|
18
|
+
- cron: "15 3 1 * *"
|
19
|
+
|
20
|
+
concurrency: huxley-techdocs-${{ github.ref }}
|
21
|
+
|
22
|
+
jobs:
|
23
|
+
publish-techdocs:
|
24
|
+
uses: simplybusiness/github-action-reusable-workflows/.github/workflows/techdocs.yaml@v1
|
25
|
+
with:
|
26
|
+
repo: "github-action-reusable-workflows"
|
27
|
+
secrets:
|
28
|
+
region: ${{ secrets.AWS_LIVE_CICD_REGION }}
|
29
|
+
aws-access-key-id: ${{ secrets.AWS_LIVE_CICD_ACCESS_KEY_ID }}
|
30
|
+
aws-secret-access-key: ${{ secrets.AWS_LIVE_CICD_SECRET_ACCESS_KEY }}
|
data/README.md
CHANGED
@@ -1,115 +1 @@
|
|
1
|
-
[
|
2
|
-
[](https://codeclimate.com/repos/53ecc0416956800c1d01f6bf/feed)
|
3
|
-
[](http://badge.fury.io/rb/rulezilla)
|
4
|
-
|
5
|
-
rulezilla
|
6
|
-
=========
|
7
|
-
|
8
|
-
This provides a DSL to implement rules for various tasks. In the current version we are still relying on user to have a certain level of Ruby knowledge
|
9
|
-
in order to be able to use this DSL. The ultimate goal is for people without prior Ruby knowledge to be able to change and even write the Rule.
|
10
|
-
|
11
|
-
|
12
|
-
# Installation
|
13
|
-
|
14
|
-
## Using `Gemfile`
|
15
|
-
|
16
|
-
Add the following line to your `Gemfile`:
|
17
|
-
|
18
|
-
gem 'rulezilla'
|
19
|
-
|
20
|
-
Then run:
|
21
|
-
|
22
|
-
bundle install
|
23
|
-
|
24
|
-
## Without `Gemfile`
|
25
|
-
|
26
|
-
On your command line run the following:
|
27
|
-
|
28
|
-
gem install 'rulezilla'
|
29
|
-
|
30
|
-
## Usage
|
31
|
-
|
32
|
-
### Rules
|
33
|
-
|
34
|
-
Rules are defined in Ruby. Rules are classes that include the `Rulezilla::DSL`.
|
35
|
-
|
36
|
-
#### Ruby
|
37
|
-
|
38
|
-
You can use plain Ruby to define the rule classes. But you will need to include the `Rulezilla::DSL` module. That will give you access to the DSL used to define rules.
|
39
|
-
|
40
|
-
Here is an example:
|
41
|
-
|
42
|
-
class RoboticsRule
|
43
|
-
include Rulezilla::DSL
|
44
|
-
|
45
|
-
group :may_not_injure_human do
|
46
|
-
condition { not_injure_human? }
|
47
|
-
|
48
|
-
group :obey_human do
|
49
|
-
condition { do_as_human_told? }
|
50
|
-
|
51
|
-
define :protect_its_own_existence do
|
52
|
-
condition { protect_itself? }
|
53
|
-
result(true)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
default(false)
|
59
|
-
|
60
|
-
end
|
61
|
-
|
62
|
-
Please refer to the [feature](spec/features/rulezilla_dsl_framework.feature) for further details of the DSL.
|
63
|
-
|
64
|
-
### Support Module
|
65
|
-
|
66
|
-
The support module will be automatically included if its name is `"#{rule_class_name}Support"`
|
67
|
-
|
68
|
-
e.g. if the rule class name is `RoboticsRule`, then the support would be `RoboticsRuleSupport`
|
69
|
-
|
70
|
-
module RoboticsRuleSupport
|
71
|
-
def protect_itself?
|
72
|
-
in_danger? && not_letting_itself_be_detroyed?
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
### How to execute the rule
|
77
|
-
|
78
|
-
If the entity is:
|
79
|
-
|
80
|
-
entity = {
|
81
|
-
not_injure_human?: true,
|
82
|
-
do_as_human_told?: true,
|
83
|
-
in_danger?: true,
|
84
|
-
not_letting_itself_be_detroyed?: true
|
85
|
-
}
|
86
|
-
|
87
|
-
#### To get the first matching result output
|
88
|
-
|
89
|
-
RoboticsRule.apply(entity) #=> true
|
90
|
-
|
91
|
-
#### To get all matching result outputs
|
92
|
-
|
93
|
-
RoboticsRule.all(entity) #=> [true, false]
|
94
|
-
|
95
|
-
Note that `false` is the result outcome coming out from `default(false)` on top level, which is also called `root node`. The `root` node does not have any condition and hence
|
96
|
-
it is considered to be matching. This means, by consequence, that its result (`default(false)`) is included in the list of matching result outputs which `#all(entity)` above
|
97
|
-
returns.
|
98
|
-
|
99
|
-
#### To get the trace of all nodes
|
100
|
-
|
101
|
-
RoboticsRule.trace(entity)
|
102
|
-
#=> all the nodes instance: [root, may_not_injure_human, obey_human, protect_its_own_existence] in sequence order.
|
103
|
-
|
104
|
-
#### To get all results from the Rule
|
105
|
-
|
106
|
-
RoboticsRule.results #=> [true, false]
|
107
|
-
|
108
|
-
|
109
|
-
### Syntax
|
110
|
-
|
111
|
-
Please refer to the features for DSL syntax:
|
112
|
-
|
113
|
-
[DSL Feature](spec/features/rulezilla_dsl_framework.feature),
|
114
|
-
|
115
|
-
[Default Support Methods Feature](spec/features/default_support_methods.feature)
|
1
|
+
All documentation is now in the `docs/` subdirectory, or can be viewed in rendered form on Backstage. Start with the [index](docs/index.md)
|
data/catalog-info.yaml
CHANGED
data/docs/index.md
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
[](https://semaphoreci.com/simplybusiness/rulezilla)
|
2
|
+
[](https://codeclimate.com/repos/53ecc0416956800c1d01f6bf/feed)
|
3
|
+
[](http://badge.fury.io/rb/rulezilla)
|
4
|
+
|
5
|
+
rulezilla
|
6
|
+
=========
|
7
|
+
|
8
|
+
This provides a DSL to implement rules for various tasks. In the current version we are still relying on user to have a certain level of Ruby knowledge
|
9
|
+
in order to be able to use this DSL. The ultimate goal is for people without prior Ruby knowledge to be able to change and even write the Rule.
|
10
|
+
|
11
|
+
|
12
|
+
# Installation
|
13
|
+
|
14
|
+
## Using `Gemfile`
|
15
|
+
|
16
|
+
Add the following line to your `Gemfile`:
|
17
|
+
|
18
|
+
gem 'rulezilla'
|
19
|
+
|
20
|
+
Then run:
|
21
|
+
|
22
|
+
bundle install
|
23
|
+
|
24
|
+
## Without `Gemfile`
|
25
|
+
|
26
|
+
On your command line run the following:
|
27
|
+
|
28
|
+
gem install 'rulezilla'
|
29
|
+
|
30
|
+
## Usage
|
31
|
+
|
32
|
+
### Rules
|
33
|
+
|
34
|
+
Rules are defined in Ruby. Rules are classes that include the `Rulezilla::DSL`.
|
35
|
+
|
36
|
+
#### Ruby
|
37
|
+
|
38
|
+
You can use plain Ruby to define the rule classes. But you will need to include the `Rulezilla::DSL` module. That will give you access to the DSL used to define rules.
|
39
|
+
|
40
|
+
Here is an example:
|
41
|
+
|
42
|
+
class RoboticsRule
|
43
|
+
include Rulezilla::DSL
|
44
|
+
|
45
|
+
group :may_not_injure_human do
|
46
|
+
condition { not_injure_human? }
|
47
|
+
|
48
|
+
group :obey_human do
|
49
|
+
condition { do_as_human_told? }
|
50
|
+
|
51
|
+
define :protect_its_own_existence do
|
52
|
+
condition { protect_itself? }
|
53
|
+
result(true)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
default(false)
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
Please refer to the [feature](spec/features/rulezilla_dsl_framework.feature) for further details of the DSL.
|
63
|
+
|
64
|
+
### Support Module
|
65
|
+
|
66
|
+
The support module will be automatically included if its name is `"#{rule_class_name}Support"`
|
67
|
+
|
68
|
+
e.g. if the rule class name is `RoboticsRule`, then the support would be `RoboticsRuleSupport`
|
69
|
+
|
70
|
+
module RoboticsRuleSupport
|
71
|
+
def protect_itself?
|
72
|
+
in_danger? && not_letting_itself_be_detroyed?
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
### How to execute the rule
|
77
|
+
|
78
|
+
If the entity is:
|
79
|
+
|
80
|
+
entity = {
|
81
|
+
not_injure_human?: true,
|
82
|
+
do_as_human_told?: true,
|
83
|
+
in_danger?: true,
|
84
|
+
not_letting_itself_be_detroyed?: true
|
85
|
+
}
|
86
|
+
|
87
|
+
#### To get the first matching result output
|
88
|
+
|
89
|
+
RoboticsRule.apply(entity) #=> true
|
90
|
+
|
91
|
+
#### To get all matching result outputs
|
92
|
+
|
93
|
+
RoboticsRule.all(entity) #=> [true, false]
|
94
|
+
|
95
|
+
Note that `false` is the result outcome coming out from `default(false)` on top level, which is also called `root node`. The `root` node does not have any condition and hence
|
96
|
+
it is considered to be matching. This means, by consequence, that its result (`default(false)`) is included in the list of matching result outputs which `#all(entity)` above
|
97
|
+
returns.
|
98
|
+
|
99
|
+
#### To get the trace of all nodes
|
100
|
+
|
101
|
+
RoboticsRule.trace(entity)
|
102
|
+
#=> all the nodes instance: [root, may_not_injure_human, obey_human, protect_its_own_existence] in sequence order.
|
103
|
+
|
104
|
+
#### To get all results from the Rule
|
105
|
+
|
106
|
+
RoboticsRule.results #=> [true, false]
|
107
|
+
|
108
|
+
|
109
|
+
### Syntax
|
110
|
+
|
111
|
+
Please refer to the features for DSL syntax:
|
112
|
+
|
113
|
+
[DSL Feature](spec/features/rulezilla_dsl_framework.feature),
|
114
|
+
|
115
|
+
[Default Support Methods Feature](spec/features/default_support_methods.feature)
|
data/lib/rulezilla/version.rb
CHANGED
data/mkdocs.yaml
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rulezilla
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simply Business
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -91,6 +91,7 @@ files:
|
|
91
91
|
- ".github/workflows/codeql-analysis.yaml"
|
92
92
|
- ".github/workflows/dobby-actions.yml"
|
93
93
|
- ".github/workflows/gem-publish.yaml"
|
94
|
+
- ".github/workflows/publish-docs.yaml"
|
94
95
|
- ".github/workflows/version-forget-me-not.yaml"
|
95
96
|
- ".gitignore"
|
96
97
|
- ".rspec"
|
@@ -101,13 +102,16 @@ files:
|
|
101
102
|
- Gemfile
|
102
103
|
- LICENSE.txt
|
103
104
|
- README.md
|
105
|
+
- _pipeline/stage_publishdocs.yml
|
104
106
|
- catalog-info.yaml
|
107
|
+
- docs/index.md
|
105
108
|
- lib/rulezilla.rb
|
106
109
|
- lib/rulezilla/basic_support.rb
|
107
110
|
- lib/rulezilla/dsl.rb
|
108
111
|
- lib/rulezilla/node.rb
|
109
112
|
- lib/rulezilla/tree.rb
|
110
113
|
- lib/rulezilla/version.rb
|
114
|
+
- mkdocs.yaml
|
111
115
|
- rulezilla.gemspec
|
112
116
|
- spec/features/default_support_methods.feature
|
113
117
|
- spec/features/rulezilla_dsl_framework.feature
|