yamlscript 0.1.65 → 0.1.67
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog.md +8 -0
- data/ReadMe.md +53 -21
- data/lib/yamlscript/version.rb +1 -1
- data/lib/yamlscript.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0882f28f507724e4423834e89d19e74aaf8e1c2bf5d5bd8b3b800f12c54088f9'
|
4
|
+
data.tar.gz: 68162847a5259cc137f59f0542a18b1f9f580d5438da5a9ad6de1b6fbd91a5fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 601b7202c6555f91558f5e2603c7d62f17eb2bc8092c2818adb4efcb59298d3e24120315c906ea1a3ece4d1da55464e2e040e27fa9f6982538c5983cab86d4b8
|
7
|
+
data.tar.gz: 3b3b6ce700936675fde16c7e19d31a74b806310cb86cbcb5d5c1981d63baa82dc745ef3c6ff3bdfcd3d359b7f5b6a317c1e88915a6da3dbcdbe7b9895a8c38f4
|
data/ChangeLog.md
CHANGED
data/ReadMe.md
CHANGED
@@ -3,37 +3,58 @@
|
|
3
3
|
YAMLScript
|
4
4
|
==========
|
5
5
|
|
6
|
-
|
6
|
+
Add Logic to Your YAML Files
|
7
7
|
|
8
8
|
|
9
9
|
## Synopsis
|
10
10
|
|
11
|
+
Load `file.yaml` with YAMLScript:
|
11
12
|
```yaml
|
12
|
-
|
13
|
+
!yamlscript/v0/
|
14
|
+
|
15
|
+
=>:
|
16
|
+
names-url =:
|
17
|
+
("https://raw.githubusercontent.com/dominictarr/" +
|
18
|
+
"random-name/master/first-names.json")
|
19
|
+
|
20
|
+
name-list =: &first-names json/load(curl(names-url))
|
21
|
+
|
22
|
+
# Data object with literal keys and generated values:
|
23
|
+
name:: rand-nth(*first-names)
|
24
|
+
aka:: name-list.rand-nth()
|
25
|
+
age:: &num 2 * 3 * 7
|
26
|
+
color:: &hue qw(red green blue yellow)
|
27
|
+
.shuffle()
|
28
|
+
.first()
|
29
|
+
title:: "$(*num) shades of $(*hue)."
|
30
|
+
```
|
13
31
|
|
14
|
-
|
15
|
-
|
32
|
+
and get:
|
33
|
+
```json
|
34
|
+
{
|
35
|
+
"name": "Dolores",
|
36
|
+
"aka": "Anita",
|
37
|
+
"age": 42,
|
38
|
+
"color": "green",
|
39
|
+
"title": "42 shades of green."
|
40
|
+
}
|
16
41
|
```
|
17
42
|
|
18
43
|
|
19
44
|
## Description
|
20
45
|
|
21
|
-
YAMLScript is a functional programming language with a
|
46
|
+
[YAMLScript](https://yamlscript.org) is a functional programming language with a
|
47
|
+
clean YAML syntax.
|
22
48
|
|
23
|
-
YAMLScript can be used for
|
49
|
+
YAMLScript can be used for enhancing ordinary [YAML](https://yaml.org) files
|
50
|
+
with functional operations, such as:
|
24
51
|
|
25
|
-
*
|
26
|
-
|
27
|
-
|
28
|
-
* Data transforms including ones defined by you
|
29
|
-
* Writing new programs and applications
|
30
|
-
* Run with `ys file.ys`
|
31
|
-
* Or compile to binary executable with `ys -C file.ys`
|
32
|
-
* Writing reusable shared libraries
|
33
|
-
* High level code instead of C
|
34
|
-
* Bindable to almost any programming language
|
52
|
+
* Import (parts of) other YAML files to any node
|
53
|
+
* String interpolation including function calls
|
54
|
+
* Data transforms including ones defined by you
|
35
55
|
|
36
|
-
YAMLScript should be a drop-in replacement for your YAML
|
56
|
+
This YAMLScript library should be a drop-in replacement for your current YAML
|
57
|
+
loader!
|
37
58
|
|
38
59
|
Most existing YAML files are already valid YAMLScript files.
|
39
60
|
This means that YAMLScript works as a normal YAML loader, but can also evaluate
|
@@ -49,10 +70,19 @@ YAMLScript is compiled to a native shared library (`libyamlscript.so`) that can
|
|
49
70
|
be used by any programming language that can load shared libraries.
|
50
71
|
|
51
72
|
To see the Clojure code that YAMLScript compiles to, you can use the YAMLScript
|
52
|
-
CLI binary
|
73
|
+
CLI binary `ys` to run:
|
53
74
|
|
54
75
|
```text
|
55
76
|
$ ys --compile file.ys
|
77
|
+
(def names-url
|
78
|
+
(+_ "https://raw.githubusercontent.com/dominictarr/"
|
79
|
+
"random-name/master/first-names.json"))
|
80
|
+
(def name-list (_& 'first-names (json/load (curl names-url))))
|
81
|
+
{"age" (_& 'num (*_ 2 3 7)),
|
82
|
+
"aka" (_-> name-list (list rand-nth)),
|
83
|
+
"color" (_& 'hue (_-> (qw red green blue yellow) (list shuffle) (list first))),
|
84
|
+
"name" (rand-nth (_** 'first-names)),
|
85
|
+
"title" (str (_** 'num) " shades of " (_** 'hue) ".")}
|
56
86
|
```
|
57
87
|
|
58
88
|
|
@@ -120,9 +150,11 @@ See https://github.com/yaml/yamlscript?#installing-yamlscript for more info.
|
|
120
150
|
|
121
151
|
## See Also
|
122
152
|
|
123
|
-
* [
|
124
|
-
* [
|
125
|
-
* [
|
153
|
+
* [YAMLScript Web Site](https://yamlscript.org)
|
154
|
+
* [YAMLScript Blog](https://yamlscript.org/blog)
|
155
|
+
* [YAMLScript Source Code](https://github.com/yaml/yamlscript)
|
156
|
+
* [YAMLScript Samples](https://github.com/yaml/yamlscript/tree/main/sample)
|
157
|
+
* [YAMLScript Programs](https://rosettacode.org/wiki/Category:YAMLScript)
|
126
158
|
* [YAML](https://yaml.org)
|
127
159
|
* [Clojure](https://clojure.org)
|
128
160
|
|
data/lib/yamlscript/version.rb
CHANGED
data/lib/yamlscript.rb
CHANGED
@@ -16,7 +16,7 @@ class YAMLScript
|
|
16
16
|
# This value is automatically updated by 'make bump'.
|
17
17
|
# The version number is used to find the correct shared library file.
|
18
18
|
# We currently only support binding to an exact version of libyamlscript.
|
19
|
-
YAMLSCRIPT_VERSION = '0.1.
|
19
|
+
YAMLSCRIPT_VERSION = '0.1.67'
|
20
20
|
|
21
21
|
# A low-level interface to the native library
|
22
22
|
module LibYAMLScript
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yamlscript
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.67
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ingy döt Net
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-07-
|
12
|
+
date: 2024-07-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|