kojo 0.1.2 → 0.1.3
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/bin/kojo-config.rb +13 -5
- data/bin/kojo-dir.rb +10 -1
- data/bin/kojo-file.rb +9 -1
- data/lib/kojo/generator.rb +4 -3
- data/lib/kojo/version.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: 61ba22b7003667b908b01d8a1c6c4b3996ba18653d9424574700a7c75086cf1e
|
4
|
+
data.tar.gz: 1a5da4957a819a19e0fc31bd6229e3aaf4aae72e45ed807da9424c3ee03a52de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f2496aee4ebee3a2b2d9acb89361f8646abe2b84173f4b24d7938ac4270b653e49424fdc26fa4102b0f6e625087a1c57a4d00767f6a27c38a6c0138fb025966
|
7
|
+
data.tar.gz: 5bbaf81bb30c7794b00cc630025d9af12e280b4e440b4389eff4284071ccd79a70cb338ddc3df82f361b785fec2ceb527788db8f86a8a1be0491a83fde6382ca
|
data/bin/kojo-config.rb
CHANGED
@@ -3,28 +3,36 @@ require 'fileutils'
|
|
3
3
|
|
4
4
|
help "Generate based on instructions from a config file"
|
5
5
|
|
6
|
-
usage "kojo config CONFIG [--save DIR] [ARGS...]"
|
6
|
+
usage "kojo config CONFIG [--save DIR --args FILE] [ARGS...]"
|
7
7
|
usage "kojo config (-h|--help)"
|
8
8
|
|
9
9
|
option "-s --save DIR", "Save output to directory instead of printing"
|
10
|
+
option "-a --args FILE", "Load arguments from YAML file"
|
10
11
|
|
11
12
|
param "ARGS", "Optional key=value pairs"
|
12
13
|
|
13
14
|
example "kojo config config.yml"
|
14
15
|
example "kojo config config.yml --save output"
|
15
16
|
example "kojo config config.yml -s output scale=3"
|
17
|
+
example "kojo config config.yml -s output --args args.yml"
|
16
18
|
|
17
19
|
action do |args|
|
18
20
|
gen = Kojo::Generator.new args['CONFIG']
|
19
21
|
outdir = args['--save']
|
20
|
-
|
21
|
-
|
22
|
-
|
22
|
+
opts = args['ARGS'].args_to_hash
|
23
|
+
argfile = args['--args']
|
24
|
+
|
25
|
+
if argfile
|
26
|
+
fileopts = YAML.load_file(argfile).symbolize_keys
|
27
|
+
opts = fileopts.merge opts
|
23
28
|
end
|
24
29
|
|
25
|
-
gen.generate do |file, output|
|
30
|
+
gen.generate opts do |file, output|
|
26
31
|
path = "#{outdir}/#{file}"
|
27
32
|
if outdir
|
33
|
+
dir = File.dirname path
|
34
|
+
FileUtils.mkdir_p dir unless Dir.exist? dir
|
35
|
+
|
28
36
|
File.write path, output
|
29
37
|
say "Saved #{path}"
|
30
38
|
else
|
data/bin/kojo-dir.rb
CHANGED
@@ -2,27 +2,36 @@ require 'kojo'
|
|
2
2
|
|
3
3
|
help "Compile a folder of templates to a similar output folder"
|
4
4
|
|
5
|
-
usage "kojo dir INDIR [--save DIR --import DIR] [ARGS...]"
|
5
|
+
usage "kojo dir INDIR [--save DIR --import DIR --args FILE] [ARGS...]"
|
6
6
|
usage "kojo dir (-h|--help)"
|
7
7
|
|
8
8
|
option "-s --save DIR", "Save output to directory instead of printing"
|
9
9
|
option "-i --import DIR", "Specify base directory for @import directives"
|
10
|
+
option "-a --args FILE", "Load arguments from YAML file"
|
10
11
|
|
11
12
|
param "ARGS", "Optional key=value pairs"
|
12
13
|
|
13
14
|
example "kojo dir indir"
|
14
15
|
example "kojo dir in --save out env=production"
|
15
16
|
example "kojo dir in --save out --import snippets env=production"
|
17
|
+
example "kojo dir in -s out -i snippets -a args.yml"
|
16
18
|
|
17
19
|
action do |args|
|
18
20
|
opts = args['ARGS'].args_to_hash
|
19
21
|
indir = args['INDIR']
|
20
22
|
outdir = args['--save']
|
21
23
|
import_base = args['--import']
|
24
|
+
argfile = args['--args']
|
25
|
+
|
26
|
+
if argfile
|
27
|
+
fileopts = YAML.load_file(argfile).symbolize_keys
|
28
|
+
opts = fileopts.merge opts
|
29
|
+
end
|
22
30
|
|
23
31
|
files = Dir["#{indir}/**/*"].reject { |file| File.directory? file }
|
24
32
|
|
25
33
|
files.each do |file|
|
34
|
+
|
26
35
|
template = Kojo::Template.new(file, opts)
|
27
36
|
template.import_base = import_base if import_base
|
28
37
|
output = template.render
|
data/bin/kojo-file.rb
CHANGED
@@ -2,21 +2,29 @@ require 'kojo'
|
|
2
2
|
|
3
3
|
help "Compile a file from a template"
|
4
4
|
|
5
|
-
usage "kojo file INFILE [--save FILE] [ARGS...]"
|
5
|
+
usage "kojo file INFILE [--save FILE --args FILE] [ARGS...]"
|
6
6
|
usage "kojo file (-h|--help)"
|
7
7
|
|
8
8
|
option "-s --save FILE", "Save to file instead of printing"
|
9
|
+
option "-a --args FILE", "Load arguments from YAML file"
|
9
10
|
|
10
11
|
param "ARGS", "Optional key=value pairs"
|
11
12
|
|
12
13
|
example "kojo file main.yml"
|
13
14
|
example "kojo file main.yml --save out.yml"
|
14
15
|
example "kojo file main.yml -s out.yml app=lause"
|
16
|
+
example "kojo file main.yml -s out.yml --args args.yml"
|
15
17
|
|
16
18
|
action do |args|
|
17
19
|
opts = args['ARGS'].args_to_hash
|
18
20
|
outfile = args['--save']
|
19
21
|
infile = args['INFILE']
|
22
|
+
argfile = args['--args']
|
23
|
+
|
24
|
+
if argfile
|
25
|
+
fileopts = YAML.load_file(argfile).symbolize_keys
|
26
|
+
opts = fileopts.merge opts
|
27
|
+
end
|
20
28
|
|
21
29
|
output = Kojo::Template.new(infile, opts).render
|
22
30
|
|
data/lib/kojo/generator.rb
CHANGED
@@ -12,8 +12,9 @@ module Kojo
|
|
12
12
|
base_dir = File.dirname config_file
|
13
13
|
infile = "#{base_dir}/#{config['input']}"
|
14
14
|
|
15
|
-
config['output'].each do |outfile,
|
16
|
-
|
15
|
+
config['output'].each do |outfile, config_opts|
|
16
|
+
local_opts = opts.merge config_opts.symbolize_keys
|
17
|
+
output = render infile, local_opts
|
17
18
|
yield outfile, output
|
18
19
|
end
|
19
20
|
end
|
@@ -25,7 +26,7 @@ module Kojo
|
|
25
26
|
end
|
26
27
|
|
27
28
|
def render(infile, opts={})
|
28
|
-
Template.new(infile, opts).render
|
29
|
+
Template.new(infile, opts).render
|
29
30
|
end
|
30
31
|
end
|
31
32
|
|
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.1.
|
4
|
+
version: 0.1.3
|
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: 2018-08-
|
11
|
+
date: 2018-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mister_bin
|