summaryrefslogtreecommitdiff
path: root/lib/chef/mixin
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2015-11-23 19:59:02 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2015-12-02 13:41:33 -0800
commit602e09a72c6617ee01ca3febb519d3fd36bd2b8c (patch)
tree376938e5ee04b27b41f4e62ff511644455bfd82e /lib/chef/mixin
parentde1f684f415faa54599c6b3abbe211d64a319aa6 (diff)
downloadchef-602e09a72c6617ee01ca3febb519d3fd36bd2b8c.tar.gz
dpkg multipackage and bonus fixes
- multipackages dpkg_package - fixes edge conditions in load-current-resource around purging/removing packages that threw errors before - fixes the ability to purge packages that have been removed - adds a lot of functional tests for dpkg_package
Diffstat (limited to 'lib/chef/mixin')
-rw-r--r--lib/chef/mixin/get_source_from_package.rb9
-rw-r--r--lib/chef/mixin/subclass_directive.rb42
2 files changed, 49 insertions, 2 deletions
diff --git a/lib/chef/mixin/get_source_from_package.rb b/lib/chef/mixin/get_source_from_package.rb
index 2ed251854a..cb5583b431 100644
--- a/lib/chef/mixin/get_source_from_package.rb
+++ b/lib/chef/mixin/get_source_from_package.rb
@@ -1,5 +1,5 @@
# Author:: Lamont Granquist (<lamont@opscode.com>)
-# Copyright:: Copyright (c) 2008 Opscode, Inc.
+# Copyright:: Copyright (c) 2008-2015 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -27,6 +27,12 @@
class Chef
module Mixin
module GetSourceFromPackage
+ # FIXME: this is some bad code that I wrote a long time ago.
+ # - it does too much in the initializer
+ # - it mutates the new_resource
+ # - it does not support multipackage arrays
+ # this code is deprecated, check out the :use_package_names_for_source
+ # subclass directive instead
def initialize(new_resource, run_context)
super
return if new_resource.package_name.is_a?(Array)
@@ -40,4 +46,3 @@ class Chef
end
end
end
-
diff --git a/lib/chef/mixin/subclass_directive.rb b/lib/chef/mixin/subclass_directive.rb
new file mode 100644
index 0000000000..c0c7aa0328
--- /dev/null
+++ b/lib/chef/mixin/subclass_directive.rb
@@ -0,0 +1,42 @@
+#
+# Author:: Adam Jacob (<adam@opscode.com>)
+# Copyright:: Copyright (c) 2008-2015 Chef Software, Inc.
+# License:: Apache License, Version 2.0
+#
+# 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.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+class Chef
+ module Mixin
+ module SubclassDirective
+ def self.included(base)
+ base.extend(ClassMethods)
+ end
+ module ClassMethods
+ def subclass_directive(sym)
+ define_singleton_method sym do
+ instance_variable_set(:"@#{sym}", true)
+ end
+
+ define_singleton_method :"#{sym}?" do
+ !!instance_variable_get(:"@#{sym}")
+ end
+
+ define_method :"#{sym}?" do
+ self.class.send(:"#{sym}?")
+ end
+ end
+ end
+ end
+ end
+end