summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2017-12-13 12:04:33 -0800
committerTim Smith <tsmith@chef.io>2017-12-13 12:04:33 -0800
commit0d14959ebef1f7cd051e1621e9785555981d5500 (patch)
treee207f1c1e35b49910d41474742d02a646088da28
parent8c923eee2f43bbd48ffc8f8137c369e5c3661a2b (diff)
downloadchef-0d14959ebef1f7cd051e1621e9785555981d5500.tar.gz
Add a few more comments to resources
I try to add them as I read through resources Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/chef/resource/chef_gem.rb1
-rw-r--r--lib/chef/resource/freebsd_package.rb11
-rw-r--r--lib/chef/resource/resource_notification.rb17
3 files changed, 27 insertions, 2 deletions
diff --git a/lib/chef/resource/chef_gem.rb b/lib/chef/resource/chef_gem.rb
index 7025d74e58..3a2d90e852 100644
--- a/lib/chef/resource/chef_gem.rb
+++ b/lib/chef/resource/chef_gem.rb
@@ -30,6 +30,7 @@ class Chef
}
property :compile_time, [ true, false ], default: false, desired_state: false
+ # force the resource to compile time if the compile time property has been set
def after_created
if compile_time
Array(action).each do |action|
diff --git a/lib/chef/resource/freebsd_package.rb b/lib/chef/resource/freebsd_package.rb
index ecaff95244..eedddf28e7 100644
--- a/lib/chef/resource/freebsd_package.rb
+++ b/lib/chef/resource/freebsd_package.rb
@@ -32,19 +32,26 @@ class Chef
resource_name :freebsd_package
provides :package, platform: "freebsd"
+ # make sure we assign the appropriate underlying providers based on what
+ # package managers exist on this FreeBSD system or the source of the package
+ #
+ # @return [void]
def after_created
assign_provider
end
+ # Is the system at least version 1000017 or is the make variable WITH_PKGNG set
+ #
+ # @return [Boolean] do we support pkgng
def supports_pkgng?
ships_with_pkgng? || !!shell_out_compact!("make", "-V", "WITH_PKGNG", :env => nil).stdout.match(/yes/i)
end
private
+ # It was not until __FreeBSD_version 1000017 that pkgng became
+ # the default binary package manager. See '/usr/ports/Mk/bsd.port.mk'.
def ships_with_pkgng?
- # It was not until __FreeBSD_version 1000017 that pkgng became
- # the default binary package manager. See '/usr/ports/Mk/bsd.port.mk'.
node[:os_version].to_i >= 1000017
end
diff --git a/lib/chef/resource/resource_notification.rb b/lib/chef/resource/resource_notification.rb
index ee90064a17..bd09097669 100644
--- a/lib/chef/resource/resource_notification.rb
+++ b/lib/chef/resource/resource_notification.rb
@@ -20,6 +20,10 @@ require "chef/resource"
class Chef
class Resource
+ # @author Tyler Ball
+ # @attr [Resource] resource the Chef resource object to notify to
+ # @attr [Action] action the action to notify
+ # @attr [Resource] notifying_resource the Chef resource performing the notification
class Notification
attr_accessor :resource, :action, :notifying_resource
@@ -30,6 +34,10 @@ class Chef
@notifying_resource = notifying_resource
end
+ # Is the current notification a duplicate of another notification
+ #
+ # @param [Notification] another notification object to compare to
+ # @return [Boolean] does the resource match
def duplicates?(other_notification)
unless other_notification.respond_to?(:resource) && other_notification.respond_to?(:action)
msg = "only duck-types of Chef::Resource::Notification can be checked for duplication "\
@@ -41,6 +49,9 @@ class Chef
# If resource and/or notifying_resource is not a resource object, this will look them up in the resource collection
# and fix the references from strings to actual Resource objects.
+ # @param [ResourceCollection] resource_collection
+ #
+ # @return [void]
def resolve_resource_reference(resource_collection)
return resource if resource.kind_of?(Chef::Resource) && notifying_resource.kind_of?(Chef::Resource)
@@ -55,6 +66,9 @@ class Chef
# This will look up the resource if it is not a Resource Object. It will complain if it finds multiple
# resources, can't find a resource, or gets invalid syntax.
+ # @param [ResourceCollection] resource_collection
+ #
+ # @return [void]
def fix_resource_reference(resource_collection)
matching_resource = resource_collection.find(resource)
if Array(matching_resource).size > 1
@@ -84,6 +98,9 @@ is defined near #{notifying_resource.source_line}
# This will look up the notifying_resource if it is not a Resource Object. It will complain if it finds multiple
# resources, can't find a resource, or gets invalid syntax.
+ # @param [ResourceCollection] resource_collection
+ #
+ # @return [void]
def fix_notifier_reference(resource_collection)
matching_notifier = resource_collection.find(notifying_resource)
if Array(matching_notifier).size > 1