kojo 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7bfe6b265587d1655d021af564aefee81cb53ef83d91f8fa00a4118bf7a0923f
4
- data.tar.gz: fb6fefecfb5b4f39b249c7e0402b571814ad7c6a326951b700cdc9f3a95eedbe
3
+ metadata.gz: cf86e9c731c19158840673852b2edb3fdb047ff1e80170ba8f33685c40e677c1
4
+ data.tar.gz: 38d5f668d58d4681e635cfb73944f4a5927a9865a9e72f1040cfa968f119186c
5
5
  SHA512:
6
- metadata.gz: ddf2dd1579527285d918ac439bfac43470b9c764decb6310e2a596fc4e0caf738570fd0ff04bab06cb0a4b6ac5940514ebb7f701bc4b3dac344aebd1d6047774
7
- data.tar.gz: bc80e7fc451a1e214530bcae3aa89052e70cb9f8ab20b686c57e18679c95487e6bfc58a840fbbb0b87b22e991d7b4a596d9a333dc455c828a81ce307b60e0954
6
+ metadata.gz: d9abd6c45fc2cf8a92659db86914ed4baa0e4754d117ae348444b5dcceed7301f7e3f822d3fcf7ad0602be4bdcaa29d8c58e19aff5071c3321c849e1a4e937df
7
+ data.tar.gz: 4358ffb8cde4c83ec10aa73e2f5bae4c34b369200cfeb1abe837249528a7cfcc16d5ed2c80967232795a38c14dc49a95a9f96ee9bfa0f6c70c199c4d225fcb4d
data/README.md CHANGED
@@ -50,13 +50,12 @@ relevant files, and the expected output.
50
50
 
51
51
  ![kojo](images/features-vars.svg)
52
52
 
53
- Include variables in your configuration templates using this syntax:
54
-
55
- ```ruby
56
- %{varname}
57
- ```
53
+ Include variables in your configuration templates by using this syntax:
54
+ `%{varname}`
58
55
 
59
56
  - Variables can be provided through the command line, or when using `@import`.
57
+ - When one or more variables are not provided, you will be prompted to provide
58
+ a value.
60
59
  - Variables from the top level will be forwarded downstream, and aggregated
61
60
  with any additional variables that are defined in subsequent `@imports`.
62
61
 
@@ -92,6 +91,8 @@ The space after `filename` is optional.
92
91
  Process a folder containing templates and `@imports`, and generate a mirror
93
92
  output folder, with all the variables and `@imports` evaluated.
94
93
 
94
+ You may use `%{variables}` in filenames.
95
+
95
96
 
96
97
 
97
98
  ### One to Many Generation
@@ -22,7 +22,7 @@ module Kojo
22
22
  template = Template.new file
23
23
  template.import_base = import_base
24
24
 
25
- path = file.sub(/#{dir}\//, '') % args
25
+ path = file.sub(/#{dir}\//, '').resolve args
26
26
 
27
27
  yield path, template.render(args)
28
28
  end
@@ -15,4 +15,18 @@ class String
15
15
 
16
16
  end
17
17
  end
18
+
19
+ def resolve(vars)
20
+ self % vars
21
+
22
+ rescue KeyError => e
23
+ print "> #{e.key}: "
24
+ response = $stdin.gets
25
+
26
+ raise Kojo::TemplateError, e.message unless response
27
+
28
+ vars[e.key] = response.chomp
29
+ retry
30
+ end
31
+
18
32
  end
data/lib/kojo/template.rb CHANGED
@@ -38,8 +38,8 @@ module Kojo
38
38
  end
39
39
 
40
40
  def eval_vars(content)
41
- content % args
42
- rescue ArgumentError, KeyError => e
41
+ content.resolve args
42
+ rescue ArgumentError => e
43
43
  raise Kojo::TemplateError, "#{e.message}\nin: #{file}"
44
44
  end
45
45
 
data/lib/kojo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kojo
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
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.2.3
4
+ version: 0.2.4
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-09-12 00:00:00.000000000 Z
11
+ date: 2018-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mister_bin