moory 1.1.3 → 1.1.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e4602285bb8fe1aa65033c2385c0f878cf3170d662f72a41d6ac3f339e5127c0
4
- data.tar.gz: 596a24456b2f615d5ae0c13621a0542c6c658506a9734cb47dc88fffc004cc6f
3
+ metadata.gz: '0239942918e89ed21a49acd4fd35cee39ad71910dece516c6f53a04b36f962dd'
4
+ data.tar.gz: bbedc737fdc70d1fc41b8386a30903e7d324301cd11d07adc2264a4f8212a8ec
5
5
  SHA512:
6
- metadata.gz: 476b79929ebbf3b5e1fdc63fffe5444225e551308fc9c350b0c397095eee26940e6fed0063fe11235bfcb1ff147621c70bcf80c3f7b2222916be9e95ee989807
7
- data.tar.gz: 63910cc00a4e89d7b1e1ed207a67677f300cce0b33b8ef8ffa105cdaf90cb36230a9cc95fdeab39654cd8102f5f056ebac2cadd52d70c9dc006c3d086c5065fe
6
+ metadata.gz: bc8b101ebaead0455063763317833d62148f72a6b5e561f81b336d4be88aab781795338fcf98150a67d38635464a5eb1aaf2941fbc454052c700b1770edaa5a9
7
+ data.tar.gz: 5b0cb93badef69d457928f3df86ea6ae9cc7f659c430b13fd0f4e8ed680923dba018a4e83f19043ff5d858fb6cae954c01c5a53c3b44fe15c0845f0956afe5ba
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- moory (1.1.3)
4
+ moory (1.1.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -0,0 +1,77 @@
1
+ require 'moory'
2
+
3
+ pipcv_config = {
4
+ basis: 'basis',
5
+ specs: {
6
+ 'basis' => {
7
+ rules: """
8
+ ^ : constant : $
9
+
10
+ ^ : variable : $
11
+
12
+ ^ : prefix / open / defer : Δ
13
+
14
+ ^ : ( / parenthetical / defer : Δ
15
+
16
+ $ : infix / open / defer : Δ
17
+
18
+ Δ : term : $
19
+ """,
20
+ },
21
+ 'open' => {
22
+ rules: """
23
+ ^ : constant / term / reconvene : $
24
+
25
+ ^ : variable / term / reconvene : $
26
+
27
+ ^ : prefix / open / defer : Δ
28
+
29
+ ^ : ( / parenthetical / defer : Δ
30
+
31
+ $ : infix / open / defer : Δ
32
+
33
+ Δ : term / term / reconvene : $
34
+ """,
35
+ },
36
+ 'parenthetical' => {
37
+ rules: """
38
+ ^ : constant : C
39
+
40
+ ^ : variable : C
41
+
42
+ ^ : prefix / open / defer : Δ
43
+
44
+ ^ : ( / parenthetical / defer : Δ
45
+
46
+ ^ : ) / void / reconvene : $
47
+
48
+ C : infix / open / defer : Δ
49
+
50
+ C : ) / term / reconvene : $
51
+
52
+ Δ : term : C
53
+ """
54
+ }
55
+ }
56
+ }
57
+
58
+ logistic = Moory::Logistic::Controller.new(pipcv_config)
59
+
60
+ pp logistic.issue('(')
61
+ pp logistic.issue('(')
62
+ pp logistic.issue('prefix')
63
+ pp logistic.issue('constant')
64
+ pp logistic.issue('infix')
65
+ pp logistic.issue('prefix')
66
+ pp logistic.issue('(')
67
+ pp logistic.issue('variable')
68
+ pp logistic.issue('infix')
69
+ pp logistic.issue('prefix')
70
+ pp logistic.issue('(')
71
+ pp logistic.issue('variable')
72
+ pp logistic.issue(')')
73
+ pp logistic.issue(')')
74
+ pp logistic.issue(')')
75
+ pp logistic.issue(')')
76
+ pp logistic.issue('infix')
77
+ pp logistic.issue('variable')
@@ -80,6 +80,3 @@ logistic = Moory::Logistic::Controller.new(pipcv_config)
80
80
  end
81
81
 
82
82
  pp logistic.deferrals
83
-
84
- pp logistic.done?
85
-
@@ -1,5 +1,11 @@
1
1
  module Moory
2
2
  module Logistic
3
+ module NilExtensions
4
+ refine NilClass do
5
+ def <<(other);end
6
+ end
7
+ end
8
+
3
9
  class Unit
4
10
  include Moory::Efferent
5
11
 
@@ -27,6 +33,8 @@ module Moory
27
33
  end
28
34
 
29
35
  class Controller
36
+ using NilExtensions
37
+
30
38
  def initialize(config)
31
39
  @config = config
32
40
  prepare_units
@@ -51,11 +59,11 @@ module Moory
51
59
  end
52
60
 
53
61
  def issue(stimulus)
54
- active_unit.issue(stimulus)
55
- end
56
-
57
- def done?
58
- deferrals.empty?
62
+ @consequences = []
63
+
64
+ active_unit.understand?(stimulus) ?
65
+ forward(stimulus) :
66
+ nil
59
67
  end
60
68
 
61
69
  private
@@ -78,8 +86,15 @@ module Moory
78
86
  def focus_on(unit_name)
79
87
  @focus = unit_name
80
88
  end
89
+
90
+ def forward(stimulus)
91
+ active_unit.issue(stimulus)
92
+ @consequences
93
+ end
81
94
 
82
95
  def defer(unit_name)
96
+ @consequences << :defer
97
+
83
98
  deferrals.push(
84
99
  {
85
100
  name: @focus.clone,
@@ -92,6 +107,8 @@ module Moory
92
107
 
93
108
  def reconvene(stimulus=nil)
94
109
  raise "Cannot reconvene without prior deferral" if deferrals.empty?
110
+
111
+ @consequences << :reconvene
95
112
 
96
113
  deferrals.pop.tap do |last_deferral|
97
114
  focus_on(last_deferral[:name])
@@ -1,3 +1,3 @@
1
1
  module Moory
2
- VERSION = "1.1.3"
2
+ VERSION = "1.1.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moory
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam W. Grant
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-08-01 00:00:00.000000000 Z
11
+ date: 2018-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -70,6 +70,7 @@ files:
70
70
  - bin/console
71
71
  - bin/setup
72
72
  - examples/ab_star.rb
73
+ - examples/consequences.rb
73
74
  - examples/decoder.rb
74
75
  - examples/inductive.rb
75
76
  - lib/moory.rb