calyx 0.14.1 → 0.14.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
  SHA1:
3
- metadata.gz: 27169df4f2bd509b5032e94a52faf2a66caac896
4
- data.tar.gz: de708f687c780fb782d9dee7857afabc1fd64e92
3
+ metadata.gz: 129a9b8ddec5530b5f427780572e1e0a3a667bd4
4
+ data.tar.gz: 445ce73db118256bbf9ad748b82421235bb8573d
5
5
  SHA512:
6
- metadata.gz: 9a4a39f5d884dbec68f98dd861196b877139398c95549a3c01892c199f26e698680d028128fe6a009192851dba2be636ada636aec2a3b5acac3409b73c8c0e92
7
- data.tar.gz: 3a31249994903e00bb8ec895eed7929a7343e1736e5d2750d400ed69a4980ff6be7f5b100ff051ceb64820a5f51295729debc9a0bc0d87b514b8eaafcbfa0318
6
+ metadata.gz: 5b31b154440e67f0bde8ba9cd49784aece4ffa971a3b15731f83b05696f44e4db3fc43cdf78ffba990c962c46ac7d71c4964339133a43c202bd651a9066113bd
7
+ data.tar.gz: 3aded7ee2f7104244b0d47dc0a06a98607f32bdc05e17a1eabf153b1595cca60e17f708cbc2873eb09bb27b16ec6bb445980f23c3b679a76feb669ecb1bcd601
data/README.md CHANGED
@@ -493,7 +493,9 @@ Rough plan for stabilising the API and features for a `1.0` release.
493
493
  | `0.11` | ~~support YAML format (and JSON?)~~ |
494
494
  | `0.12` | ~~API documentation~~ |
495
495
  | `0.13` | ~~Support for unique rules~~ |
496
- | `0.14` | Options config and ‘strict mode’ error handling |
496
+ | `0.14` | ~~Support for Ruby 2.4~~ |
497
+ | `0.15` | Options config and ‘strict mode’ error handling |
498
+ | `0.16` | Improve representation of weighted probability selection |
497
499
 
498
500
  ## Credits
499
501
 
@@ -10,7 +10,7 @@ module Calyx
10
10
  #
11
11
  # grammar.evaluate
12
12
  # # => Calyx::Errors::MissingRule: :blank is not registered
13
- class MissingRule < RuntimeError;
13
+ class MissingRule < RuntimeError
14
14
  def initialize(msg)
15
15
  super(":#{msg} is not registered")
16
16
  end
@@ -138,7 +138,7 @@ module Calyx
138
138
 
139
139
  @registry.evaluate(start_symbol, @random, rules_map).flatten.reject do |obj|
140
140
  obj.is_a?(Symbol)
141
- end.join(''.freeze)
141
+ end.join
142
142
  end
143
143
 
144
144
  # Produces a syntax tree of nested list nodes as an output of the grammar.
@@ -20,7 +20,7 @@ module Calyx
20
20
  # @param [Random] random
21
21
  # @return [Array]
22
22
  def evaluate(random)
23
- terminal = @production.evaluate(random).flatten.reject { |o| o.is_a?(Symbol) }.join(''.freeze)
23
+ terminal = @production.evaluate(random).flatten.reject { |o| o.is_a?(Symbol) }.join
24
24
  expression = @methods.reduce(terminal) do |value, method|
25
25
  @registry.transform(method, value)
26
26
  end
@@ -18,7 +18,12 @@ module Calyx
18
18
  # @param [Random] random
19
19
  # @return [Array]
20
20
  def evaluate(random)
21
- [@symbol, @registry.expand(@symbol).evaluate(random)]
21
+ expansion = @registry.expand(@symbol)
22
+ if expansion.nil?
23
+ raise Errors::MissingRule.new(@symbol)
24
+ else
25
+ [@symbol, expansion.evaluate(random)]
26
+ end
22
27
  end
23
28
  end
24
29
  end
@@ -1,3 +1,3 @@
1
1
  module Calyx
2
- VERSION = '0.14.1'.freeze
2
+ VERSION = '0.14.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: calyx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.1
4
+ version: 0.14.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Rickerby
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-17 00:00:00.000000000 Z
11
+ date: 2017-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler