summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2015-03-12 15:21:59 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2015-08-18 12:03:21 -0700
commit6b4713081fcccede0c9857987e9e3fd47d94c14d (patch)
treec10ca0d035061edee5b3c39fd9e3ae8377fa7781
parent63a2d95003bc062d251d453d63ab1c5d91cbdb06 (diff)
downloadchef-6b4713081fcccede0c9857987e9e3fd47d94c14d.tar.gz
PR feedback
-rw-r--r--lib/chef/mixin/template.rb78
-rw-r--r--spec/unit/provider/template/content_spec.rb2
2 files changed, 40 insertions, 40 deletions
diff --git a/lib/chef/mixin/template.rb b/lib/chef/mixin/template.rb
index 546b76cf80..be83edc697 100644
--- a/lib/chef/mixin/template.rb
+++ b/lib/chef/mixin/template.rb
@@ -44,71 +44,71 @@ class Chef
attr_reader :_extension_modules
- def initialize(variables)
- super
- @_extension_modules = []
- end
-
- ###
- # USER FACING API
- ###
-
- # Returns the current node object, or raises an error if it's not set.
- # Provides API consistency, allowing users to reference the node object
- # by the bare `node` everywhere.
- def node
- return @node if @node
- # XXX: we include @node even if you explicitly pass vars, so is this warning never reached?
- raise "Could not find a value for node. If you are explicitly setting variables in a template, " +
- "include a node variable if you plan to use it."
- end
-
#
# Helpers for adding context of which resource is rendering the template (CHEF-5012)
#
# name of the cookbook containing the template resource, e.g.:
# test
- def cookbook_name
- return @cookbook_name if @cookbook_name
- end
+ #
+ # @return [String] cookbook name
+ attr_reader :cookbook_name
# name of the recipe containing the template resource, e.g.:
# default
- def recipe_name
- return @recipe_name if @recipe_name
- end
+ #
+ # @return [String] recipe name
+ attr_reader :recipe_name
# string representation of the line in the recipe containing the template resource, e.g.:
# /Users/lamont/solo/cookbooks/test/recipes/default.rb:2:in `from_file'
- def recipe_line_string
- return @recipe_line_string if @recipe_line_string
- end
+ #
+ # @return [String] recipe line
+ attr_reader :recipe_line_string
# path to the recipe containing the template resource, e.g.:
# /Users/lamont/solo/cookbooks/test/recipes/default.rb
- def recipe_path
- return @recipe_path if @recipe_path
- end
+ #
+ # @return [String] recipe path
+ attr_reader :recipe_path
# line in the recipe containing the template reosurce, e.g.:
# 2
- def recipe_line
- return @recipe_line if @recipe_line
- end
+ #
+ # @return [String] recipe line
+ attr_reader :recipe_line
# name of the template source itself, e.g.:
# foo.erb
- def template_name
- return @template_name if @template_name
- end
+ #
+ # @return [String] template name
+ attr_reader :template_name
# path to the template source itself, e.g.:
# /Users/lamont/solo/cookbooks/test/templates/default/foo.erb
- def template_path
- return @template_path if @template_path
+ #
+ # @return [String] template path
+ attr_reader :template_path
+
+ def initialize(variables)
+ super
+ @_extension_modules = []
+ end
+
+ ###
+ # USER FACING API
+ ###
+
+ # Returns the current node object, or raises an error if it's not set.
+ # Provides API consistency, allowing users to reference the node object
+ # by the bare `node` everywhere.
+ def node
+ return @node if @node
+ raise "Could not find a value for node. If you are explicitly setting variables in a template, " +
+ "include a node variable if you plan to use it."
end
+
#
# Takes the name of the partial, plus a hash of options. Returns a
# string that contains the result of the evaluation of the partial.
diff --git a/spec/unit/provider/template/content_spec.rb b/spec/unit/provider/template/content_spec.rb
index ef7419d9b8..3d6e822c00 100644
--- a/spec/unit/provider/template/content_spec.rb
+++ b/spec/unit/provider/template/content_spec.rb
@@ -97,7 +97,7 @@ describe Chef::Provider::Template::Content do
end
it "creates the template with the rendered content" do
- IO.read(content.tempfile.path).should == <<EOF
+ expect(IO.read(content.tempfile.path)).to eql <<EOF
openldap
default
#{CHEF_SPEC_DATA}/cookbooks/openldap/recipes/default.rb:2:in `from_file'