rulezilla 0.4.5 → 0.4.7
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/ci.yaml +1 -1
- data/.github/workflows/publish-docs.yaml +30 -0
- data/.github/workflows/version-forget-me-not.yaml +1 -1
- data/.gitignore +0 -1
- data/.rubocop_todo.yml +10 -11
- data/.ruby-version +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/dsl.rb +2 -0
- data/lib/rulezilla/version.rb +1 -1
- data/mkdocs.yaml +8 -0
- data/rulezilla.gemspec +1 -0
- metadata +21 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6941c7f485cc90010f97357c0662d7dd36c363be4067e02dd83d2e0aa034ab32
|
4
|
+
data.tar.gz: e87b673510615deeb29977215da82d056d17b33870d12982637b9af5f027374d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0dd7029f354b0d45e13a300367cb56c34754e5df15985cef57c4e6c704805b3d1f3474f19c4d38ee83c0df33267cd7c0487e91aedeb711b2763e8c1f18df8a7
|
7
|
+
data.tar.gz: fab0af6a0152a830c58ef882c625e6e25861a3ffcd1a076d407a7592da96ad7abf3d22209cf9ed1575a85d5960fa462549a4cf6a6611cad373103907751540a3
|
data/.github/workflows/ci.yaml
CHANGED
@@ -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/.gitignore
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -1,36 +1,36 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
3
|
+
# on 2025-02-28 15:35:40 UTC using RuboCop version 1.73.1.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
9
|
# Offense count: 1
|
10
|
-
# Configuration parameters: Include.
|
10
|
+
# Configuration parameters: Severity, Include.
|
11
11
|
# Include: **/*.gemspec
|
12
12
|
Gemspec/RequiredRubyVersion:
|
13
13
|
Exclude:
|
14
14
|
- 'rulezilla.gemspec'
|
15
15
|
|
16
16
|
# Offense count: 1
|
17
|
-
# Configuration parameters:
|
17
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
|
18
18
|
Metrics/AbcSize:
|
19
19
|
Max: 20
|
20
20
|
|
21
21
|
# Offense count: 2
|
22
|
-
# Configuration parameters: CountComments, CountAsOne,
|
23
|
-
#
|
22
|
+
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
23
|
+
# AllowedMethods: refine
|
24
24
|
Metrics/BlockLength:
|
25
25
|
Max: 32
|
26
26
|
|
27
27
|
# Offense count: 2
|
28
|
-
# Configuration parameters: CountComments, CountAsOne,
|
28
|
+
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
29
29
|
Metrics/MethodLength:
|
30
30
|
Max: 19
|
31
31
|
|
32
32
|
# Offense count: 3
|
33
|
-
# Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros.
|
33
|
+
# Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros, UseSorbetSigs.
|
34
34
|
# NamePrefix: is_, has_, have_
|
35
35
|
# ForbiddenPrefixes: is_, has_, have_
|
36
36
|
# AllowedMethods: is_a?
|
@@ -41,7 +41,7 @@ Naming/PredicateName:
|
|
41
41
|
- 'lib/rulezilla/node.rb'
|
42
42
|
- 'lib/rulezilla/tree.rb'
|
43
43
|
|
44
|
-
# Offense count:
|
44
|
+
# Offense count: 5
|
45
45
|
# Configuration parameters: AllowedConstants.
|
46
46
|
Style/Documentation:
|
47
47
|
Exclude:
|
@@ -51,11 +51,10 @@ Style/Documentation:
|
|
51
51
|
- 'lib/rulezilla/dsl.rb'
|
52
52
|
- 'lib/rulezilla/node.rb'
|
53
53
|
- 'lib/rulezilla/tree.rb'
|
54
|
-
- 'lib/rulezilla/version.rb'
|
55
54
|
|
56
|
-
# Offense count:
|
55
|
+
# Offense count: 2
|
56
|
+
# This cop supports safe autocorrection (--autocorrect).
|
57
57
|
# Configuration parameters: MinBodyLength, AllowConsecutiveConditionals.
|
58
58
|
Style/GuardClause:
|
59
59
|
Exclude:
|
60
60
|
- 'lib/rulezilla/dsl.rb'
|
61
|
-
- 'rulezilla.gemspec'
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.1
|
1
|
+
3.4.1
|
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/dsl.rb
CHANGED
data/lib/rulezilla/version.rb
CHANGED
data/mkdocs.yaml
ADDED
data/rulezilla.gemspec
CHANGED
metadata
CHANGED
@@ -1,15 +1,28 @@
|
|
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.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simply Business
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-02-28 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
12
|
+
- !ruby/object:Gem::Dependency
|
13
|
+
name: ostruct
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - ">="
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '0'
|
19
|
+
type: :runtime
|
20
|
+
prerelease: false
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
requirements:
|
23
|
+
- - ">="
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: '0'
|
13
26
|
- !ruby/object:Gem::Dependency
|
14
27
|
name: rspec
|
15
28
|
requirement: !ruby/object:Gem::Requirement
|
@@ -91,6 +104,7 @@ files:
|
|
91
104
|
- ".github/workflows/codeql-analysis.yaml"
|
92
105
|
- ".github/workflows/dobby-actions.yml"
|
93
106
|
- ".github/workflows/gem-publish.yaml"
|
107
|
+
- ".github/workflows/publish-docs.yaml"
|
94
108
|
- ".github/workflows/version-forget-me-not.yaml"
|
95
109
|
- ".gitignore"
|
96
110
|
- ".rspec"
|
@@ -101,13 +115,16 @@ files:
|
|
101
115
|
- Gemfile
|
102
116
|
- LICENSE.txt
|
103
117
|
- README.md
|
118
|
+
- _pipeline/stage_publishdocs.yml
|
104
119
|
- catalog-info.yaml
|
120
|
+
- docs/index.md
|
105
121
|
- lib/rulezilla.rb
|
106
122
|
- lib/rulezilla/basic_support.rb
|
107
123
|
- lib/rulezilla/dsl.rb
|
108
124
|
- lib/rulezilla/node.rb
|
109
125
|
- lib/rulezilla/tree.rb
|
110
126
|
- lib/rulezilla/version.rb
|
127
|
+
- mkdocs.yaml
|
111
128
|
- rulezilla.gemspec
|
112
129
|
- spec/features/default_support_methods.feature
|
113
130
|
- spec/features/rulezilla_dsl_framework.feature
|
@@ -117,7 +134,6 @@ homepage: https://github.com/simplybusiness/rulezilla
|
|
117
134
|
licenses:
|
118
135
|
- MIT
|
119
136
|
metadata: {}
|
120
|
-
post_install_message:
|
121
137
|
rdoc_options: []
|
122
138
|
require_paths:
|
123
139
|
- lib
|
@@ -132,8 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
132
148
|
- !ruby/object:Gem::Version
|
133
149
|
version: '0'
|
134
150
|
requirements: []
|
135
|
-
rubygems_version: 3.
|
136
|
-
signing_key:
|
151
|
+
rubygems_version: 3.6.2
|
137
152
|
specification_version: 4
|
138
153
|
summary: Rules DSL
|
139
154
|
test_files: []
|