ytools 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/VERSION +1 -1
  2. data/lib/ytools/templates/cli.rb +8 -24
  3. metadata +3 -3
data/lib/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.8
1
+ 0.1.9
@@ -17,7 +17,12 @@ module YTools::Templates
17
17
  yaml_object.merge(YAML::load(options[:literal]))
18
18
  end
19
19
 
20
- executor = Executor.new(template_contents, yaml_object)
20
+ template = options[:expression]
21
+ if template.nil?
22
+ File.open(options[:template], 'r') { |f| template = f.read}
23
+ end
24
+
25
+ executor = Executor.new(template, yaml_object)
21
26
 
22
27
  if options[:debug]
23
28
  STDERR.puts yaml_object
@@ -26,15 +31,6 @@ module YTools::Templates
26
31
  executor.write!(options[:output])
27
32
  end
28
33
 
29
- def template_contents
30
- template = options[:stdin] || options[:expression]
31
- if template.nil?
32
- File.open(options[:template], 'r') { |f| template = f.read}
33
- end
34
-
35
- template
36
- end
37
-
38
34
  def parse(args)
39
35
  OptionParser.new do |opts|
40
36
  opts.banner = "Usage: #{File.basename($0)} [OPTIONS] YAML_FILES"
@@ -55,9 +51,6 @@ Description:
55
51
  values. If you pass in files that don't exist, no error will be
56
52
  raised unless the '--strict' flag is passed.
57
53
 
58
- Instead of supplying an expression via --expression or a template
59
- via --template, you can also pipe in an expression via STDIN.
60
-
61
54
  Check out the '--examples' flag for more details.
62
55
 
63
56
  Options:
@@ -111,20 +104,11 @@ EOF
111
104
  end
112
105
 
113
106
  def validate(args)
114
- if RUBY_PLATFORM =~ /win/ && $stdin.stat.size > 0
115
- options[:stdin] = STDIN.read
116
- else
117
- require 'fcntl'
118
- if STDIN.fcntl(Fcntl::F_GETFL, 0) == 0
119
- options[:stdin] = STDIN.read
120
- end
121
- end
122
-
123
- if options[:stdin].nil? && options[:expression].nil? && options[:template].nil?
107
+ if options[:expression].nil? && options[:template].nil?
124
108
  raise YTools::ConfigurationError.new("No template expression or file was indicated")
125
109
  end
126
110
 
127
- if options[:stdin].nil? && options[:expression].nil? && !File.exists?(options[:template])
111
+ if options[:expression].nil? && !File.exists?(options[:template])
128
112
  raise YTools::ConfigurationError.new("Unable to locate the template file: #{options[:template]}")
129
113
  end
130
114
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ytools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,7 +14,7 @@ default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
17
- requirement: &79211790 !ruby/object:Gem::Requirement
17
+ requirement: &85986530 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,7 +22,7 @@ dependencies:
22
22
  version: '2.5'
23
23
  type: :development
24
24
  prerelease: false
25
- version_requirements: *79211790
25
+ version_requirements: *85986530
26
26
  description: Installs the ypath tool for reading YAML files using an XPath-like syntax. Installs
27
27
  the ytemplates tool for writing ERB templates using YAML files as the template binding
28
28
  object.