calyx 0.17.1 → 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/docs/_data/breadcrumbs.yml +9 -0
- data/docs/_data/docs.yml +35 -0
- data/docs/_data/examples.yml +9 -0
- data/docs/_includes/breadcrumbs.html +36 -0
- data/docs/_includes/contents.html +12 -0
- data/docs/_includes/icon-github.html +4 -0
- data/docs/_includes/icon-rubygems.html +9 -0
- data/docs/_includes/navbar.html +24 -0
- data/docs/_includes/pagebar.html +12 -0
- data/docs/_layouts/default.html +3 -23
- data/docs/_layouts/docs.html +14 -0
- data/docs/_layouts/home.html +13 -0
- data/docs/_layouts/page.html +20 -0
- data/docs/_posts/2017-09-14-welcome-to-jekyll.markdown +1 -1
- data/docs/_posts/2017-09-21-0.17.0-released.md +10 -0
- data/docs/_styles/card.scss +7 -0
- data/docs/_styles/colors.scss +18 -0
- data/docs/_styles/content.scss +57 -0
- data/docs/_styles/cta.scss +25 -0
- data/docs/_styles/grid.scss +22 -0
- data/docs/_styles/media.scss +50 -0
- data/docs/_styles/menu.scss +54 -0
- data/docs/_styles/modifiers.scss +3 -0
- data/docs/_styles/navbar.scss +161 -0
- data/docs/_styles/pagebar.scss +32 -0
- data/docs/_styles/reset.scss +92 -0
- data/docs/_styles/scale.scss +23 -0
- data/docs/_styles/spread.scss +55 -0
- data/docs/_styles/styleguide.scss +52 -0
- data/docs/_styles/syntax.scss +84 -0
- data/docs/_styles/typography.scss +49 -0
- data/docs/_styles/yard.scss +36 -0
- data/docs/api.html +9662 -0
- data/docs/assets/calyx-docs.css +253 -162
- data/docs/assets/calyx-flower-outline.svg +202 -0
- data/docs/assets/calyx-flower-reverse.svg +202 -0
- data/docs/assets/calyx-flower.svg +202 -0
- data/docs/assets/logo-small.png +0 -0
- data/docs/assets/logos/calyx-flower-1.svg +22 -0
- data/docs/assets/logos/calyx-flower-2.svg +21 -0
- data/docs/content/documentation.html +20 -0
- data/docs/content/examples.html +12 -0
- data/docs/content/examples/any-gradient.md +32 -0
- data/docs/content/examples/faker.md +16 -0
- data/docs/content/examples/tiny-woodland-bot.md +24 -0
- data/docs/{guide → content/guides}/context.md +2 -2
- data/docs/{guide → content/guides}/expressions.md +2 -2
- data/docs/content/guides/features.md +50 -0
- data/docs/{guide → content/guides}/formats.md +1 -1
- data/docs/content/guides/installation.md +51 -0
- data/docs/{guide → content/guides}/random.md +1 -1
- data/docs/{guide → content/guides}/results.md +1 -1
- data/docs/content/index.html +44 -0
- data/docs/content/introduction.md +23 -0
- data/docs/content/introduction/concepts.md +82 -0
- data/docs/content/introduction/contributing.md +43 -0
- data/docs/content/introduction/tutorial.md +129 -0
- data/docs/content/styleguide.html +71 -0
- data/docs/docs.scss +94 -0
- data/docs/index.html +1 -23
- data/docs/package.json +1 -1
- data/lib/calyx/production/choices.rb +7 -0
- data/lib/calyx/production/unique.rb +0 -2
- data/lib/calyx/registry.rb +5 -0
- data/lib/calyx/rule.rb +4 -0
- data/lib/calyx/version.rb +1 -1
- metadata +59 -13
- data/docs/about.md +0 -18
- data/docs/calyx-docs.scss +0 -66
- data/docs/guide/examples.md +0 -59
- data/docs/guide/getting-started.md +0 -129
- data/docs/guide/installation.md +0 -19
data/docs/about.md
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
---
|
2
|
-
layout: page
|
3
|
-
title: About
|
4
|
-
permalink: /about/
|
5
|
-
---
|
6
|
-
|
7
|
-
This is the base Jekyll theme. You can find out more info about customizing your Jekyll theme, as well as basic Jekyll usage documentation at [jekyllrb.com](https://jekyllrb.com/)
|
8
|
-
|
9
|
-
You can find the source code for Minima at GitHub:
|
10
|
-
[jekyll][jekyll-organization] /
|
11
|
-
[minima](https://github.com/jekyll/minima)
|
12
|
-
|
13
|
-
You can find the source code for Jekyll at GitHub:
|
14
|
-
[jekyll][jekyll-organization] /
|
15
|
-
[jekyll](https://github.com/jekyll/jekyll)
|
16
|
-
|
17
|
-
|
18
|
-
[jekyll-organization]: https://github.com/jekyll
|
data/docs/calyx-docs.scss
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
$green: #218764;
|
2
|
-
|
3
|
-
$family-monospace: "Oxygen Mono", "Monaco", Inconsolata, monospace;
|
4
|
-
$family-sans-serif: "Libre Franklin", sans-serif;
|
5
|
-
|
6
|
-
$background: #fafafa;
|
7
|
-
|
8
|
-
$content-pre-padding: 0;
|
9
|
-
$content-heading-color: #218764;
|
10
|
-
$content-heading-weight: 700;
|
11
|
-
|
12
|
-
$navbar-item-color: #fff;
|
13
|
-
$navbar-background-color: #1BDE81;
|
14
|
-
$navbar-item-hover-color: $navbar-item-color;
|
15
|
-
$navbar-item-hover-background-color: darken($navbar-background-color, 6%);
|
16
|
-
$navbar-item-active-background-color: #1BDE81;
|
17
|
-
|
18
|
-
@import "bulma";
|
19
|
-
@import "syntax";
|
20
|
-
@import "styleguide";
|
21
|
-
|
22
|
-
body {
|
23
|
-
font-weight: 500;
|
24
|
-
height: 100%;
|
25
|
-
background-color: $background;
|
26
|
-
}
|
27
|
-
|
28
|
-
.sidebar {
|
29
|
-
background-color: #eee;
|
30
|
-
height: calc(100vh - 3.25rem);
|
31
|
-
}
|
32
|
-
|
33
|
-
.navbar-item {
|
34
|
-
font-weight: 500;
|
35
|
-
}
|
36
|
-
|
37
|
-
.navbar-brand {
|
38
|
-
.navbar-item {
|
39
|
-
font-family: "Work Sans";
|
40
|
-
font-weight: 800;
|
41
|
-
font-size: 24px;
|
42
|
-
line-height: 24px;
|
43
|
-
|
44
|
-
span {
|
45
|
-
margin-left: 6px;
|
46
|
-
}
|
47
|
-
}
|
48
|
-
}
|
49
|
-
|
50
|
-
.content {
|
51
|
-
h1, h2, h3 {
|
52
|
-
letter-spacing: -1px;
|
53
|
-
font-family: "Work Sans";
|
54
|
-
font-weight: 700;
|
55
|
-
}
|
56
|
-
|
57
|
-
.highlighter-rouge {
|
58
|
-
margin-bottom: 1rem;
|
59
|
-
}
|
60
|
-
|
61
|
-
pre {
|
62
|
-
code {
|
63
|
-
font-size: 1em;
|
64
|
-
}
|
65
|
-
}
|
66
|
-
}
|
data/docs/guide/examples.md
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
---
|
2
|
-
layout: default
|
3
|
-
title: Examples
|
4
|
-
permalink: /examples/
|
5
|
-
---
|
6
|
-
|
7
|
-
# Examples
|
8
|
-
|
9
|
-
The best way to get started quickly is to install the gem and run the examples locally.
|
10
|
-
|
11
|
-
## Any Gradient
|
12
|
-
|
13
|
-
Requires Roda and Rack to be available.
|
14
|
-
|
15
|
-
```
|
16
|
-
gem install roda
|
17
|
-
```
|
18
|
-
|
19
|
-
Demonstrates how to use Calyx to construct SVG graphics. **Any Gradient** generates a rectangle with a linear gradient of random colours.
|
20
|
-
|
21
|
-
Run as a web server and preview the output in a browser (`http://localhost:9292`):
|
22
|
-
|
23
|
-
```
|
24
|
-
ruby examples/any_gradient.rb
|
25
|
-
```
|
26
|
-
|
27
|
-
Or generate SVG files via a command line pipe:
|
28
|
-
|
29
|
-
```
|
30
|
-
ruby examples/any_gradient > gradient1.xml
|
31
|
-
```
|
32
|
-
|
33
|
-
## Tiny Woodland Bot
|
34
|
-
|
35
|
-
Requires the Twitter client gem and API access configured for a specific Twitter handle.
|
36
|
-
|
37
|
-
```
|
38
|
-
gem install twitter
|
39
|
-
```
|
40
|
-
|
41
|
-
Demonstrates how to use Calyx to make a minimal Twitter bot that periodically posts unique tweets. See [@tiny_woodland on Twitter](https://twitter.com/tiny_woodland) and the [writeup here](http://maetl.net/notes/storyboard/tiny-woodlands).
|
42
|
-
|
43
|
-
```
|
44
|
-
TWITTER_CONSUMER_KEY=XXX-XXX
|
45
|
-
TWITTER_CONSUMER_SECRET=XXX-XXX
|
46
|
-
TWITTER_ACCESS_TOKEN=XXX-XXX
|
47
|
-
TWITTER_CONSUMER_SECRET=XXX-XXX
|
48
|
-
ruby examples/tiny_woodland_bot.rb
|
49
|
-
```
|
50
|
-
|
51
|
-
## Faker
|
52
|
-
|
53
|
-
[Faker](https://github.com/stympy/faker) is a popular library for generating fake names and associated sample data like internet addresses, company names and locations.
|
54
|
-
|
55
|
-
This example demonstrates how to use Calyx to reproduce the same functionality using custom lists defined in a YAML configuration file.
|
56
|
-
|
57
|
-
```
|
58
|
-
ruby examples/faker.rb
|
59
|
-
```
|
@@ -1,129 +0,0 @@
|
|
1
|
-
---
|
2
|
-
layout: default
|
3
|
-
title: Getting Started
|
4
|
-
permalink: /getting-started/
|
5
|
-
---
|
6
|
-
|
7
|
-
# Getting Started
|
8
|
-
|
9
|
-
Require the library and inherit from `Calyx::Grammar` to construct a set of rules to generate a text.
|
10
|
-
|
11
|
-
```ruby
|
12
|
-
require 'calyx'
|
13
|
-
|
14
|
-
class HelloWorld < Calyx::Grammar
|
15
|
-
start 'Hello world.'
|
16
|
-
end
|
17
|
-
```
|
18
|
-
|
19
|
-
To generate the text itself, initialize the object and call the `generate` method.
|
20
|
-
|
21
|
-
```ruby
|
22
|
-
hello = HelloWorld.new
|
23
|
-
hello.generate
|
24
|
-
# > "Hello world."
|
25
|
-
```
|
26
|
-
|
27
|
-
Obviously, this hardcoded sentence isn’t very interesting by itself. Possible variations can be added to the text by adding additional rules which provide a named set of text strings. The rule delimiter syntax (`{}`) can be used to substitute the generated content of other rules.
|
28
|
-
|
29
|
-
```ruby
|
30
|
-
class HelloWorld < Calyx::Grammar
|
31
|
-
start '{greeting} world.'
|
32
|
-
greeting 'Hello', 'Hi', 'Hey', 'Yo'
|
33
|
-
end
|
34
|
-
```
|
35
|
-
|
36
|
-
Each time `#generate` runs, it evaluates the tree and randomly selects variations of rules to construct a resulting string.
|
37
|
-
|
38
|
-
```ruby
|
39
|
-
hello = HelloWorld.new
|
40
|
-
|
41
|
-
hello.generate
|
42
|
-
# > "Hi world."
|
43
|
-
|
44
|
-
hello.generate
|
45
|
-
# > "Hello world."
|
46
|
-
|
47
|
-
hello.generate
|
48
|
-
# > "Yo world."
|
49
|
-
```
|
50
|
-
|
51
|
-
By convention, the `start` rule specifies the default starting point for generating the final text. You can start from any other named rule by passing it explicitly to the generate method.
|
52
|
-
|
53
|
-
```ruby
|
54
|
-
class HelloWorld < Calyx::Grammar
|
55
|
-
hello 'Hello world.'
|
56
|
-
end
|
57
|
-
|
58
|
-
hello = HelloWorld.new
|
59
|
-
hello.generate(:hello)
|
60
|
-
```
|
61
|
-
|
62
|
-
## Block Constructors
|
63
|
-
|
64
|
-
As an alternative to subclassing, you can also construct rules unique to an instance by passing a block when initializing the class:
|
65
|
-
|
66
|
-
```ruby
|
67
|
-
hello = Calyx::Grammar.new do
|
68
|
-
start '{greeting} world.'
|
69
|
-
greeting 'Hello', 'Hi', 'Hey', 'Yo'
|
70
|
-
end
|
71
|
-
|
72
|
-
hello.generate
|
73
|
-
```
|
74
|
-
|
75
|
-
## Template Expressions
|
76
|
-
|
77
|
-
Basic rule substitution uses single curly brackets as delimiters for template expressions:
|
78
|
-
|
79
|
-
```ruby
|
80
|
-
fruit = Calyx::Grammar.new do
|
81
|
-
start '{colour} {fruit}'
|
82
|
-
colour 'red', 'green', 'yellow'
|
83
|
-
fruit 'apple', 'pear', 'tomato'
|
84
|
-
end
|
85
|
-
|
86
|
-
6.times { fruit.generate }
|
87
|
-
# => "yellow pear"
|
88
|
-
# => "red apple"
|
89
|
-
# => "green tomato"
|
90
|
-
# => "red pear"
|
91
|
-
# => "yellow tomato"
|
92
|
-
# => "green apple"
|
93
|
-
```
|
94
|
-
|
95
|
-
## Nesting and Substitution
|
96
|
-
|
97
|
-
Rules are recursive. They can be arbitrarily nested and connected to generate larger and more complex texts.
|
98
|
-
|
99
|
-
```ruby
|
100
|
-
class HelloWorld < Calyx::Grammar
|
101
|
-
start '{greeting} {world_phrase}.'
|
102
|
-
greeting 'Hello', 'Hi', 'Hey', 'Yo'
|
103
|
-
world_phrase '{happy_adj} world', '{sad_adj} world', 'world'
|
104
|
-
happy_adj 'wonderful', 'amazing', 'bright', 'beautiful'
|
105
|
-
sad_adj 'cruel', 'miserable'
|
106
|
-
end
|
107
|
-
```
|
108
|
-
|
109
|
-
Nesting and hierarchy can be manipulated to balance consistency with novelty. The exact same word atoms can be combined in a variety of ways to produce strikingly different resulting texts.
|
110
|
-
|
111
|
-
```ruby
|
112
|
-
module HelloWorld
|
113
|
-
class Sentiment < Calyx::Grammar
|
114
|
-
start '{happy_phrase}', '{sad_phrase}'
|
115
|
-
happy_phrase '{happy_greeting} {happy_adj} world.'
|
116
|
-
happy_greeting 'Hello', 'Hi', 'Hey', 'Yo'
|
117
|
-
happy_adj 'wonderful', 'amazing', 'bright', 'beautiful'
|
118
|
-
sad_phrase '{sad_greeting} {sad_adj} world.'
|
119
|
-
sad_greeting 'Goodbye', 'So long', 'Farewell'
|
120
|
-
sad_adj 'cruel', 'miserable'
|
121
|
-
end
|
122
|
-
|
123
|
-
class Mixed < Calyx::Grammar
|
124
|
-
start '{greeting} {adj} world.'
|
125
|
-
greeting 'Hello', 'Hi', 'Hey', 'Yo', 'Goodbye', 'So long', 'Farewell'
|
126
|
-
adj 'wonderful', 'amazing', 'bright', 'beautiful', 'cruel', 'miserable'
|
127
|
-
end
|
128
|
-
end
|
129
|
-
```
|