diff options
author | danielsdeleo <dan@opscode.com> | 2013-05-27 10:19:56 -0700 |
---|---|---|
committer | danielsdeleo <dan@opscode.com> | 2013-05-29 11:32:22 -0700 |
commit | 00de51bb552ea2e613afec4825277b855775b71e (patch) | |
tree | d3ddc7a693ff83b505990942535908ffcaf31a06 /lib/chef/mixin/template.rb | |
parent | e7d836f1bc6478a05419abb242197eee98c803b1 (diff) | |
download | chef-00de51bb552ea2e613afec4825277b855775b71e.tar.gz |
fix whitespace and ruby warnings
Diffstat (limited to 'lib/chef/mixin/template.rb')
-rw-r--r-- | lib/chef/mixin/template.rb | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/lib/chef/mixin/template.rb b/lib/chef/mixin/template.rb index 4557c50136..4906734900 100644 --- a/lib/chef/mixin/template.rb +++ b/lib/chef/mixin/template.rb @@ -6,9 +6,9 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,7 +22,7 @@ require 'erubis' class Chef module Mixin module Template - + module ChefContext def node return @node if @node @@ -67,14 +67,14 @@ class Chef template_location = @template_finder.find(partial_name, options) eruby = Erubis::Eruby.new(IO.read(template_location)) - output = eruby.evaluate(context) + eruby.evaluate(context) end end - + ::Erubis::Context.send(:include, ChefContext) - - # Render a template with Erubis. Takes a template as a string, and a - # context hash. + + # Render a template with Erubis. Takes a template as a string, and a + # context hash. def render_template(template, context) begin eruby = Erubis::Eruby.new(template) @@ -88,27 +88,27 @@ class Chef yield tempfile end end - + class TemplateError < RuntimeError attr_reader :original_exception, :context SOURCE_CONTEXT_WINDOW = 2 - + def initialize(original_exception, template, context) @original_exception, @template, @context = original_exception, template, context end - + def message @original_exception.message end - + def line_number @line_number ||= $1.to_i if original_exception.backtrace.find {|line| line =~ /\(erubis\):(\d+)/ } end - + def source_location "on line ##{line_number}" end - + def source_listing @source_listing ||= begin lines = @template.split(/\n/) @@ -129,7 +129,7 @@ class Chef output.join("\n") end end - + def to_s "\n\n#{self.class} (#{message}) #{source_location}:\n\n" + "#{source_listing}\n\n #{original_exception.backtrace.join("\n ")}\n\n" |