calyx 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2bd547cabae5575236b9ef076d641c222365c207
4
- data.tar.gz: 3a534687dc5371ade6bb88b06ff4059a20b25c7b
3
+ metadata.gz: 6e0af61453ee9d96b61daf9255a322023510eda0
4
+ data.tar.gz: 1beb02a6c87b667587fc3cae9e05852e52d253b1
5
5
  SHA512:
6
- metadata.gz: 86fdb69a40b9f57995da80c8318e38992b7588053c73824207ea058cf2262d3bc90fe87fea0e6f3e2967a0403239da2db70a14c799a2829ccddd2355e690f1af
7
- data.tar.gz: 7252174f84e3edc72cf8e6e8dee901c4c2f8ba9b3aa746b3d62f577d48d620c8946efacdab01b6373c9afe18488c2b846abccc1f62c53e6258c3f6984acf266a
6
+ metadata.gz: d844ef847d5a1e7fa00f75d252f666ad183740a39537ff0441df3def2e2768c2daff09399364e794a08c64e03ded3b06ddb1b9fce14fd72d8ec2edfe40b4ea39
7
+ data.tar.gz: e10899e3abac20855a2a10f616d53ffe75b2f72d9751503cf9e6a17d2e19595c28924ed289b01c1734f7d32e9d53065f83c391842e3680af7784acbb88aec6f2
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015 Mark Rickerby
3
+ Copyright (c) 2015-2016 Editorial Technology <http://editorial.technology>
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -114,7 +114,7 @@ end
114
114
 
115
115
  ### Random Sampling
116
116
 
117
- By default, the outcomes of generated rules are selected with Ruby’s built-in pseudorandom number generator (as seen in methods like `Kernel.rand` and `Array.sample`). To seed the random number generator, pass in a seed value (an integer) as the first argument to the constructor:
117
+ By default, the outcomes of generated rules are selected with Ruby’s built-in pseudorandom number generator (as seen in methods like `Kernel.rand` and `Array.sample`). To seed the random number generator, pass in an integer seed value as the first argument to the constructor:
118
118
 
119
119
  ```ruby
120
120
  MyGrammar.new(12345)
@@ -259,6 +259,6 @@ Rough plan for stabilising the API and features for a `1.0` release.
259
259
 
260
260
  ## License
261
261
 
262
- Calyx is open source and provided under the terms of the MIT license. Copyright (c) 2015 Mark Rickerby
262
+ Calyx is open source and provided under the terms of the MIT license. Copyright (c) 2015-2016 [Editorial Technology](http://editorial.technology/).
263
263
 
264
264
  See the `LICENSE` file [included with the project distribution](https://github.com/maetl/calyx/blob/master/LICENSE) for more information.
@@ -7,8 +7,8 @@ module Calyx
7
7
  @rules = {}
8
8
  end
9
9
 
10
- def start(*productions, &production)
11
- @rules[:start] = construct_rule(productions)
10
+ def method_missing(name, *arguments)
11
+ rule(name, *arguments)
12
12
  end
13
13
 
14
14
  def rule(name, *productions, &production)
@@ -23,7 +23,7 @@ module Calyx
23
23
  @rules = rules.merge(registry.rules)
24
24
  end
25
25
 
26
- def evaluate(context={})
26
+ def evaluate(start_symbol=:start, context={})
27
27
  duplicate_registry = Marshal.load(Marshal.dump(self))
28
28
  duplicate_rules = duplicate_registry.rules
29
29
  context.each do |key, value|
@@ -38,7 +38,7 @@ module Calyx
38
38
  end
39
39
  end
40
40
 
41
- duplicate_rules[:start].evaluate
41
+ duplicate_rules[start_symbol].evaluate
42
42
  end
43
43
 
44
44
  private
@@ -58,7 +58,7 @@ module Calyx
58
58
  end
59
59
 
60
60
  def start(*productions, &production)
61
- registry.start(*productions)
61
+ registry.rule(:start, *productions)
62
62
  end
63
63
 
64
64
  def rule(name, *productions, &production)
@@ -203,20 +203,19 @@ module Calyx
203
203
  end
204
204
 
205
205
  def initialize(seed=nil, &block)
206
- @seed = seed
207
- @seed = Time.new.to_i unless @seed
206
+ @seed = seed || Random.new_seed
208
207
  srand(@seed)
209
208
 
210
209
  if block_given?
211
210
  @registry = Registry.new
212
211
  @registry.instance_eval(&block)
213
212
  else
214
- @registry = self.class.registry.clone
213
+ @registry = self.class.registry
215
214
  end
216
215
  end
217
216
 
218
217
  def generate(context={})
219
- @registry.evaluate(context)
218
+ @registry.evaluate(:start, context)
220
219
  end
221
220
  end
222
221
  end
@@ -1,3 +1,3 @@
1
1
  module Calyx
2
- VERSION = '0.7.1'.freeze
2
+ VERSION = '0.7.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.7.1
4
+ version: 0.7.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: 2016-03-04 00:00:00.000000000 Z
11
+ date: 2016-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler