ytools 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- 0.2.2
1
+ 0.2.3
@@ -23,9 +23,8 @@ module YTools
23
23
  protected
24
24
  def tail(command)
25
25
  command.alter do
26
- string :literal, "Evaluate a literal string in addition to any file paths."
27
26
  boolean :strict, "Checks to make sure all of the YAML files exist before proceeding."
28
- boolean :examples, "Show some examples on how to use the path syntax." do
27
+ boolean_ :examples, "Show some examples on how to use the path syntax." do
29
28
  validate do |show, options|
30
29
  if show
31
30
  YTools::Utils.print_example(File.join(File.dirname(__FILE__), command.name.to_s.gsub(/^y/, '')))
@@ -33,6 +33,8 @@ module YTools::Path
33
33
  end
34
34
  end
35
35
  end
36
+
37
+ string :literal, "Evaluate a literal string in addition to any file paths."
36
38
  end
37
39
  end
38
40
  end # CLI
@@ -14,12 +14,20 @@ module YTools::Templates
14
14
  header 'Description:'
15
15
  para 'This tool uses an ERB template file and a set of YAML files to generate a merged file. For convenience, all of the keys in hashes in regular YAML can work like methods in the ERB templates. Thus, the YAML "{ \'a\' : {\'b\' : 3 } }" could be used in an ERB template with "<%= a.b %>" instead of the more verbose hash syntax. Indeed, the root hash values can only be accessed by those method attributes, because the root YAML context object is simply assumed.'
16
16
  para "It accepts multiple yaml files, and will merge their contents in the order in which they are given. Thus, files listed later, if their keys conflict with ones listed earlier, override the earlier listed values. If you pass in files that don't exist, no error will be raised unless the '--strict' flag is passed."
17
+ para "Instead of reading from the template, you can also supply an expression to evaluate from the command line."
17
18
  para "Check out the '--examples' flag for more details."
18
19
 
19
20
  header 'Options:'
20
- file :template, "The ERB template file to use for generation" do
21
- required
21
+ string :template, "The ERB template file to use for generation" do
22
22
  depends_on :examples
23
+
24
+ validate do |path, options|
25
+ if !File.exists?(path)
26
+ die "file doesn't exist: #{path}"
27
+ end
28
+
29
+ options[:erb] = File.read(path)
30
+ end
23
31
  end
24
32
  string :output, "Write the generated output to a file instead of STDOUT" do
25
33
  validate do |path, options|
@@ -28,6 +36,17 @@ module YTools::Templates
28
36
  end
29
37
  end
30
38
  end
39
+ string :expression, "Evaluate the expression, instead of a given template file." do
40
+ depends_on :examples, :template
41
+
42
+ validate do |expr, options|
43
+ if options[:template]
44
+ die "allows only --expression or --template, not both"
45
+ end
46
+
47
+ options[:erb] = expr
48
+ end
49
+ end
31
50
  end
32
51
  end
33
52
  end # CLI
@@ -12,7 +12,7 @@ module YTools::Templates
12
12
  end
13
13
 
14
14
  def execute!(yaml_files, options)
15
- @template = options[:template]
15
+ @template = options[:erb]
16
16
  @yaml_object = options[:yaml_object]
17
17
 
18
18
  if options[:debug]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ytools
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 2
10
- version: 0.2.2
9
+ - 3
10
+ version: 0.2.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Gabe McArthur