yamlscript 0.2.3 → 0.2.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: adc5f948886a047ea3ad9e04bf56f0abd4abfffbbfcfd11951eab4cdfcf2f9eb
4
- data.tar.gz: a7d77e7b131306a7eed0afebafd5ac9343fdd6b8a87e5dd64856017e4a0700df
3
+ metadata.gz: 0a62fb7a5f809111d94cbcc1e0824396bd90ec24e0ad3c18aecebef412a213cc
4
+ data.tar.gz: 97f3b6629be5f8ca08ed1b9564539c0533fb40e10d67639e45c5fbf0526db367
5
5
  SHA512:
6
- metadata.gz: b33d07eb63edb779d4956d5375d527b8df8fc229532b372044473967ace12af264b87cb5ce2913cb38611f4a68861298d9f8dd2ea0c7335c65c412c90e3ec550
7
- data.tar.gz: fa6f7b8d7a97bc72528528b1bf90875405d8265f2ebc7f4375870e29acdebc872d4fb3369b1d8d57187faa332d187ce7a81efe26b11a2da50d82b86260d2dae3
6
+ metadata.gz: a89ad53088075994459d49b5ce23aff9b840cefdd8baf2f865d44d6d95fb79be2882d2f0503332ec595ddb47d8acc7823060c8e55806d8b307b1497e9c5e53f0
7
+ data.tar.gz: 17f583776e27b926edee1c4d877854ff9c34647ef4f85ef2d39ec18f199379aa23f517d97c6c460c5f6c3c8a78b975a30ce7bdeafdf38f83b2ff00eaeb535d25
data/ChangeLog.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [0.2.4] - 2025-09-16
2
+
3
+ - libys 0.2.4
4
+
1
5
  ## [0.2.3] - 2025-09-09
2
6
 
3
7
  - libys 0.2.3
data/ReadMe.md CHANGED
@@ -1,154 +1,166 @@
1
1
  <!-- DO NOT EDIT — THIS FILE WAS GENERATED -->
2
2
 
3
- YS / YAMLScript
4
- ===============
3
+ YAMLScript
4
+ ==========
5
5
 
6
6
  Add Logic to Your YAML Files
7
7
 
8
8
 
9
- ## Synopsis
9
+ ## Quick Start
10
10
 
11
- Load `file.yaml` with YS:
11
+ This library lets you load YAML files that may or may not contain
12
+ [YAMLScript](https://yamlscript.org) functional programming logic.
13
+ You can use it as a drop-in replacement for your current YAML loader.
14
+
15
+ Here's an example `config.yaml` that makes use of YAMLScript functions.
12
16
 
13
17
  ```yaml
18
+ # config.yaml with YAMLScript:
14
19
  !YS-v0:
15
20
 
16
- # Get data from external sources:
17
- names-url =:
18
- 'github:dominictarr/random-name/first-names.json'
19
-
20
- name-list =: names-url:curl:json/load
21
-
22
- # Data object with literal keys and generated values:
23
- name:: name-list:shuffle:first
24
- aka:: name-list:rand-nth
25
- age:: &num 2 * 3 * 7
26
- color:: &hue
27
- rand-nth: qw(red green blue yellow)
28
- title:: "$(*num) shades of $(*hue)."
21
+ # Define variables
22
+ db-host =: ENV.DB_HOST || 'localhost'
23
+ db-port =: ENV.DB_PORT || 5432
24
+ deploy =: ENV.DEPLOYMENT || 'dev'
25
+ :when deploy !~ /^(dev|stage|prod)/:
26
+ die: |
27
+ Invalid deployment value '$deploy'.
28
+ Must be one of: dev | stage | prod
29
+
30
+ # Normal YAML data
31
+ description: Dynamic application configuration
32
+
33
+ # Dynamic data values
34
+ database:
35
+ host:: db-host
36
+ port:: db-port:num
37
+ name:: "app_$deploy"
38
+
39
+ # Import external data
40
+ features:: load('common.yaml').features
41
+
42
+ # Use logic and conditions
43
+ cache:
44
+ # Variable scoped to this mapping
45
+ enabled =: deploy == 'production'
46
+
47
+ directory: .cache
48
+ enabled:: enabled
49
+ limit: 100
50
+ # Conditional key/value pairs
51
+ :when enabled::
52
+ limit:: 1000
53
+ ttl:: 60 * 60 # 3600
29
54
  ```
30
55
 
31
- and get:
32
- ```json
33
- {
34
- "name": "Dolores",
35
- "aka": "Anita",
36
- "age": 42,
37
- "color": "green",
38
- "title": "42 shades of green."
39
- }
40
- ```
41
56
 
57
+ ## What is YAMLScript?
42
58
 
43
- ## Description
59
+ YAMLScript is a functional programming language that can be embedded in YAML.
60
+ Its syntax is 100% YAML so files that embed it are still valid YAML files.
44
61
 
45
- [YS](https://yamlscript.org) is a functional programming language with a clean
46
- YAML syntax.
62
+ The YAMLScript project provides YAML loader libraries for many programming
63
+ languages.
64
+ They can be used to load any YAML config files properly, whether or not they
65
+ contain functional programming logic.
47
66
 
48
- YS can be used for enhancing ordinary [YAML](https://yaml.org) files with
49
- functional operations, such as:
67
+ It's perfect for:
50
68
 
51
- * Import (parts of) other YAML files to any node
52
- * String interpolation including function calls
53
- * Data transforms including ones defined by you
69
+ * **Configuration files** that need logic, variables, and dynamic values
70
+ * **Data transformation** with built-in functions for JSON, YAML, and text
71
+ processing
72
+ * **Templating** with powerful string interpolation and data manipulation
73
+ * **Scripting** as a complete functional programming language
54
74
 
55
- This YS library should be a drop-in replacement for your current YAML loader!
56
75
 
57
- Most existing YAML files are already valid YS files.
58
- This means that YS works as a normal YAML loader, but can also evaluate
59
- functional expressions if asked to.
76
+ ## Key Features
60
77
 
61
- Under the hood, YS code compiles to the Clojure programming language.
62
- This makes YS a complete functional programming language right out of the box.
78
+ * **Drop-in YAML replacement** Works with your existing YAML files
79
+ * **Variables & functions** Define and reuse values throughout your files
80
+ * **External data loading** – Import JSON, YAML, or data from URLs
81
+ * **Conditional logic** – Use if/then/else and pattern matching
82
+ * **Data transformation** – Built-ins for transforming & manipulating data
83
+ * **String interpolation** – Embed expressions/variables directly in strings
84
+ * **No JVM required** – Runs as a native library despite compiling to Clojure
63
85
 
64
- Even though YS compiles to Clojure, and Clojure compiles to Java, there is no
65
- dependency on Java or the JVM.
66
- YS is compiled to a native shared library (`libys.so`) that can be used
67
- by any programming language that can load shared libraries.
68
86
 
69
- To see the Clojure code that YS compiles to, you can use the YS
70
- CLI binary `ys` to run:
87
+ ## How It Works
71
88
 
72
- ```text
73
- $ ys --compile file.ys
74
- (let
75
- [names-url "https://raw.githubusercontent.com/dominictarr/random-name/master/first-names.json"
76
- name-list (json/load (curl names-url))]
77
- (%
78
- "name" (first (shuffle name-list))
79
- "aka" (rand-nth name-list)
80
- "age" (_& 'num (mul+ 2 3 7))
81
- "color" (_& 'hue (rand-nth (qw red green blue yellow)))
82
- "title" (str (_** 'num) " shades of " (_** 'hue) ".")))
83
- ```
89
+ YAMLScript extends YAML with a simple, elegant syntax:
84
90
 
85
- ## Ruby Usage
91
+ ```yaml
92
+ # file.yaml
93
+ !YS-v0: # Enable YAMLScript
86
94
 
87
- File `prog.rb`:
95
+ name =: 'World' # Variable assignment
96
+ nums =:: [1, 2, 3] # Any YAML value
88
97
 
89
- ```ruby
90
- require 'yamlscript'
91
- input = IO.read('file.ys')
92
- ys = YAMLScript.new
93
- data = ys.load(input)
94
- puts data
98
+ # Literal YAML with ':'
99
+ a key: a value
100
+
101
+ # Evaluated expressions with '::'
102
+ message:: "Hello, $name!"
103
+ sum:: nums.reduce(+)
104
+ timestamp:: now():str
95
105
  ```
96
106
 
97
- File `file.ys`:
107
+ You can load this file from a program as described below, or you can use the
108
+ `ys` YAMLScript binary to load the file from the command line:
98
109
 
99
- ```yaml
100
- !YS-v0:
110
+ ```bash
111
+ $ ys -Y file.yaml
112
+ a key: a value
113
+ message: Hello, World!
114
+ sum: 6
115
+ timestamp: '2025-09-14T22:35:42.832470203Z'
116
+ ```
101
117
 
102
- name =: "World"
118
+ Under the hood, YAMLScript compiles YAML to Clojure and evaluates it, giving
119
+ you access to a rich functional programming environment.
103
120
 
104
- foo: [1, 2, ! inc(41)]
105
- bar:: load("other.yaml")
106
- baz:: "Hello, $name!"
107
- ```
121
+ ## Ruby Usage
108
122
 
109
- File `other.yaml`:
123
+ Use `yamlscript` as a drop-in replacement for your current YAML loader:
110
124
 
111
- ```yaml
112
- oh: Hello
113
- ```
125
+ ```ruby
126
+ # program.rb
127
+ require 'yamlscript'
128
+ require 'json'
114
129
 
115
- Run:
130
+ ys = YAMLScript.new
131
+
132
+ # Load from file
133
+ input = File.read('config.yaml')
134
+ config = ys.load(input)
116
135
 
117
- ```text
118
- $ ruby prog.rb
119
- {"foo"=>[1, 2, 42], "bar"=>{"oh"=>"Hello"}, "baz"=>"Hello, World!"}
136
+ # Convert to JSON
137
+ puts JSON.pretty_generate(config)
120
138
  ```
121
139
 
122
140
 
123
141
  ## Installation
124
142
 
125
- You can install this module like any other Ruby module:
143
+ Install YAMLScript for Ruby and the `libys.so` shared library:
126
144
 
127
145
  ```bash
128
146
  gem install yamlscript
147
+ curl -sSL https://yamlscript.org/install | bash
129
148
  ```
130
149
 
131
- but you will need to have a system install of `libys.so`.
150
+ See <https://yamlscript.org/doc/install/> for more info.
132
151
 
133
- One simple way to do that is with:
134
152
 
135
- ```bash
136
- curl https://yamlscript.org/install | bash
137
- ```
138
-
139
- > Note: The above command will install the latest version of the YAMLScript
140
- command line utility, `ys`, and the shared library, `libys.so`, into
141
- `~/local/bin` and `~/.local/lib` respectively.
153
+ ### Requirements
142
154
 
143
- See <https://yamlscript.org/doc/install/> for more info.
155
+ * Ruby 2.7 or higher
144
156
 
145
157
  ## See Also
146
158
 
147
- * [YS Web Site](https://yamlscript.org)
148
- * [YS Blog](https://yamlscript.org/blog)
149
- * [YS Source Code](https://github.com/yaml/yamlscript)
150
- * [YS Samples](https://github.com/yaml/yamlscript/tree/main/sample)
151
- * [YS Programs](https://rosettacode.org/wiki/Category:YAMLScript)
159
+ * [YAMLScript Web Site](https://yamlscript.org)
160
+ * [Learn YAMLScript](https://exercism.org/tracks/yamlscript)
161
+ * [YAMLScript Blog](https://yamlscript.org/blog)
162
+ * [YAMLScript Source Code](https://github.com/yaml/yamlscript)
163
+ * [YAMLScript Programs](https://rosettacode.org/wiki/Category:YAMLScript)
152
164
  * [YAML](https://yaml.org)
153
165
  * [Clojure](https://clojure.org)
154
166
 
@@ -163,5 +175,5 @@ See <https://yamlscript.org/doc/install/> for more info.
163
175
  Copyright 2022-2025 Ingy döt Net <ingy@ingy.net>
164
176
 
165
177
  This project is licensed under the terms of the `MIT` license.
166
- See [LICENSE](https://github.com/yaml/yamlscript/blob/main/License) for
167
- more details.
178
+ See [LICENSE](https://github.com/yaml/yamlscript/blob/main/License) for more
179
+ details.
data/doc/readme.md CHANGED
@@ -1,59 +1,35 @@
1
1
  ## Ruby Usage
2
2
 
3
- File `prog.rb`:
3
+ Use `yamlscript` as a drop-in replacement for your current YAML loader:
4
4
 
5
5
  ```ruby
6
+ # program.rb
6
7
  require 'yamlscript'
7
- input = IO.read('file.ys')
8
- ys = YAMLScript.new
9
- data = ys.load(input)
10
- puts data
11
- ```
12
-
13
- File `file.ys`:
14
-
15
- ```yaml
16
- !YS-v0:
17
-
18
- name =: "World"
19
-
20
- foo: [1, 2, ! inc(41)]
21
- bar:: load("other.yaml")
22
- baz:: "Hello, $name!"
23
- ```
24
-
25
- File `other.yaml`:
8
+ require 'json'
26
9
 
27
- ```yaml
28
- oh: Hello
29
- ```
10
+ ys = YAMLScript.new
30
11
 
31
- Run:
12
+ # Load from file
13
+ input = File.read('config.yaml')
14
+ config = ys.load(input)
32
15
 
33
- ```text
34
- $ ruby prog.rb
35
- {"foo"=>[1, 2, 42], "bar"=>{"oh"=>"Hello"}, "baz"=>"Hello, World!"}
16
+ # Convert to JSON
17
+ puts JSON.pretty_generate(config)
36
18
  ```
37
19
 
38
20
 
39
21
  ## Installation
40
22
 
41
- You can install this module like any other Ruby module:
23
+ Install YAMLScript for Ruby and the `libys.so` shared library:
42
24
 
43
25
  ```bash
44
26
  gem install yamlscript
27
+ curl -sSL https://yamlscript.org/install | bash
45
28
  ```
46
29
 
47
- but you will need to have a system install of `libys.so`.
30
+ See <https://yamlscript.org/doc/install/> for more info.
48
31
 
49
- One simple way to do that is with:
50
32
 
51
- ```bash
52
- curl https://yamlscript.org/install | bash
53
- ```
54
-
55
- > Note: The above command will install the latest version of the YAMLScript
56
- command line utility, `ys`, and the shared library, `libys.so`, into
57
- `~/local/bin` and `~/.local/lib` respectively.
33
+ ### Requirements
58
34
 
59
- See <https://yamlscript.org/doc/install/> for more info.
35
+ * Ruby 2.7 or higher
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class YAMLScript
4
- VERSION = "0.2.3"
4
+ VERSION = "0.2.4"
5
5
  end
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 libys.
19
- YAMLSCRIPT_VERSION = '0.2.3'
19
+ YAMLSCRIPT_VERSION = '0.2.4'
20
20
 
21
21
  # A low-level interface to the native library
22
22
  module LibYS
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.2.3
4
+ version: 0.2.4
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: 2025-09-09 00:00:00.000000000 Z
12
+ date: 2025-09-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest