moory 1.2.1 → 1.2.2

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: 63dbdfffb9d3e9c172e021708da629b70bfda5ff8d61247247fc2cf4a37e39c5
4
- data.tar.gz: 572e8da3c78d4f133e05c75f56ebce947551b1067d82f5c12d0e1768de4d2323
3
+ metadata.gz: 5fdaf3f278870dc01b02d6d4aa050d1fde6683d798ecce11e84cb2aa3351e06d
4
+ data.tar.gz: 2223ec51cae4433832d760c7564bae12c2fdf37b608ac12c9ed08f17c4a71ba0
5
5
  SHA512:
6
- metadata.gz: 1fdb34c1539249252081632c6c75e0e680423481c4c61aa408ee2cdde32ccbab84429388cc36da566145bfc4ba1d2eac292a6b521ed7f1a4307414274563af66
7
- data.tar.gz: 9fc9f0fc5bc675d0307fc083375c457a848f1654cda0728f5adaa76cce82a37274092bc76830925c9bc7ee58e7415867549fe63b935e45fff0912a4343e377a8
6
+ metadata.gz: 0ab71db785a91356d74c53d622677ccc7ea9e689935cd382ac786d196314f3e5bb5cb2bdad2aa0ca6c0620c08a7f01e408db55443dbf28bc85df5032afbcf4b7
7
+ data.tar.gz: 8d733924a7885ef504194724ba7d3736ded7c411fed54326ba99feba041acc68cf51bd2351b5a8a0831e77516cb56a9f9ecb2f5e14265ce34c5ad11c946c9324
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- moory (1.2.1)
4
+ moory (1.2.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -32,4 +32,4 @@ DEPENDENCIES
32
32
  rspec (~> 3.0)
33
33
 
34
34
  BUNDLED WITH
35
- 1.16.2
35
+ 1.16.3
@@ -2,11 +2,12 @@ module Moory
2
2
  class Filter < Moory::Logistic::Unit
3
3
  IGNORE = [' ', "\t", "\n"]
4
4
  DEFAULT_CONSUMER = $stdout.method(:puts)
5
+ IGNORE_FOREIGN = proc { |c| "Warning! Ignoring unknown character: #{c}" }
5
6
 
6
- def initialize(rules:, consumer:DEFAULT_CONSUMER)
7
+ def initialize(rules:, consumer:DEFAULT_CONSUMER, quarantine:IGNORE_FOREIGN)
7
8
  @buffer = ""
8
9
  @consumer = consumer
9
- super(rules: rules)
10
+ super(rules: rules, quarantine:quarantine)
10
11
  end
11
12
 
12
13
  def configure(rules)
@@ -8,8 +8,10 @@ module Moory
8
8
 
9
9
  class Unit
10
10
  include Moory::Efferent
11
-
12
- def initialize(rules:, initial:'^')
11
+
12
+ attr_accessor :quarantine
13
+
14
+ def initialize(rules:, initial:'^',quarantine:nil)
13
15
  @initial = initial
14
16
  configure(rules)
15
17
  end
@@ -17,7 +19,7 @@ module Moory
17
19
  def issue(stimulus)
18
20
  understand?(stimulus) ?
19
21
  super :
20
- (raise "Unexpected #{stimulus}")
22
+ bad_stimulus(stimulus)
21
23
  end
22
24
 
23
25
  def prime
@@ -30,6 +32,12 @@ module Moory
30
32
  Moory::Loader.load(rules:rules, machine:self)
31
33
  prime
32
34
  end
35
+
36
+ def bad_stimulus(stimulus)
37
+ quarantine ?
38
+ quarantine.call(stimulus) :
39
+ (raise "Unexpected #{stimulus}")
40
+ end
33
41
  end
34
42
 
35
43
  class Controller
@@ -1,3 +1,3 @@
1
1
  module Moory
2
- VERSION = "1.2.1"
2
+ VERSION = "1.2.2"
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.2.1
4
+ version: 1.2.2
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-13 00:00:00.000000000 Z
11
+ date: 2018-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
107
  version: '0'
108
108
  requirements: []
109
109
  rubyforge_project:
110
- rubygems_version: 2.7.6
110
+ rubygems_version: 2.7.7
111
111
  signing_key:
112
112
  specification_version: 4
113
113
  summary: Use plain text to define finite machines.