aristotle 0.2.0 → 0.2.1
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/app/logic/test.logic +25 -0
- data/test/test_aristotle.rb +67 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c1d907da31b330af457d62abfc97661db64d65d
|
4
|
+
data.tar.gz: bded9bf0b597e36a730749fbf5ff4987a4734481
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd4eff834e89b79e76c0489a6103b8de898b0c52c44b6848c54e45df50c0776d4c55d5fb6125297725e489458f0f5f1d634c80e373485c20a57e1bc0798aa29d
|
7
|
+
data.tar.gz: 894dbe8c782f0ec6e5517f811e8ff02a18c01a54e719d7fc989bc1a3883c235f6d9f952f1f61092bb733ffa02f7bb54add674081de95277190ba9849eb3629fc
|
@@ -0,0 +1,25 @@
|
|
1
|
+
Nothing matches
|
2
|
+
Go to a bar if this won't match
|
3
|
+
Do something else if nothing happens
|
4
|
+
Do a third thing if all hell breaks loose
|
5
|
+
|
6
|
+
Things not defined
|
7
|
+
Go to a bar if this won't match
|
8
|
+
Do something else if this is not found anywhere
|
9
|
+
Do a third thing if all hell breaks loose
|
10
|
+
|
11
|
+
Return on second
|
12
|
+
Return 1 if this won't match
|
13
|
+
Return 2 if this matches
|
14
|
+
Return 3 if this won't match
|
15
|
+
|
16
|
+
Return only the first
|
17
|
+
Return 1 if this matches
|
18
|
+
Return 2 if this matches
|
19
|
+
Return 3 if this won't match
|
20
|
+
|
21
|
+
Test payload
|
22
|
+
Return payload if this matches
|
23
|
+
|
24
|
+
Test condition regexp
|
25
|
+
Return payload if this is a regexp condition
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'aristotle'
|
3
|
+
|
4
|
+
class TestLogic < Aristotle::Logic
|
5
|
+
action /Go to a bar/ do |_|
|
6
|
+
false
|
7
|
+
end
|
8
|
+
action /Do something else/ do |_|
|
9
|
+
false
|
10
|
+
end
|
11
|
+
action /Do a third thing/ do |_|
|
12
|
+
false
|
13
|
+
end
|
14
|
+
action /Return (\d+)/ do |_, number|
|
15
|
+
number.to_i
|
16
|
+
end
|
17
|
+
action /Return payload/ do |test_model|
|
18
|
+
test_model.payload
|
19
|
+
end
|
20
|
+
condition /this won't match/ do |_|
|
21
|
+
false
|
22
|
+
end
|
23
|
+
condition /this matches/ do |_|
|
24
|
+
true
|
25
|
+
end
|
26
|
+
condition /nothing happens/ do |_|
|
27
|
+
false
|
28
|
+
end
|
29
|
+
condition /all hell breaks loose/ do |_|
|
30
|
+
false
|
31
|
+
end
|
32
|
+
condition /this is a ([a-z]+) condition/ do |test_model, string|
|
33
|
+
test_model.payload = string
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
class TestModel
|
38
|
+
attr_accessor :payload
|
39
|
+
|
40
|
+
def initialize(argument)
|
41
|
+
@payload = argument
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
class AristotleTest < Minitest::Test
|
46
|
+
def test_aristotle
|
47
|
+
test_model = TestModel.new('payload')
|
48
|
+
test_logic = TestLogic.new(test_model)
|
49
|
+
|
50
|
+
assert test_logic.is_a? Aristotle::Logic
|
51
|
+
assert_nil test_logic.process('Nothing matches')
|
52
|
+
|
53
|
+
begin
|
54
|
+
test_logic.process('Things not defined')
|
55
|
+
assert false, 'It should have thrown an exception here'
|
56
|
+
rescue
|
57
|
+
assert true, ''
|
58
|
+
end
|
59
|
+
|
60
|
+
assert_equal 2, test_logic.process('Return on second')
|
61
|
+
assert_equal 1, test_logic.process('Return only the first')
|
62
|
+
|
63
|
+
assert_equal 'payload', test_logic.process('Test payload')
|
64
|
+
|
65
|
+
assert_equal 'regexp', test_logic.process('Test condition regexp')
|
66
|
+
end
|
67
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aristotle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marius Andra
|
@@ -17,12 +17,14 @@ executables:
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
+
- app/logic/test.logic
|
20
21
|
- bin/aristotle
|
21
22
|
- lib/aristotle.rb
|
22
23
|
- lib/aristotle/command.rb
|
23
24
|
- lib/aristotle/logic.rb
|
24
25
|
- lib/aristotle/presenter.rb
|
25
26
|
- lib/aristotle/utility.rb
|
27
|
+
- test/test_aristotle.rb
|
26
28
|
homepage: https://github.com/apprentus/aristotle
|
27
29
|
licenses:
|
28
30
|
- MIT
|
@@ -47,4 +49,6 @@ rubygems_version: 2.2.2
|
|
47
49
|
signing_key:
|
48
50
|
specification_version: 4
|
49
51
|
summary: Business logic
|
50
|
-
test_files:
|
52
|
+
test_files:
|
53
|
+
- test/test_aristotle.rb
|
54
|
+
- app/logic/test.logic
|