ytools 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -27,8 +27,8 @@ begin
27
27
  gem.authors = ['Gabe McArthur']
28
28
  gem.homepage = 'http://github.com/gabemc/ytools'
29
29
  gem.files = FileList["[A-Z]*", "{bin,lib,spec}/**/*"]
30
-
31
- gem.add_development_dependency 'rspec', '>=2.0.1'
30
+
31
+ gem.add_development_dependency 'rspec', '~> 2.5'
32
32
  end
33
33
  rescue LoadError
34
34
  puts "Jeweler or dependencies are not available. Install it with: sudo gem install jeweler"
data/lib/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.5
1
+ 0.1.6
@@ -13,11 +13,16 @@ module YTools::Templates
13
13
  YTools::YamlObject.new
14
14
  end
15
15
 
16
+ template = options[:expression]
17
+ if template.nil?
18
+ File.open(template, 'r') { |f| template = f.read}
19
+ end
20
+
16
21
  if options[:literal]
17
22
  yaml_object.merge(YAML::load(options[:literal]))
18
23
  end
19
24
 
20
- executor = Executor.new(options[:template], yaml_object)
25
+ executor = Executor.new(template, yaml_object)
21
26
 
22
27
  if options[:debug]
23
28
  STDERR.puts yaml_object
@@ -54,6 +59,11 @@ EOF
54
59
  "The ERB template file to use for generation") do |t|
55
60
  options[:template] = t
56
61
  end
62
+ opts.on('-e', '--expression EXPR',
63
+ "The ERB expression to use for generation",
64
+ "overrides --template") do |e|
65
+ options[:expression] = e
66
+ end
57
67
  opts.on('-l', '--literal STRING',
58
68
  "Evaluate a literal string in addition",
59
69
  "to any file paths") do |l|
@@ -71,7 +81,7 @@ EOF
71
81
  end
72
82
  opts.separator ""
73
83
 
74
- opts.on('-e', '--examples',
84
+ opts.on('--examples',
75
85
  "Show some examples on how to use the",
76
86
  "path syntax.") do
77
87
  print_examples(File.dirname(__FILE__))
@@ -94,11 +104,11 @@ EOF
94
104
  end
95
105
 
96
106
  def validate(args)
97
- if options[:template].nil?
98
- raise YTools::ConfigurationError.new("No template file was indicated")
107
+ if options[:expression].nil? && options[:template].nil?
108
+ raise YTools::ConfigurationError.new("No template expression or file was indicated")
99
109
  end
100
110
 
101
- if !File.exists?(options[:template])
111
+ if options[:expression].nil? && !File.exists?(options[:template])
102
112
  raise YTools::ConfigurationError.new("Unable to locate the template file: #{options[:template]}")
103
113
  end
104
114
 
@@ -12,10 +12,7 @@ module YTools::Templates
12
12
  end
13
13
 
14
14
  def write!(outfile)
15
- tcontents = nil
16
- File.open(template, 'r') { |f| tcontents = f.read}
17
-
18
- generator = ERB.new(tcontents)
15
+ generator = ERB.new(template)
19
16
  output = generator.result(yaml_object.erb_binding)
20
17
 
21
18
  if outfile
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ytools
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 1
9
- - 5
10
- version: 0.1.5
8
+ - 6
9
+ version: 0.1.6
11
10
  platform: ruby
12
11
  authors:
13
12
  - Gabe McArthur
@@ -15,7 +14,7 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2010-11-12 00:00:00 -08:00
17
+ date: 2011-02-12 00:00:00 -08:00
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
@@ -24,14 +23,12 @@ dependencies:
24
23
  requirement: &id001 !ruby/object:Gem::Requirement
25
24
  none: false
26
25
  requirements:
27
- - - ">="
26
+ - - ~>
28
27
  - !ruby/object:Gem::Version
29
- hash: 13
30
28
  segments:
31
29
  - 2
32
- - 0
33
- - 1
34
- version: 2.0.1
30
+ - 5
31
+ version: "2.5"
35
32
  type: :development
36
33
  version_requirements: *id001
37
34
  description: Installs the ypath tool for reading YAML files using an XPath-like syntax. Installs the ytemplates tool for writing ERB templates using YAML files as the template binding object.
@@ -82,8 +79,8 @@ homepage: http://github.com/gabemc/ytools
82
79
  licenses: []
83
80
 
84
81
  post_install_message:
85
- rdoc_options:
86
- - --charset=UTF-8
82
+ rdoc_options: []
83
+
87
84
  require_paths:
88
85
  - lib
89
86
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -91,7 +88,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
91
88
  requirements:
92
89
  - - ">="
93
90
  - !ruby/object:Gem::Version
94
- hash: 3
95
91
  segments:
96
92
  - 0
97
93
  version: "0"
@@ -100,7 +96,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
96
  requirements:
101
97
  - - ">="
102
98
  - !ruby/object:Gem::Version
103
- hash: 3
104
99
  segments:
105
100
  - 0
106
101
  version: "0"
@@ -113,8 +108,8 @@ specification_version: 3
113
108
  summary: For reading or writing configuration files using YAML.
114
109
  test_files:
115
110
  - spec/helpers.rb
116
- - spec/yaml_object_spec.rb
117
- - spec/path/lexer_spec.rb
118
111
  - spec/path/executor_spec.rb
119
- - spec/path/selectors_spec.rb
112
+ - spec/path/lexer_spec.rb
120
113
  - spec/path/parser_spec.rb
114
+ - spec/path/selectors_spec.rb
115
+ - spec/yaml_object_spec.rb