calyx 0.13.0 → 0.14.0
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/README.md +4 -2
- data/lib/calyx/grammar.rb +19 -6
- data/lib/calyx/registry.rb +2 -1
- data/lib/calyx/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7beefadeb8e2f98a6c802a85dec4fb2ee9a81de
|
4
|
+
data.tar.gz: aeeb4015155d4ea728f0289fff21488fda88d37d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee1a4994645a80f6ceef3824f348653a9ac44eee32f127db31f457c4ca57c5e5ff26b5228109ba6f407d5ca7c3761d1632b3adcdfb65dd165e8b18d0d1dac24b
|
7
|
+
data.tar.gz: 3cd0f9955a377a9e97d4f62b1b2e2b5f256af0dd33089de81fa95d938f29633e0c771ba71d9fd581ed23f310d8edc29c18f4ad3b43b953fbeb905cf2ca100ac0
|
data/README.md
CHANGED
@@ -489,7 +489,9 @@ Rough plan for stabilising the API and features for a `1.0` release.
|
|
489
489
|
| `0.9` | ~~return grammar tree from `#evaluate`, with flattened string from `#generate` being separate~~ |
|
490
490
|
| `0.10` | ~~inject custom string functions for parameterised rules, transforms and mappings~~ |
|
491
491
|
| `0.11` | ~~support YAML format (and JSON?)~~ |
|
492
|
-
| `
|
492
|
+
| `0.12` | ~~API documentation~~ |
|
493
|
+
| `0.13` | ~~Support for unique rules~~ |
|
494
|
+
| `0.14` | Options config and ‘strict mode’ error handling |
|
493
495
|
|
494
496
|
## Credits
|
495
497
|
|
@@ -503,6 +505,6 @@ Rough plan for stabilising the API and features for a `1.0` release.
|
|
503
505
|
|
504
506
|
## License
|
505
507
|
|
506
|
-
Calyx is open source and provided under the terms of the MIT license. Copyright (c) 2015-
|
508
|
+
Calyx is open source and provided under the terms of the MIT license. Copyright (c) 2015-2017 [Editorial Technology](http://editorial.technology/).
|
507
509
|
|
508
510
|
See the `LICENSE` file [included with the project distribution](https://github.com/maetl/calyx/blob/master/LICENSE) for more information.
|
data/lib/calyx/grammar.rb
CHANGED
@@ -98,16 +98,29 @@ module Calyx
|
|
98
98
|
# Grammar rules can be constructed on the fly when the passed-in block is
|
99
99
|
# evaluated.
|
100
100
|
#
|
101
|
-
# @param [Numeric, Random]
|
102
|
-
def initialize(
|
103
|
-
|
104
|
-
|
101
|
+
# @param [Numeric, Random, Hash] options
|
102
|
+
def initialize(options={}, &block)
|
103
|
+
unless options.is_a?(Hash)
|
104
|
+
config_opts = {}
|
105
|
+
if options.is_a?(Numeric)
|
106
|
+
config_opts[:seed] = options
|
107
|
+
elsif options.is_a?(Random)
|
108
|
+
config_opts[:rng] = options
|
109
|
+
end
|
105
110
|
else
|
106
|
-
|
111
|
+
config_opts = options.dup
|
112
|
+
end
|
113
|
+
|
114
|
+
@random = if config_opts.key?(:seed)
|
115
|
+
Random.new(config_opts[:seed])
|
116
|
+
elsif config_opts.key?(:rng)
|
117
|
+
config_opts[:rng]
|
118
|
+
else
|
119
|
+
Random.new
|
107
120
|
end
|
108
121
|
|
109
122
|
if block_given?
|
110
|
-
@registry = Registry.new
|
123
|
+
@registry = Registry.new(config_opts)
|
111
124
|
@registry.instance_eval(&block)
|
112
125
|
else
|
113
126
|
@registry = self.class.registry
|
data/lib/calyx/registry.rb
CHANGED
data/lib/calyx/version.rb
CHANGED
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.
|
4
|
+
version: 0.14.0
|
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-02-
|
11
|
+
date: 2017-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|