kojo 0.3.8 → 0.3.9
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/README.md +29 -11
- data/lib/kojo/commands/config.rb +1 -1
- data/lib/kojo/commands/dir.rb +1 -1
- data/lib/kojo/commands/file.rb +1 -1
- data/lib/kojo/commands/to_json.rb +1 -1
- data/lib/kojo/config.rb +1 -1
- data/lib/kojo/extensions/yaml.rb +10 -0
- data/lib/kojo/front_matter_template.rb +1 -1
- data/lib/kojo/refinements/string.rb +1 -1
- data/lib/kojo/version.rb +1 -1
- data/lib/kojo.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1952c33f6d6360f1a027ee30eefcfea5636a062c2c28c02d83916d99e51ed7c1
|
|
4
|
+
data.tar.gz: 9554ea0de969c79e11d40b237d4ffb24c3bceead6dc863511124af6b4753841b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 40bdbcfa32871516c1776923dffd3d78b0757463941da85708b4292e9a84f5c8308dd655e1707493e6da9411771a12c18a57d7098ae0d85cc1c537bf41d3fcb7
|
|
7
|
+
data.tar.gz: 76d43feccd9c0210bd3239f86b089a27527fdbd293daaf771dcb3d8170dd5d57a864e2a7fc399a00b6989d963659eb1e7ea9a7b8e7f23561a288a27e7187d941
|
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<div align='center'>
|
|
2
2
|
|
|
3
|
-

|
|
4
4
|
|
|
5
5
|
# Kojo Configuration Ninja
|
|
6
6
|
|
|
@@ -26,6 +26,7 @@ format.
|
|
|
26
26
|
- [Transform an Entire Folder](#transform-an-entire-folder)
|
|
27
27
|
- [Transform One to Many using Config](#transform-one-to-many-using-config)
|
|
28
28
|
- [Transform One to Many using Front Matter](#transform-one-to-many-using-front-matter)
|
|
29
|
+
- [Convert YAML to JSON](#convert-yaml-to-json)
|
|
29
30
|
- [Interactive Form Templates](#interactive-form-templates)
|
|
30
31
|
- [Conditions and Loops with ERB](#conditions-and-loops-with-erb)
|
|
31
32
|
- [Interactive Fallback](#interactive-fallback)
|
|
@@ -54,7 +55,7 @@ relevant files, and the expected output.
|
|
|
54
55
|
|
|
55
56
|
### Variables
|
|
56
57
|
|
|
57
|
-

|
|
58
59
|
|
|
59
60
|
Include variables in your configuration templates by using this syntax:
|
|
60
61
|
`%{varname}`
|
|
@@ -65,9 +66,13 @@ Include variables in your configuration templates by using this syntax:
|
|
|
65
66
|
- Variables from the top level will be forwarded downstream, and aggregated
|
|
66
67
|
with any additional variables that are defined in subsequent `@imports`.
|
|
67
68
|
|
|
69
|
+
Note that since the `%` sign is used for variable replacement, if you want
|
|
70
|
+
your generated file to include a literal percent sign, you need to escape it
|
|
71
|
+
as `%%` in your template.
|
|
72
|
+
|
|
68
73
|
### Import
|
|
69
74
|
|
|
70
|
-

|
|
71
76
|
|
|
72
77
|
Use the `@import filename` directive anywhere to include another file in the
|
|
73
78
|
resulting configuration file.
|
|
@@ -88,7 +93,7 @@ The space after `filename` is optional.
|
|
|
88
93
|
|
|
89
94
|
### Transform an Entire Folder
|
|
90
95
|
|
|
91
|
-

|
|
92
97
|
|
|
93
98
|
Process a folder containing templates and `@imports`, and generate a mirror
|
|
94
99
|
output folder, with all the variables and `@imports` evaluated.
|
|
@@ -97,7 +102,7 @@ You may use `%{variables}` in filenames.
|
|
|
97
102
|
|
|
98
103
|
### Transform One to Many using Config
|
|
99
104
|
|
|
100
|
-

|
|
101
106
|
|
|
102
107
|
Using the `kojo config` command together with a simple definitions file, you
|
|
103
108
|
can:
|
|
@@ -142,7 +147,7 @@ output:
|
|
|
142
147
|
|
|
143
148
|
### Transform One to Many using Front Matter
|
|
144
149
|
|
|
145
|
-

|
|
146
151
|
|
|
147
152
|
Define a template that contains the instructions on how to transform it as a
|
|
148
153
|
YAML front matter.
|
|
@@ -150,7 +155,7 @@ YAML front matter.
|
|
|
150
155
|
The YAML front matter should be structured like this:
|
|
151
156
|
|
|
152
157
|
```yaml
|
|
153
|
-
|
|
158
|
+
filename1:
|
|
154
159
|
arg: value
|
|
155
160
|
another_arg: value
|
|
156
161
|
|
|
@@ -165,9 +170,22 @@ Your template that uses %{arg} goes here
|
|
|
165
170
|
Additional arguments provided to the command line, will also be transferred
|
|
166
171
|
to the template.
|
|
167
172
|
|
|
173
|
+
### Convert YAML to JSON
|
|
174
|
+
|
|
175
|
+

|
|
176
|
+
|
|
177
|
+
Convert one or more YAML files to JSON.
|
|
178
|
+
|
|
179
|
+
This can be useful when you require JSON files as output, but wish to edit
|
|
180
|
+
(or generate using Kojo) using the less error-prone and more aesthetically
|
|
181
|
+
pleasing YAML format.
|
|
182
|
+
|
|
183
|
+
Note that this Kojo command does not provide any additional preprocessing - the
|
|
184
|
+
input files should be valid YAML.
|
|
185
|
+
|
|
168
186
|
### Interactive Form Templates
|
|
169
187
|
|
|
170
|
-

|
|
171
189
|
|
|
172
190
|
Using the `kojo form` command lets you define an ERB or [ERBX][erbx] template, and include interactive prompts to enter the input.
|
|
173
191
|
|
|
@@ -177,11 +195,11 @@ Using the `kojo form` command lets you define an ERB or [ERBX][erbx] template, a
|
|
|
177
195
|
4. If there is a file with the same name as the template, and with an `.rb` extension (for example `form.md` and `form.md.rb`), then the ruby file will be loaded into the ERB template as if it was written inside it.
|
|
178
196
|
5. If you prefer using a single template file (without the ruby appendix), you can simply use regular ERB/ERBX tags, like demonstrated below.
|
|
179
197
|
|
|
180
|
-

|
|
181
199
|
|
|
182
200
|
### Conditions and Loops with ERB
|
|
183
201
|
|
|
184
|
-

|
|
185
203
|
|
|
186
204
|
Template files are evaluated using ERB, so you can use any Ruby code for more
|
|
187
205
|
advanced templates (for conditions, loops etc.).
|
|
@@ -197,7 +215,7 @@ Use this syntax for ruby code:
|
|
|
197
215
|
When Kojo encounters a variable that was not supplied (either through the command
|
|
198
216
|
line or through a configuration file), it will prompt for a value.
|
|
199
217
|
|
|
200
|
-

|
|
201
219
|
|
|
202
220
|
You can enable or disable interactive mode by setting the environment
|
|
203
221
|
variable `KOJO_INTERACTIVE` to `yes` or `no`.
|
data/lib/kojo/commands/config.rb
CHANGED
data/lib/kojo/commands/dir.rb
CHANGED
data/lib/kojo/commands/file.rb
CHANGED
data/lib/kojo/config.rb
CHANGED
|
@@ -32,7 +32,7 @@ module Kojo
|
|
|
32
32
|
def read_file(file)
|
|
33
33
|
raise Kojo::NotFoundError, "File not found: #{file}" unless File.exist? file
|
|
34
34
|
|
|
35
|
-
config = YAML.
|
|
35
|
+
config = YAML.properly_load_file file
|
|
36
36
|
content = File.read(file)[/^---\s*$\n(.*)/m, 1]
|
|
37
37
|
|
|
38
38
|
[config, content]
|
data/lib/kojo/version.rb
CHANGED
data/lib/kojo.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: kojo
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Danny Ben Shitrit
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2022-02-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: mister_bin
|
|
@@ -103,6 +103,7 @@ files:
|
|
|
103
103
|
- lib/kojo/config.rb
|
|
104
104
|
- lib/kojo/exceptions.rb
|
|
105
105
|
- lib/kojo/extensions/file.rb
|
|
106
|
+
- lib/kojo/extensions/yaml.rb
|
|
106
107
|
- lib/kojo/form.rb
|
|
107
108
|
- lib/kojo/front_matter_template.rb
|
|
108
109
|
- lib/kojo/refinements/array.rb
|
|
@@ -122,14 +123,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
122
123
|
requirements:
|
|
123
124
|
- - ">="
|
|
124
125
|
- !ruby/object:Gem::Version
|
|
125
|
-
version: 2.
|
|
126
|
+
version: 2.6.0
|
|
126
127
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
128
|
requirements:
|
|
128
129
|
- - ">="
|
|
129
130
|
- !ruby/object:Gem::Version
|
|
130
131
|
version: '0'
|
|
131
132
|
requirements: []
|
|
132
|
-
rubygems_version: 3.
|
|
133
|
+
rubygems_version: 3.2.15
|
|
133
134
|
signing_key:
|
|
134
135
|
specification_version: 4
|
|
135
136
|
summary: Configuration Ninja
|