kojo 0.3.3 → 0.3.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +48 -37
- data/lib/kojo.rb +4 -0
- data/lib/kojo/cli.rb +2 -0
- data/lib/kojo/collection.rb +9 -3
- data/lib/kojo/commands/command_base.rb +2 -3
- data/lib/kojo/commands/config.rb +1 -9
- data/lib/kojo/commands/dir.rb +1 -1
- data/lib/kojo/commands/file.rb +2 -3
- data/lib/kojo/commands/form.rb +35 -0
- data/lib/kojo/commands/single.rb +1 -1
- data/lib/kojo/commands/to_json.rb +67 -0
- data/lib/kojo/config.rb +1 -3
- data/lib/kojo/extensions/file.rb +2 -0
- data/lib/kojo/form.rb +60 -0
- data/lib/kojo/front_matter_template.rb +2 -4
- data/lib/kojo/refinements/array.rb +1 -1
- data/lib/kojo/refinements/string.rb +0 -1
- data/lib/kojo/template.rb +1 -1
- data/lib/kojo/version.rb +1 -1
- metadata +34 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31deffc66dbb1ff100bb90f669f8d2995f8eeac92c78919434caffbb9ecfee69
|
4
|
+
data.tar.gz: 6c4b75d7e13b627520d403d8885333a9c30b06cd40c56889e2cd4823ac125b12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6731a253afc7c3ccdb8f718e4a78d70d6bfcea9079c269f0b9ca1d8da3596abcbfd5b895fa2e32bbc2b14629c4b5a022cd7996fb3428a6260cb5b5b64b97aa8
|
7
|
+
data.tar.gz: 0c285f0dcaeff09fb183fe2f02e8f25a9905b4431bca7908dfc0824bfd5caba74d215476e661b519733c790b2b79ea599c9d325f03bdab7c847f98761c815ffc
|
data/README.md
CHANGED
@@ -2,24 +2,22 @@
|
|
2
2
|
|
3
3
|
![kojo](images/kojo.png)
|
4
4
|
|
5
|
-
Kojo Configuration Ninja
|
6
|
-
==================================================
|
5
|
+
# Kojo Configuration Ninja
|
7
6
|
|
8
7
|
[![Gem Version](https://badge.fury.io/rb/kojo.svg)](https://badge.fury.io/rb/kojo)
|
9
|
-
[![Build Status](https://
|
8
|
+
[![Build Status](https://github.com/DannyBen/kojo/workflows/Test/badge.svg)](https://github.com/DannyBen/kojo/actions?query=workflow%3ATest)
|
10
9
|
[![Maintainability](https://api.codeclimate.com/v1/badges/f24566ad04b5054a2251/maintainability)](https://codeclimate.com/github/DannyBen/kojo/maintainability)
|
11
10
|
|
12
11
|
|
13
12
|
Kojo helps you generate configuration files from templates, using variables
|
14
|
-
and definition files.
|
15
|
-
|
13
|
+
and definition files. It is a command line utility, and works on any text file
|
14
|
+
format.
|
16
15
|
|
17
16
|
</div>
|
18
17
|
|
19
18
|
---
|
20
19
|
|
21
|
-
Table of Contents
|
22
|
-
--------------------------------------------------
|
20
|
+
## Table of Contents
|
23
21
|
|
24
22
|
- [Installation](#installation)
|
25
23
|
- [Usage](#usage)
|
@@ -28,28 +26,32 @@ Table of Contents
|
|
28
26
|
- [Transform an Entire Folder](#transform-an-entire-folder)
|
29
27
|
- [Transform One to Many using Config](#transform-one-to-many-using-config)
|
30
28
|
- [Transform One to Many using Front Matter](#transform-one-to-many-using-front-matter)
|
29
|
+
- [Interactive Form Templates](#interactive-form-templates)
|
31
30
|
- [Conditions and Loops with ERB](#conditions-and-loops-with-erb)
|
32
|
-
- [Interactive
|
31
|
+
- [Interactive Fallback](#interactive-fallback)
|
33
32
|
- [Using from Ruby Code](#using-from-ruby-code)
|
34
33
|
- [Contributing / Support](#contributing--support)
|
35
34
|
|
36
35
|
---
|
37
36
|
|
38
|
-
Installation
|
39
|
-
--------------------------------------------------
|
37
|
+
## Installation
|
40
38
|
|
41
|
-
|
39
|
+
```shell
|
40
|
+
$ gem install kojo
|
41
|
+
```
|
42
42
|
|
43
|
+
Or with Docker:
|
43
44
|
|
45
|
+
```shell
|
46
|
+
$ alias kojo='docker run --rm -it -v "$PWD:/app" dannyben/kojo'
|
47
|
+
```
|
44
48
|
|
45
|
-
Usage
|
46
|
-
--------------------------------------------------
|
49
|
+
## Usage
|
47
50
|
|
48
51
|
If you prefer to learn by example, see the [examples](examples#examples) folder for
|
49
52
|
several use cases. Each example subfolder contains the command to run, the
|
50
53
|
relevant files, and the expected output.
|
51
54
|
|
52
|
-
|
53
55
|
### Variables
|
54
56
|
|
55
57
|
![kojo](images/features-vars.svg)
|
@@ -63,8 +65,6 @@ Include variables in your configuration templates by using this syntax:
|
|
63
65
|
- Variables from the top level will be forwarded downstream, and aggregated
|
64
66
|
with any additional variables that are defined in subsequent `@imports`.
|
65
67
|
|
66
|
-
|
67
|
-
|
68
68
|
### Import
|
69
69
|
|
70
70
|
![kojo](images/features-import.svg)
|
@@ -86,8 +86,6 @@ resulting configuration file.
|
|
86
86
|
|
87
87
|
The space after `filename` is optional.
|
88
88
|
|
89
|
-
|
90
|
-
|
91
89
|
### Transform an Entire Folder
|
92
90
|
|
93
91
|
![kojo](images/features-dir.svg)
|
@@ -97,8 +95,6 @@ output folder, with all the variables and `@imports` evaluated.
|
|
97
95
|
|
98
96
|
You may use `%{variables}` in filenames.
|
99
97
|
|
100
|
-
|
101
|
-
|
102
98
|
### Transform One to Many using Config
|
103
99
|
|
104
100
|
![kojo](images/features-config.svg)
|
@@ -169,6 +165,20 @@ Your template that uses %{arg} goes here
|
|
169
165
|
Additional arguments provided to the command line, will also be transferred
|
170
166
|
to the template.
|
171
167
|
|
168
|
+
### Interactive Form Templates
|
169
|
+
|
170
|
+
![kojo](images/features-form.svg)
|
171
|
+
|
172
|
+
Using the `kojo form` command lets you define an ERB or [ERBX][erbx] template, and include interactive prompts to enter the input.
|
173
|
+
|
174
|
+
1. Use either ERB tags (`<%= %>`, `<%- -%>`) or ERBX tags (`{{ }}`, `(( ))`).
|
175
|
+
2. Use the built in `prompt` object, which is a [TTY::Prompt](tty-prompt) instance, to prompt for input when running the command (for example: `{{ prompt.ask? "Your Name?" }}`)
|
176
|
+
3. Any unidentified ruby command will be forwarded to the `prompt` object, so `prompt.ask` is the same as just using `ask`.
|
177
|
+
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
|
+
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
|
+
|
180
|
+
![kojo](images/features-form-inline.svg)
|
181
|
+
|
172
182
|
### Conditions and Loops with ERB
|
173
183
|
|
174
184
|
![kojo](images/features-erb.svg)
|
@@ -182,10 +192,7 @@ Use this syntax for ruby code:
|
|
182
192
|
<%- ruby code here -%> # for code that should not be printed
|
183
193
|
<%= ruby code here -%> # for code that should be printed
|
184
194
|
```
|
185
|
-
|
186
|
-
|
187
|
-
Interactive Mode
|
188
|
-
--------------------------------------------------
|
195
|
+
## Interactive Fallback
|
189
196
|
|
190
197
|
When Kojo encounters a variable that was not supplied (either through the command
|
191
198
|
line or through a configuration file), it will prompt for a value.
|
@@ -201,21 +208,20 @@ running from within Ruby code.
|
|
201
208
|
When running from within Ruby code, you can also use `Kojo.interactive = true`
|
202
209
|
and `Kojo.interactive?` to get the current state.
|
203
210
|
|
204
|
-
|
205
|
-
Using from Ruby Code
|
206
|
-
--------------------------------------------------
|
211
|
+
## Using from Ruby Code
|
207
212
|
|
208
213
|
Although Kojo was primarily designed as a command line utility, you can also
|
209
214
|
use it as a library from your Ruby code.
|
210
215
|
|
211
216
|
These are the primary classes:
|
212
217
|
|
213
|
-
| Class | Description | CLI equivalent
|
214
|
-
|
215
|
-
| `Kojo::Template` | generate from a single template | `kojo file`
|
216
|
-
| `Kojo::FrontMatterTemplate` | generate from a template with a front matter | `kojo single`
|
217
|
-
| `Kojo::Config` | generate from a config file | `kojo config`
|
218
|
-
| `Kojo::Collection` | generate from a directory | `kojo dir`
|
218
|
+
| Class | Description | CLI equivalent |
|
219
|
+
| --------------------------- | -------------------------------------------- | -------------- |
|
220
|
+
| `Kojo::Template` | generate from a single template | `kojo file` |
|
221
|
+
| `Kojo::FrontMatterTemplate` | generate from a template with a front matter | `kojo single` |
|
222
|
+
| `Kojo::Config` | generate from a config file | `kojo config` |
|
223
|
+
| `Kojo::Collection` | generate from a directory | `kojo dir` |
|
224
|
+
| `Kojo::Form` | generate interactively | `kojo form` |
|
219
225
|
|
220
226
|
### Examples
|
221
227
|
|
@@ -246,9 +252,13 @@ end
|
|
246
252
|
template = Kojo::FrontMatterTemplate.new 'examples/single/Dockerfile'
|
247
253
|
params = { version: '0.1.1' }
|
248
254
|
|
249
|
-
|
255
|
+
template.render params do |path, content|
|
250
256
|
# code to handle results here
|
251
257
|
end
|
258
|
+
|
259
|
+
# Form
|
260
|
+
template = Kojo::Form.new 'examples/form/movie.md'
|
261
|
+
puts template.render
|
252
262
|
```
|
253
263
|
|
254
264
|
In addition, Kojo extends Ruby's `File` class with the `File.deep_write`
|
@@ -265,12 +275,13 @@ config.generate do |path, content|
|
|
265
275
|
end
|
266
276
|
```
|
267
277
|
|
268
|
-
Contributing / Support
|
269
|
-
--------------------------------------------------
|
278
|
+
## Contributing / Support
|
270
279
|
|
271
280
|
If you experience any issue, have a question or a suggestion, or if you wish
|
272
281
|
to contribute, feel free to [open an issue][issues].
|
273
282
|
|
274
283
|
---
|
275
284
|
|
276
|
-
[issues]: https://github.com/DannyBen/kojo/issues
|
285
|
+
[issues]: https://github.com/DannyBen/kojo/issues
|
286
|
+
[erbx]: https://github.com/DannyBen/erbx
|
287
|
+
[tty-prompt]: https://github.com/piotrmurach/tty-prompt#contents
|
data/lib/kojo.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
require 'requires'
|
2
2
|
require 'byebug' if ENV['BYEBUG']
|
3
3
|
|
4
|
+
require 'yaml'
|
5
|
+
require 'json'
|
6
|
+
|
4
7
|
requires 'kojo/refinements'
|
5
8
|
requires 'kojo/extensions'
|
6
9
|
|
@@ -9,6 +12,7 @@ require 'kojo/template'
|
|
9
12
|
require 'kojo/collection'
|
10
13
|
require 'kojo/config'
|
11
14
|
require 'kojo/front_matter_template'
|
15
|
+
require 'kojo/form'
|
12
16
|
|
13
17
|
module Kojo
|
14
18
|
class << self
|
data/lib/kojo/cli.rb
CHANGED
@@ -15,6 +15,8 @@ module Kojo
|
|
15
15
|
runner.route 'dir', to: Kojo::Commands::DirCmd
|
16
16
|
runner.route 'config', to: Kojo::Commands::ConfigCmd
|
17
17
|
runner.route 'single', to: Kojo::Commands::SingleCmd
|
18
|
+
runner.route 'form', to: Kojo::Commands::FormCmd
|
19
|
+
runner.route 'tojson', to: Kojo::Commands::ToJsonCmd
|
18
20
|
|
19
21
|
runner
|
20
22
|
end
|
data/lib/kojo/collection.rb
CHANGED
@@ -12,15 +12,19 @@ module Kojo
|
|
12
12
|
@import_base = dir
|
13
13
|
end
|
14
14
|
|
15
|
-
def render(args={}, &block)
|
15
|
+
def render(args = {}, &block)
|
16
16
|
files.each do |file|
|
17
17
|
handle file, args, &block
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
+
def size
|
22
|
+
files.size
|
23
|
+
end
|
24
|
+
|
21
25
|
private
|
22
26
|
|
23
|
-
def handle(file, args={})
|
27
|
+
def handle(file, args = {})
|
24
28
|
template = Template.new file
|
25
29
|
template.import_base = import_base
|
26
30
|
|
@@ -34,7 +38,9 @@ module Kojo
|
|
34
38
|
raise Kojo::NotFoundError, "Directory not found: #{dir}" unless Dir.exist? dir
|
35
39
|
raise Kojo::NotFoundError, "Directory is empty: #{dir}" if Dir.empty? dir
|
36
40
|
|
37
|
-
@files = Dir
|
41
|
+
@files = Dir.glob("#{dir}/**/*", File::FNM_DOTMATCH)
|
42
|
+
.reject { |f| File.directory? f }
|
43
|
+
.sort
|
38
44
|
end
|
39
45
|
end
|
40
46
|
end
|
@@ -4,9 +4,8 @@ module Kojo
|
|
4
4
|
module Commands
|
5
5
|
class CommandBase < MisterBin::Command
|
6
6
|
def save(file, output)
|
7
|
-
|
8
|
-
|
9
|
-
say "Saved #{outpath}"
|
7
|
+
File.deep_write file, output
|
8
|
+
say "Saved #{file}"
|
10
9
|
end
|
11
10
|
end
|
12
11
|
end
|
data/lib/kojo/commands/config.rb
CHANGED
@@ -3,7 +3,7 @@ require 'mister_bin'
|
|
3
3
|
|
4
4
|
module Kojo::Commands
|
5
5
|
# Handle calls to the +kojo config+ command
|
6
|
-
class ConfigCmd <
|
6
|
+
class ConfigCmd < CommandBase
|
7
7
|
using Kojo::Refinements
|
8
8
|
|
9
9
|
attr_reader :gen, :outdir, :opts, :import_base, :config_file
|
@@ -59,13 +59,5 @@ module Kojo::Commands
|
|
59
59
|
say output
|
60
60
|
end
|
61
61
|
end
|
62
|
-
|
63
|
-
def save(path, output)
|
64
|
-
dir = File.dirname path
|
65
|
-
FileUtils.mkdir_p dir unless Dir.exist? dir
|
66
|
-
File.write path, output
|
67
|
-
say "Saved #{path}"
|
68
|
-
end
|
69
|
-
|
70
62
|
end
|
71
63
|
end
|
data/lib/kojo/commands/dir.rb
CHANGED
data/lib/kojo/commands/file.rb
CHANGED
@@ -3,7 +3,7 @@ require 'mister_bin'
|
|
3
3
|
module Kojo
|
4
4
|
module Commands
|
5
5
|
# Handle calls to the +kojo file+ command
|
6
|
-
class FileCmd <
|
6
|
+
class FileCmd < CommandBase
|
7
7
|
using Kojo::Refinements
|
8
8
|
|
9
9
|
attr_reader :opts, :outfile, :infile, :import_base
|
@@ -48,8 +48,7 @@ module Kojo
|
|
48
48
|
output = template.render(opts)
|
49
49
|
|
50
50
|
if outfile
|
51
|
-
|
52
|
-
say "Saved #{outfile}"
|
51
|
+
save outfile, output
|
53
52
|
else
|
54
53
|
puts output
|
55
54
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'mister_bin'
|
2
|
+
|
3
|
+
module Kojo
|
4
|
+
module Commands
|
5
|
+
# Handle calls to the +kojo form+ command
|
6
|
+
class FormCmd < CommandBase
|
7
|
+
attr_reader :infile, :outdir
|
8
|
+
|
9
|
+
help "Fill a template form interactively"
|
10
|
+
|
11
|
+
usage "kojo form INFILE [--save FILE]"
|
12
|
+
usage "kojo form (-h|--help)"
|
13
|
+
|
14
|
+
option "-s --save FILE", "Save to file instead of printing"
|
15
|
+
|
16
|
+
param "INFILE", "ERBX template to transform"
|
17
|
+
|
18
|
+
example "kojo form report.md"
|
19
|
+
example "kojo form report.md --save output.md"
|
20
|
+
|
21
|
+
def run
|
22
|
+
infile = args['INFILE']
|
23
|
+
outfile = args['--save']
|
24
|
+
template = Kojo::Form.new infile
|
25
|
+
|
26
|
+
if outfile
|
27
|
+
save outfile, template.render
|
28
|
+
else
|
29
|
+
puts template.render
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/kojo/commands/single.rb
CHANGED
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'mister_bin'
|
2
|
+
|
3
|
+
module Kojo
|
4
|
+
module Commands
|
5
|
+
# Handle calls to the +kojo dir+ command
|
6
|
+
class ToJsonCmd < CommandBase
|
7
|
+
using Kojo::Refinements
|
8
|
+
|
9
|
+
attr_reader :input, :save_files, :replace_files
|
10
|
+
|
11
|
+
help "Convert one or more YAML files to JSON"
|
12
|
+
|
13
|
+
usage "kojo tojson INPUT... [(--save | --replace)]"
|
14
|
+
usage "kojo tojson (-h|--help)"
|
15
|
+
|
16
|
+
option "-s --save", "Save each input file in the same directory"
|
17
|
+
option "-r --replace", "Save each input file in the same directory and delete the input file"
|
18
|
+
|
19
|
+
param "INPUT", "Path to a YAML file or multiple files using a glob pattern"
|
20
|
+
|
21
|
+
example "kojo tojson myfile.yaml"
|
22
|
+
example "kojo tojson myfile.yaml --save"
|
23
|
+
example "kojo tojson indir/*.yaml"
|
24
|
+
example "kojo tojson indir/*.yaml --replace"
|
25
|
+
example "kojo tojson indir/**/*.yml"
|
26
|
+
|
27
|
+
def run
|
28
|
+
@input = get_input_files
|
29
|
+
@save_files = args['--save'] || args['--replace']
|
30
|
+
@replace_files = args['--replace']
|
31
|
+
|
32
|
+
save_files ? write : show
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def tojson(path)
|
38
|
+
JSON.pretty_generate YAML.load_file(path)
|
39
|
+
end
|
40
|
+
|
41
|
+
# Glob patterns are usually handled by the shell, but in case
|
42
|
+
# we still have '*' in our string (for example, if it was sent
|
43
|
+
# quoted), we will do the globbing ourselves
|
44
|
+
def get_input_files
|
45
|
+
args['INPUT'].map do |path|
|
46
|
+
path.include?('*') ? Dir[path].sort : path
|
47
|
+
end.flatten
|
48
|
+
end
|
49
|
+
|
50
|
+
def show
|
51
|
+
input.each do |infile|
|
52
|
+
outfile = infile.gsub(/\.ya?ml/, '.json')
|
53
|
+
say "\n!txtgrn!# #{outfile}"
|
54
|
+
say tojson(infile)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def write
|
59
|
+
input.each do |infile|
|
60
|
+
outfile = infile.gsub(/\.ya?ml/, '.json')
|
61
|
+
save outfile, tojson(infile)
|
62
|
+
File.delete infile if replace_files
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
data/lib/kojo/config.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'yaml'
|
2
|
-
|
3
1
|
module Kojo
|
4
2
|
# The Config class handles multiple template generation from a
|
5
3
|
# definitions YAML file.
|
@@ -14,7 +12,7 @@ module Kojo
|
|
14
12
|
@import_base = nil
|
15
13
|
end
|
16
14
|
|
17
|
-
def generate(opts={}, &block)
|
15
|
+
def generate(opts = {}, &block)
|
18
16
|
if directory_mode?
|
19
17
|
generate_from_dir opts, &block
|
20
18
|
else
|
data/lib/kojo/extensions/file.rb
CHANGED
data/lib/kojo/form.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'erbx'
|
2
|
+
require 'tty-prompt'
|
3
|
+
|
4
|
+
module Kojo
|
5
|
+
# The Form class handles interactive ERBX templates
|
6
|
+
class Form
|
7
|
+
attr_reader :file
|
8
|
+
|
9
|
+
def initialize(file)
|
10
|
+
@file = file
|
11
|
+
end
|
12
|
+
|
13
|
+
def content
|
14
|
+
@content ||= content!
|
15
|
+
end
|
16
|
+
|
17
|
+
def content!
|
18
|
+
content = File.read file
|
19
|
+
ruby_code = File.exist?("#{file}.rb") ? File.read("#{file}.rb") : nil
|
20
|
+
content = "<%-\n#{ruby_code}\n-%>\n#{content}" if ruby_code
|
21
|
+
content
|
22
|
+
end
|
23
|
+
|
24
|
+
def render
|
25
|
+
ERBX.new(content).result(binding)
|
26
|
+
rescue TTY::Reader::InputInterrupt
|
27
|
+
# :nocov:
|
28
|
+
raise Kojo::Interrupt
|
29
|
+
# :nocov:
|
30
|
+
end
|
31
|
+
|
32
|
+
def prompt
|
33
|
+
@prompt ||= TTY::Prompt.new
|
34
|
+
end
|
35
|
+
|
36
|
+
def method_missing(method_name, *args, **kargs, &block)
|
37
|
+
if respond_to? method_name
|
38
|
+
prompt.send method_name, *args, **kargs, &block
|
39
|
+
else
|
40
|
+
super
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def respond_to?(method_name, include_private = false)
|
45
|
+
prompt.respond_to?(method_name) || super
|
46
|
+
end
|
47
|
+
|
48
|
+
# Below are TTY::Prompt functions that are not captured by the
|
49
|
+
# `mthod_missing`, so we specify them explicitly
|
50
|
+
|
51
|
+
def select(*args, &block)
|
52
|
+
prompt.select *args, &block
|
53
|
+
end
|
54
|
+
|
55
|
+
def warn(*args, &block)
|
56
|
+
prompt.warn *args, &block
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'yaml'
|
2
|
-
|
3
1
|
module Kojo
|
4
2
|
# The FrontMatterTemplate class handles a single template file, that
|
5
3
|
# contains a YAML front matter.
|
@@ -12,7 +10,7 @@ module Kojo
|
|
12
10
|
@file = file
|
13
11
|
end
|
14
12
|
|
15
|
-
def render(additional_args=nil)
|
13
|
+
def render(additional_args = nil)
|
16
14
|
additional_args ||= {}
|
17
15
|
config, @template = read_file file
|
18
16
|
|
@@ -24,7 +22,7 @@ module Kojo
|
|
24
22
|
|
25
23
|
private
|
26
24
|
|
27
|
-
def handle(args={})
|
25
|
+
def handle(args = {})
|
28
26
|
content = template
|
29
27
|
content = content.eval_erb args, file
|
30
28
|
content = content.eval_vars args, file
|
data/lib/kojo/template.rb
CHANGED
data/lib/kojo/version.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.8
|
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: 2020-
|
11
|
+
date: 2020-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mister_bin
|
@@ -52,6 +52,34 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0.5'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: tty-prompt
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.21'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.21'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: erbx
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.1.1
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.1.1
|
55
83
|
description: Generate configuration files from templates, using variables and definition
|
56
84
|
files.
|
57
85
|
email: db@dannyben.com
|
@@ -69,10 +97,13 @@ files:
|
|
69
97
|
- lib/kojo/commands/config.rb
|
70
98
|
- lib/kojo/commands/dir.rb
|
71
99
|
- lib/kojo/commands/file.rb
|
100
|
+
- lib/kojo/commands/form.rb
|
72
101
|
- lib/kojo/commands/single.rb
|
102
|
+
- lib/kojo/commands/to_json.rb
|
73
103
|
- lib/kojo/config.rb
|
74
104
|
- lib/kojo/exceptions.rb
|
75
105
|
- lib/kojo/extensions/file.rb
|
106
|
+
- lib/kojo/form.rb
|
76
107
|
- lib/kojo/front_matter_template.rb
|
77
108
|
- lib/kojo/refinements/array.rb
|
78
109
|
- lib/kojo/refinements/hash.rb
|
@@ -98,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
129
|
- !ruby/object:Gem::Version
|
99
130
|
version: '0'
|
100
131
|
requirements: []
|
101
|
-
rubygems_version: 3.
|
132
|
+
rubygems_version: 3.1.4
|
102
133
|
signing_key:
|
103
134
|
specification_version: 4
|
104
135
|
summary: Configuration Ninja
|