calyx 0.20.0 → 0.21.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +33 -0
- data/.travis.yml +1 -1
- data/lib/calyx.rb +1 -0
- data/lib/calyx/grammar.rb +12 -0
- data/lib/calyx/mapping.rb +15 -0
- data/lib/calyx/modifiers.rb +10 -0
- data/lib/calyx/production/weighted_choices.rb +7 -0
- data/lib/calyx/registry.rb +2 -12
- data/lib/calyx/rule.rb +14 -4
- data/lib/calyx/version.rb +1 -1
- metadata +5 -69
- data/docs/404.html +0 -7
- data/docs/CNAME +0 -1
- data/docs/_config.yml +0 -27
- data/docs/_data/breadcrumbs.yml +0 -9
- data/docs/_data/docs.yml +0 -35
- data/docs/_data/examples.yml +0 -9
- data/docs/_includes/breadcrumbs.html +0 -36
- data/docs/_includes/contents.html +0 -12
- data/docs/_includes/icon-github.html +0 -4
- data/docs/_includes/icon-rubygems.html +0 -9
- data/docs/_includes/navbar.html +0 -24
- data/docs/_includes/pagebar.html +0 -12
- data/docs/_layouts/default.html +0 -13
- data/docs/_layouts/docs.html +0 -14
- data/docs/_layouts/home.html +0 -13
- data/docs/_layouts/page.html +0 -20
- data/docs/_posts/2017-09-14-welcome-to-jekyll.markdown +0 -25
- data/docs/_posts/2017-09-21-0.17.0-released.md +0 -10
- data/docs/_styles/card.scss +0 -7
- data/docs/_styles/colors.scss +0 -18
- data/docs/_styles/content.scss +0 -57
- data/docs/_styles/cta.scss +0 -25
- data/docs/_styles/grid.scss +0 -22
- data/docs/_styles/media.scss +0 -50
- data/docs/_styles/menu.scss +0 -54
- data/docs/_styles/modifiers.scss +0 -3
- data/docs/_styles/navbar.scss +0 -161
- data/docs/_styles/pagebar.scss +0 -32
- data/docs/_styles/reset.scss +0 -92
- data/docs/_styles/scale.scss +0 -23
- data/docs/_styles/spread.scss +0 -55
- data/docs/_styles/styleguide.scss +0 -52
- data/docs/_styles/syntax.scss +0 -84
- data/docs/_styles/typography.scss +0 -49
- data/docs/_styles/yard.scss +0 -36
- data/docs/api.html +0 -9662
- data/docs/assets/calyx-docs.css +0 -792
- data/docs/assets/calyx-flower-outline.svg +0 -202
- data/docs/assets/calyx-flower-reverse.svg +0 -202
- data/docs/assets/calyx-flower.svg +0 -202
- data/docs/assets/logo-small.png +0 -0
- data/docs/assets/logos/calyx-flower-1.svg +0 -22
- data/docs/assets/logos/calyx-flower-2.svg +0 -21
- data/docs/content/documentation.html +0 -20
- data/docs/content/examples.html +0 -12
- data/docs/content/examples/any-gradient.md +0 -32
- data/docs/content/examples/faker.md +0 -16
- data/docs/content/examples/tiny-woodland-bot.md +0 -24
- data/docs/content/guides/context.md +0 -45
- data/docs/content/guides/expressions.md +0 -175
- data/docs/content/guides/features.md +0 -50
- data/docs/content/guides/formats.md +0 -37
- data/docs/content/guides/installation.md +0 -51
- data/docs/content/guides/random.md +0 -100
- data/docs/content/guides/results.md +0 -62
- data/docs/content/index.html +0 -44
- data/docs/content/introduction.md +0 -23
- data/docs/content/introduction/concepts.md +0 -82
- data/docs/content/introduction/contributing.md +0 -43
- data/docs/content/introduction/tutorial.md +0 -129
- data/docs/content/styleguide.html +0 -71
- data/docs/docs.scss +0 -94
- data/docs/index.html +0 -12
- data/docs/package-lock.json +0 -1536
- data/docs/package.json +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88debcd6bac2845d1d5b6c932aff212a3d93a900cfb6758db486500f49987e7e
|
4
|
+
data.tar.gz: 7a22972ac485e7147f0855bac351badaa25876978655191e75327a54a404cd4d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 716f85a44ca0e852c96695ffdd6ddb91b298c5c6579a61d5082893be445ab78d6e8b7b37ac0f50eac2169f14ada86c0001cabf7c354ae4ba6ecd763c0335de8e
|
7
|
+
data.tar.gz: 63de5c1d2d1ccaa74232eb3c7535df24cdce5fc2065bedc2cf90a8a590080397d9e1881cbee15501aeb8ef61f206b561e5e2888f0c7dee22680eefbb83c1e615
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: Ruby
|
9
|
+
|
10
|
+
on:
|
11
|
+
push:
|
12
|
+
branches: [ master ]
|
13
|
+
pull_request:
|
14
|
+
branches: [ master ]
|
15
|
+
|
16
|
+
jobs:
|
17
|
+
test:
|
18
|
+
|
19
|
+
runs-on: ubuntu-latest
|
20
|
+
|
21
|
+
steps:
|
22
|
+
- uses: actions/checkout@v2
|
23
|
+
- name: Set up Ruby
|
24
|
+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
25
|
+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
26
|
+
# uses: ruby/setup-ruby@v1
|
27
|
+
uses: ruby/setup-ruby@ec106b438a1ff6ff109590de34ddc62c540232e0
|
28
|
+
with:
|
29
|
+
ruby-version: 2.6
|
30
|
+
- name: Install dependencies
|
31
|
+
run: bundle install
|
32
|
+
- name: Run tests
|
33
|
+
run: bundle exec rspec
|
data/.travis.yml
CHANGED
data/lib/calyx.rb
CHANGED
data/lib/calyx/grammar.rb
CHANGED
@@ -33,6 +33,10 @@ module Calyx
|
|
33
33
|
#
|
34
34
|
# @param [Module] module_name
|
35
35
|
def modifier(module_name)
|
36
|
+
warn [
|
37
|
+
"NOTE: Loading modifiers via grammar class methods is deprecated.",
|
38
|
+
"Alternative API TBD. For now this method still works."
|
39
|
+
].join
|
36
40
|
registry.modifier(module_name)
|
37
41
|
end
|
38
42
|
|
@@ -41,6 +45,10 @@ module Calyx
|
|
41
45
|
# @param [Symbol] name
|
42
46
|
# @param [Hash<Regex,String>] pairs
|
43
47
|
def mapping(name, pairs)
|
48
|
+
warn [
|
49
|
+
"NOTE: The fixed `mapping` class method is deprecated.",
|
50
|
+
"This still works but will be replaced with a new mapping format."
|
51
|
+
].join
|
44
52
|
registry.mapping(name, pairs)
|
45
53
|
end
|
46
54
|
|
@@ -50,6 +58,10 @@ module Calyx
|
|
50
58
|
# @yieldparam [String] the input string to be processed by the filter
|
51
59
|
# @yieldreturn [String] the processed output string
|
52
60
|
def filter(name, &block)
|
61
|
+
warn [
|
62
|
+
"NOTE: The fixed `filter` class method is deprecated.",
|
63
|
+
"This will be removed in 0.22. Use the API for modifers instead."
|
64
|
+
].join
|
53
65
|
registry.filter(name, &block)
|
54
66
|
end
|
55
67
|
|
data/lib/calyx/modifiers.rb
CHANGED
@@ -63,6 +63,13 @@ module Calyx
|
|
63
63
|
@collection = collection
|
64
64
|
end
|
65
65
|
|
66
|
+
# The number of possible choices available for this rule.
|
67
|
+
#
|
68
|
+
# @return [Integer]
|
69
|
+
def size
|
70
|
+
@collection.size
|
71
|
+
end
|
72
|
+
|
66
73
|
# Evaluate the choice by randomly picking one of its possible options,
|
67
74
|
# balanced according to the given weights.
|
68
75
|
#
|
data/lib/calyx/registry.rb
CHANGED
@@ -67,7 +67,7 @@ module Calyx
|
|
67
67
|
# @param [Symbol] name
|
68
68
|
# @param [Array] productions
|
69
69
|
def define_rule(name, trace, productions)
|
70
|
-
rules[name.to_sym] = Rule.new(name.to_sym,
|
70
|
+
rules[name.to_sym] = Rule.new(name.to_sym, Rule.build_ast(productions, self), trace)
|
71
71
|
end
|
72
72
|
|
73
73
|
# Defines a rule in the temporary evaluation context.
|
@@ -76,7 +76,7 @@ module Calyx
|
|
76
76
|
# @param [Array] productions
|
77
77
|
def define_context_rule(name, trace, productions)
|
78
78
|
productions = [productions] unless productions.is_a?(Enumerable)
|
79
|
-
context[name.to_sym] = Rule.new(name.to_sym,
|
79
|
+
context[name.to_sym] = Rule.new(name.to_sym, Rule.build_ast(productions, self), trace)
|
80
80
|
end
|
81
81
|
|
82
82
|
# Expands the given symbol to its rule.
|
@@ -197,15 +197,5 @@ module Calyx
|
|
197
197
|
end
|
198
198
|
}
|
199
199
|
end
|
200
|
-
|
201
|
-
def construct_rule(productions)
|
202
|
-
if productions.first.is_a?(Hash)
|
203
|
-
Production::WeightedChoices.parse(productions.first.to_a, self)
|
204
|
-
elsif productions.first.is_a?(Enumerable)
|
205
|
-
Production::WeightedChoices.parse(productions, self)
|
206
|
-
else
|
207
|
-
Production::Choices.parse(productions, self)
|
208
|
-
end
|
209
|
-
end
|
210
200
|
end
|
211
201
|
end
|
data/lib/calyx/rule.rb
CHANGED
@@ -2,20 +2,30 @@ module Calyx
|
|
2
2
|
# Represents a named rule connected to a tree of productions that can be
|
3
3
|
# evaluated and a trace which represents where the rule was declared.
|
4
4
|
class Rule
|
5
|
-
|
5
|
+
def self.build_ast(productions, registry)
|
6
|
+
if productions.first.is_a?(Hash)
|
7
|
+
Production::WeightedChoices.parse(productions.first.to_a, registry)
|
8
|
+
elsif productions.first.is_a?(Enumerable)
|
9
|
+
Production::WeightedChoices.parse(productions, registry)
|
10
|
+
else
|
11
|
+
Production::Choices.parse(productions, registry)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
attr_reader :name, :tree, :trace
|
6
16
|
|
7
17
|
def initialize(name, productions, trace)
|
8
18
|
@name = name.to_sym
|
9
|
-
@
|
19
|
+
@tree = productions
|
10
20
|
@trace = trace
|
11
21
|
end
|
12
22
|
|
13
23
|
def size
|
14
|
-
|
24
|
+
tree.size
|
15
25
|
end
|
16
26
|
|
17
27
|
def evaluate(options)
|
18
|
-
|
28
|
+
tree.evaluate(options)
|
19
29
|
end
|
20
30
|
end
|
21
31
|
end
|
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.21.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:
|
11
|
+
date: 2020-11-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -60,6 +60,7 @@ executables: []
|
|
60
60
|
extensions: []
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
|
+
- ".github/workflows/ruby.yml"
|
63
64
|
- ".gitignore"
|
64
65
|
- ".travis.yml"
|
65
66
|
- CODE_OF_CONDUCT.md
|
@@ -69,71 +70,6 @@ files:
|
|
69
70
|
- README.md
|
70
71
|
- SYNTAX.md
|
71
72
|
- calyx.gemspec
|
72
|
-
- docs/404.html
|
73
|
-
- docs/CNAME
|
74
|
-
- docs/_config.yml
|
75
|
-
- docs/_data/breadcrumbs.yml
|
76
|
-
- docs/_data/docs.yml
|
77
|
-
- docs/_data/examples.yml
|
78
|
-
- docs/_includes/breadcrumbs.html
|
79
|
-
- docs/_includes/contents.html
|
80
|
-
- docs/_includes/icon-github.html
|
81
|
-
- docs/_includes/icon-rubygems.html
|
82
|
-
- docs/_includes/navbar.html
|
83
|
-
- docs/_includes/pagebar.html
|
84
|
-
- docs/_layouts/default.html
|
85
|
-
- docs/_layouts/docs.html
|
86
|
-
- docs/_layouts/home.html
|
87
|
-
- docs/_layouts/page.html
|
88
|
-
- docs/_posts/2017-09-14-welcome-to-jekyll.markdown
|
89
|
-
- docs/_posts/2017-09-21-0.17.0-released.md
|
90
|
-
- docs/_styles/card.scss
|
91
|
-
- docs/_styles/colors.scss
|
92
|
-
- docs/_styles/content.scss
|
93
|
-
- docs/_styles/cta.scss
|
94
|
-
- docs/_styles/grid.scss
|
95
|
-
- docs/_styles/media.scss
|
96
|
-
- docs/_styles/menu.scss
|
97
|
-
- docs/_styles/modifiers.scss
|
98
|
-
- docs/_styles/navbar.scss
|
99
|
-
- docs/_styles/pagebar.scss
|
100
|
-
- docs/_styles/reset.scss
|
101
|
-
- docs/_styles/scale.scss
|
102
|
-
- docs/_styles/spread.scss
|
103
|
-
- docs/_styles/styleguide.scss
|
104
|
-
- docs/_styles/syntax.scss
|
105
|
-
- docs/_styles/typography.scss
|
106
|
-
- docs/_styles/yard.scss
|
107
|
-
- docs/api.html
|
108
|
-
- docs/assets/calyx-docs.css
|
109
|
-
- docs/assets/calyx-flower-outline.svg
|
110
|
-
- docs/assets/calyx-flower-reverse.svg
|
111
|
-
- docs/assets/calyx-flower.svg
|
112
|
-
- docs/assets/logo-small.png
|
113
|
-
- docs/assets/logos/calyx-flower-1.svg
|
114
|
-
- docs/assets/logos/calyx-flower-2.svg
|
115
|
-
- docs/content/documentation.html
|
116
|
-
- docs/content/examples.html
|
117
|
-
- docs/content/examples/any-gradient.md
|
118
|
-
- docs/content/examples/faker.md
|
119
|
-
- docs/content/examples/tiny-woodland-bot.md
|
120
|
-
- docs/content/guides/context.md
|
121
|
-
- docs/content/guides/expressions.md
|
122
|
-
- docs/content/guides/features.md
|
123
|
-
- docs/content/guides/formats.md
|
124
|
-
- docs/content/guides/installation.md
|
125
|
-
- docs/content/guides/random.md
|
126
|
-
- docs/content/guides/results.md
|
127
|
-
- docs/content/index.html
|
128
|
-
- docs/content/introduction.md
|
129
|
-
- docs/content/introduction/concepts.md
|
130
|
-
- docs/content/introduction/contributing.md
|
131
|
-
- docs/content/introduction/tutorial.md
|
132
|
-
- docs/content/styleguide.html
|
133
|
-
- docs/docs.scss
|
134
|
-
- docs/index.html
|
135
|
-
- docs/package-lock.json
|
136
|
-
- docs/package.json
|
137
73
|
- examples/any_gradient.rb
|
138
74
|
- examples/faker.json
|
139
75
|
- examples/faker.rb
|
@@ -142,6 +78,7 @@ files:
|
|
142
78
|
- lib/calyx/errors.rb
|
143
79
|
- lib/calyx/format.rb
|
144
80
|
- lib/calyx/grammar.rb
|
81
|
+
- lib/calyx/mapping.rb
|
145
82
|
- lib/calyx/modifiers.rb
|
146
83
|
- lib/calyx/options.rb
|
147
84
|
- lib/calyx/production/choices.rb
|
@@ -175,8 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
175
112
|
- !ruby/object:Gem::Version
|
176
113
|
version: '0'
|
177
114
|
requirements: []
|
178
|
-
|
179
|
-
rubygems_version: 2.7.6
|
115
|
+
rubygems_version: 3.1.2
|
180
116
|
signing_key:
|
181
117
|
specification_version: 4
|
182
118
|
summary: Generate text with declarative recursive grammars
|
data/docs/404.html
DELETED
data/docs/CNAME
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
calyx-rb.org
|
data/docs/_config.yml
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
title: Calyx
|
2
|
-
email: me@maetl.net
|
3
|
-
description: >
|
4
|
-
A Ruby library for generating text with template expansion grammars.
|
5
|
-
baseurl: "" # the subpath of your site, e.g. /blog
|
6
|
-
url: "" # the base hostname & protocol for your site, e.g. http://example.com
|
7
|
-
twitter_username: maetl
|
8
|
-
github_username: maetl
|
9
|
-
|
10
|
-
# Build settings
|
11
|
-
markdown: kramdown
|
12
|
-
plugins:
|
13
|
-
- jekyll-feed
|
14
|
-
|
15
|
-
highlighter: rouge
|
16
|
-
|
17
|
-
# Exclude from processing.
|
18
|
-
# The following items will not be processed, by default. Create a custom list
|
19
|
-
# to override the default setting.
|
20
|
-
# exclude:
|
21
|
-
# - Gemfile
|
22
|
-
# - Gemfile.lock
|
23
|
-
# - node_modules
|
24
|
-
# - vendor/bundle/
|
25
|
-
# - vendor/cache/
|
26
|
-
# - vendor/gems/
|
27
|
-
# - vendor/ruby/
|
data/docs/_data/breadcrumbs.yml
DELETED
data/docs/_data/docs.yml
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
- title: Introduction
|
2
|
-
permalink: /introduction/
|
3
|
-
pages:
|
4
|
-
- title: Tutorial
|
5
|
-
permalink: /introduction/tutorial
|
6
|
-
- title: Key Concepts
|
7
|
-
permalink: /introduction/concepts
|
8
|
-
- title: For Beginners
|
9
|
-
permalink: /introduction/beginners
|
10
|
-
- title: Contributing
|
11
|
-
permalink: /introduction/contributing
|
12
|
-
- title: Guides
|
13
|
-
permalink: /guides/
|
14
|
-
pages:
|
15
|
-
- title: Installation
|
16
|
-
permalink: /guides/installation
|
17
|
-
- title: Generating Results
|
18
|
-
permalink: /guides/results
|
19
|
-
- title: Dynamic Rules
|
20
|
-
permalink: /guides/dynamic-rules
|
21
|
-
- title: Template Expressions
|
22
|
-
permalink: /guides/template-expressions
|
23
|
-
- title: Weighted Choices
|
24
|
-
permalink: /guides/weighted-choices
|
25
|
-
- title: Extending Grammars
|
26
|
-
permalink: /guides/extending
|
27
|
-
- title: Random Seeds
|
28
|
-
permalink: /guides/random-seeds
|
29
|
-
- title: Reference
|
30
|
-
permalink: /reference/
|
31
|
-
pages:
|
32
|
-
- title: Configuration Options
|
33
|
-
permalink: /reference/config
|
34
|
-
- title: API Listing
|
35
|
-
permalink: /reference/api
|
data/docs/_data/examples.yml
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
- title: Tiny Woodland Bot
|
2
|
-
description: Minimalist Twitter emoji scenes.
|
3
|
-
permalink: /examples/tiny-woodland-bot
|
4
|
-
- title: Any Gradient
|
5
|
-
description: A web service making linear gradients.
|
6
|
-
permalink: /examples/any-gradient
|
7
|
-
- title: Faker
|
8
|
-
description: Generates fake names and email addresses.
|
9
|
-
permalink: /examples/faker
|
@@ -1,36 +0,0 @@
|
|
1
|
-
<ol itemscope itemtype="http://schema.org/BreadcrumbList">
|
2
|
-
|
3
|
-
{% assign counter=0 %}
|
4
|
-
|
5
|
-
{% for category in site.categories %}
|
6
|
-
|
7
|
-
{% capture category_url %}{{ site.category_dir }}/{{ category | first | slugize | downcase | replace:' ','-' }}{% endcapture %}
|
8
|
-
{% capture category_name %}{{ category | first}}{% endcapture %}
|
9
|
-
|
10
|
-
{% for catpagename in page.categories %}
|
11
|
-
{% if category_name == catpagename %}
|
12
|
-
|
13
|
-
{% assign counter=counter | plus:1 %}
|
14
|
-
|
15
|
-
<li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
|
16
|
-
<a itemprop="item" href="{{ site.url }}{{ append:'/' | append:category_url | append:'/' }}">
|
17
|
-
<span itemprop="name">{{ catpagename }}</span>
|
18
|
-
</a>
|
19
|
-
<meta itemprop="position" content="{{counter}}" />
|
20
|
-
</li>
|
21
|
-
|
22
|
-
{% endif %}
|
23
|
-
{% endfor %}
|
24
|
-
|
25
|
-
{% endfor %}
|
26
|
-
|
27
|
-
{% assign counter=counter | plus:1 %}
|
28
|
-
|
29
|
-
<li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
|
30
|
-
<a itemprop="item" href="{{ site.url }}{{ page.url }}">
|
31
|
-
<span itemprop="name">{{ page.title }}</span>
|
32
|
-
</a>
|
33
|
-
<meta itemprop="position" content="{{counter}}" />
|
34
|
-
</li>
|
35
|
-
|
36
|
-
</ol>
|