calyx 0.17.0 → 0.17.1
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/CODE_OF_CONDUCT.md +46 -0
- data/CONTRIBUTING.md +6 -18
- data/README.md +1 -1
- data/docs/404.html +3 -20
- data/docs/_config.yml +2 -0
- data/docs/_layouts/default.html +21 -4
- data/docs/assets/calyx-docs.css +640 -6042
- data/docs/calyx-docs.scss +65 -0
- data/docs/guide/context.md +45 -0
- data/docs/guide/examples.md +59 -0
- data/docs/guide/expressions.md +175 -0
- data/docs/guide/formats.md +37 -0
- data/docs/guide/getting-started.md +129 -0
- data/docs/guide/installation.md +19 -0
- data/docs/guide/random.md +100 -0
- data/docs/guide/results.md +62 -0
- data/docs/index.html +24 -2
- data/docs/package-lock.json +9 -9
- data/docs/package.json +1 -0
- data/lib/calyx/grammar.rb +19 -10
- data/lib/calyx/options.rb +2 -2
- data/lib/calyx/registry.rb +3 -3
- data/lib/calyx/result.rb +5 -4
- data/lib/calyx/version.rb +1 -1
- metadata +11 -3
data/docs/index.html
CHANGED
@@ -1,10 +1,32 @@
|
|
1
1
|
---
|
2
|
-
layout:
|
2
|
+
layout: home
|
3
3
|
---
|
4
4
|
|
5
|
+
{% include navbar.html %}
|
6
|
+
|
7
|
+
<div class="spread spread-hero">
|
8
|
+
<figure class="identity">
|
9
|
+
<img src="/assets/logos/calyx-flower-2.svg" width="80%" height="80%">
|
10
|
+
</figure>
|
11
|
+
<div class="lede">
|
12
|
+
<h2>Create writing machines with generative grammars</h2>
|
13
|
+
|
14
|
+
<ul class="cta-list">
|
15
|
+
<li><a class="cta-button" href="#">Download</a></li>
|
16
|
+
<li><a class="cta-button" href="#">Learn more</a></li>
|
17
|
+
</ul>
|
18
|
+
</div>
|
19
|
+
</div>
|
20
|
+
|
21
|
+
<div class="spread spread-intro">
|
22
|
+
<p>Calyx is a simple and powerful generative grammar tool for creating writing machines using the Ruby programming language.</p>
|
23
|
+
</div>
|
24
|
+
|
5
25
|
<div class="content">
|
6
26
|
<h1>Calyx</h1>
|
7
|
-
<p>Calyx provides a simple
|
27
|
+
<p>Calyx provides a simple and powerful generative grammar format for creating writing machines using the Ruby programming language.</p>
|
28
|
+
<p>Although the primary use case is procedurally generating text, Calyx grammars can be used to make anything where the output format is a string.</p>
|
29
|
+
<p>Calyx provides a simple Ruby API for creating writing machines of all shapes and sizes using generative grammars.</p>
|
8
30
|
<ul>
|
9
31
|
<li><a href="https://github.com/maetl/calyx">Source code on GitHub</a></li>
|
10
32
|
<li><a href="https://rubygems.org/gems/calyx">Package on Rubygems</a></li>
|
data/docs/package-lock.json
CHANGED
@@ -1292,6 +1292,15 @@
|
|
1292
1292
|
"readable-stream": "2.3.3"
|
1293
1293
|
}
|
1294
1294
|
},
|
1295
|
+
"string_decoder": {
|
1296
|
+
"version": "1.0.3",
|
1297
|
+
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz",
|
1298
|
+
"integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==",
|
1299
|
+
"dev": true,
|
1300
|
+
"requires": {
|
1301
|
+
"safe-buffer": "5.1.1"
|
1302
|
+
}
|
1303
|
+
},
|
1295
1304
|
"string-width": {
|
1296
1305
|
"version": "1.0.2",
|
1297
1306
|
"resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz",
|
@@ -1303,15 +1312,6 @@
|
|
1303
1312
|
"strip-ansi": "3.0.1"
|
1304
1313
|
}
|
1305
1314
|
},
|
1306
|
-
"string_decoder": {
|
1307
|
-
"version": "1.0.3",
|
1308
|
-
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz",
|
1309
|
-
"integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==",
|
1310
|
-
"dev": true,
|
1311
|
-
"requires": {
|
1312
|
-
"safe-buffer": "5.1.1"
|
1313
|
-
}
|
1314
|
-
},
|
1315
1315
|
"stringstream": {
|
1316
1316
|
"version": "0.0.5",
|
1317
1317
|
"resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz",
|
data/docs/package.json
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
"main": "index.html",
|
5
5
|
"scripts": {
|
6
6
|
"build": "node-sass --include-path node_modules/bulma calyx-docs.scss assets/calyx-docs.css",
|
7
|
+
"watch": "node-sass --watch --include-path node_modules/bulma docs.scss assets/calyx-docs.css",
|
7
8
|
"help": "node-sass --help"
|
8
9
|
},
|
9
10
|
"author": "Mark Rickerby <me@maetl.net>",
|
data/lib/calyx/grammar.rb
CHANGED
@@ -47,7 +47,8 @@ module Calyx
|
|
47
47
|
# DSL helper method for registering the given block as a string filter.
|
48
48
|
#
|
49
49
|
# @param [Symbol] name
|
50
|
-
# @
|
50
|
+
# @yieldparam [String] the input string to be processed by the filter
|
51
|
+
# @yieldreturn [String] the processed output string
|
51
52
|
def filter(name, &block)
|
52
53
|
registry.filter(name, &block)
|
53
54
|
end
|
@@ -99,24 +100,24 @@ module Calyx
|
|
99
100
|
# evaluated.
|
100
101
|
#
|
101
102
|
# @param [Numeric, Random, Hash] options
|
102
|
-
def initialize(
|
103
|
-
unless
|
103
|
+
def initialize(options={}, &block)
|
104
|
+
unless options.is_a?(Hash)
|
104
105
|
config_opts = {}
|
105
|
-
if
|
106
|
+
if options.is_a?(Numeric)
|
106
107
|
warn [
|
107
108
|
"NOTE: Passing a numeric seed arg directly is deprecated. ",
|
108
109
|
"Use the options hash instead: `Calyx::Grammar.new(seed: 1234)`"
|
109
110
|
].join
|
110
|
-
config_opts[:seed] =
|
111
|
-
elsif
|
111
|
+
config_opts[:seed] = options
|
112
|
+
elsif options.is_a?(Random)
|
112
113
|
warn [
|
113
114
|
"NOTE: Passing a Random object directly is deprecated. ",
|
114
115
|
"Use the options hash instead: `Calyx::Grammar.new(rng: Random.new)`"
|
115
116
|
].join
|
116
|
-
config_opts[:rng] =
|
117
|
+
config_opts[:rng] = options
|
117
118
|
end
|
118
119
|
else
|
119
|
-
config_opts =
|
120
|
+
config_opts = options
|
120
121
|
end
|
121
122
|
|
122
123
|
@options = Options.new(config_opts)
|
@@ -133,7 +134,11 @@ module Calyx
|
|
133
134
|
|
134
135
|
# Produces a string as an output of the grammar.
|
135
136
|
#
|
136
|
-
# @overload
|
137
|
+
# @overload generate(start_symbol)
|
138
|
+
# @param [Symbol] start_symbol
|
139
|
+
# @overload generate(rules_map)
|
140
|
+
# @param [Hash] rules_map
|
141
|
+
# @overload generate(start_symbol, rules_map)
|
137
142
|
# @param [Symbol] start_symbol
|
138
143
|
# @param [Hash] rules_map
|
139
144
|
# @return [String]
|
@@ -159,7 +164,11 @@ module Calyx
|
|
159
164
|
# Produces a generated result from evaluating the grammar.
|
160
165
|
#
|
161
166
|
# @see Calyx::Result
|
162
|
-
# @overload
|
167
|
+
# @overload generate_result(start_symbol)
|
168
|
+
# @param [Symbol] start_symbol
|
169
|
+
# @overload generate_result(rules_map)
|
170
|
+
# @param [Hash] rules_map
|
171
|
+
# @overload generate_result(start_symbol, rules_map)
|
163
172
|
# @param [Symbol] start_symbol
|
164
173
|
# @param [Hash] rules_map
|
165
174
|
# @return [Calyx::Result]
|
data/lib/calyx/options.rb
CHANGED
@@ -10,7 +10,7 @@ module Calyx
|
|
10
10
|
# Constructs a new options instance, merging the passed in options with the
|
11
11
|
# defaults.
|
12
12
|
#
|
13
|
-
# @
|
13
|
+
# @param [Hash, Calyx::Options] options
|
14
14
|
def initialize(options={})
|
15
15
|
@options = DEFAULTS.merge(options)
|
16
16
|
end
|
@@ -54,7 +54,7 @@ module Calyx
|
|
54
54
|
|
55
55
|
# Merges two instances together and returns a new instance.
|
56
56
|
#
|
57
|
-
# @
|
57
|
+
# @param [Calyx::Options] options
|
58
58
|
# @return [Calyx::Options]
|
59
59
|
def merge(options)
|
60
60
|
Options.new(@options.merge(options.to_h))
|
data/lib/calyx/registry.rb
CHANGED
@@ -20,7 +20,7 @@ module Calyx
|
|
20
20
|
|
21
21
|
# Attaches a modifier module to this instance.
|
22
22
|
#
|
23
|
-
# @param [Module]
|
23
|
+
# @param [Module] name
|
24
24
|
def modifier(name)
|
25
25
|
modifiers.extend(name)
|
26
26
|
end
|
@@ -36,7 +36,8 @@ module Calyx
|
|
36
36
|
# Registers the given block as a string filter.
|
37
37
|
#
|
38
38
|
# @param [Symbol] name
|
39
|
-
# @
|
39
|
+
# @yield [String]
|
40
|
+
# @yieldreturn [String]
|
40
41
|
def filter(name, callable=nil, &block)
|
41
42
|
if block_given?
|
42
43
|
transforms[name.to_sym] = block
|
@@ -154,7 +155,6 @@ module Calyx
|
|
154
155
|
# Produces a syntax tree of nested list nodes.
|
155
156
|
#
|
156
157
|
# @param [Symbol] start_symbol
|
157
|
-
# @param [Random] random
|
158
158
|
# @param [Hash] rules_map
|
159
159
|
# @return [Array]
|
160
160
|
def evaluate(start_symbol=:start, rules_map={})
|
data/lib/calyx/result.rb
CHANGED
@@ -5,8 +5,9 @@ module Calyx
|
|
5
5
|
@expression = expression.freeze
|
6
6
|
end
|
7
7
|
|
8
|
-
#
|
9
|
-
#
|
8
|
+
# Produces a syntax tree of nested nodes as the output of the grammar. Each
|
9
|
+
# syntax node represents the production rules that were evaluated at each
|
10
|
+
# step of the generator.
|
10
11
|
#
|
11
12
|
# @return [Array]
|
12
13
|
def tree
|
@@ -15,7 +16,7 @@ module Calyx
|
|
15
16
|
|
16
17
|
alias_method :to_exp, :tree
|
17
18
|
|
18
|
-
#
|
19
|
+
# Produces a text string as the output of the grammar.
|
19
20
|
#
|
20
21
|
# @return [String]
|
21
22
|
def text
|
@@ -26,7 +27,7 @@ module Calyx
|
|
26
27
|
|
27
28
|
alias_method :to_s, :text
|
28
29
|
|
29
|
-
#
|
30
|
+
# Produces a symbol as the output of the grammar.
|
30
31
|
#
|
31
32
|
# @return [Symbol]
|
32
33
|
def symbol
|
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.17.
|
4
|
+
version: 0.17.1
|
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-
|
11
|
+
date: 2017-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -62,6 +62,7 @@ extra_rdoc_files: []
|
|
62
62
|
files:
|
63
63
|
- ".gitignore"
|
64
64
|
- ".travis.yml"
|
65
|
+
- CODE_OF_CONDUCT.md
|
65
66
|
- CONTRIBUTING.md
|
66
67
|
- Gemfile
|
67
68
|
- LICENSE
|
@@ -76,6 +77,14 @@ files:
|
|
76
77
|
- docs/about.md
|
77
78
|
- docs/assets/calyx-docs.css
|
78
79
|
- docs/calyx-docs.scss
|
80
|
+
- docs/guide/context.md
|
81
|
+
- docs/guide/examples.md
|
82
|
+
- docs/guide/expressions.md
|
83
|
+
- docs/guide/formats.md
|
84
|
+
- docs/guide/getting-started.md
|
85
|
+
- docs/guide/installation.md
|
86
|
+
- docs/guide/random.md
|
87
|
+
- docs/guide/results.md
|
79
88
|
- docs/index.html
|
80
89
|
- docs/package-lock.json
|
81
90
|
- docs/package.json
|
@@ -126,4 +135,3 @@ signing_key:
|
|
126
135
|
specification_version: 4
|
127
136
|
summary: Generate text with declarative recursive grammars
|
128
137
|
test_files: []
|
129
|
-
has_rdoc:
|