summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanielsdeleo <dan@opscode.com>2012-10-17 12:58:39 -0700
committerdanielsdeleo <dan@opscode.com>2012-10-19 14:15:59 -0700
commit655ddec9ba70f134f1b1318545ea65029a619178 (patch)
tree21b15436fd746a43c75404d9e71b792430566838
parent9c45af5a5f1a2eb26c4cf870b64b08e7c7cebaaf (diff)
downloadchef-655ddec9ba70f134f1b1318545ea65029a619178.tar.gz
[CHEF-3499] move include attribute into DSL namespace
-rw-r--r--chef/lib/chef/dsl.rb1
-rw-r--r--chef/lib/chef/dsl/include_attribute.rb62
-rw-r--r--chef/lib/chef/mixin/language_include_attribute.rb44
-rw-r--r--chef/lib/chef/mixins.rb1
-rw-r--r--chef/lib/chef/node.rb4
5 files changed, 71 insertions, 41 deletions
diff --git a/chef/lib/chef/dsl.rb b/chef/lib/chef/dsl.rb
index e476120896..74244fafbb 100644
--- a/chef/lib/chef/dsl.rb
+++ b/chef/lib/chef/dsl.rb
@@ -2,3 +2,4 @@ require 'chef/dsl/recipe'
require 'chef/dsl/platform_introspection'
require 'chef/dsl/data_query'
require 'chef/dsl/include_recipe'
+require 'chef/dsl/include_attribute'
diff --git a/chef/lib/chef/dsl/include_attribute.rb b/chef/lib/chef/dsl/include_attribute.rb
new file mode 100644
index 0000000000..bccc7e8955
--- /dev/null
+++ b/chef/lib/chef/dsl/include_attribute.rb
@@ -0,0 +1,62 @@
+#
+# Author:: Adam Jacob (<adam@opscode.com>)
+# Copyright:: Copyright (c) 2008, 2009 Opscode, 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.
+#
+
+require 'chef/log'
+
+class Chef
+ module DSL
+ module IncludeAttribute
+
+ # Loads the attribute file specified by the short name of the
+ # file, e.g., loads specified cookbook's
+ # "attributes/mailservers.rb"
+ # if passed
+ # "mailservers"
+ def include_attribute(*fully_qualified_attribute_short_filenames)
+ if self.kind_of?(Chef::Node)
+ node = self
+ else
+ node = @node
+ end
+
+ fully_qualified_attribute_short_filenames.flatten.each do |fully_qualified_attribute_short_filename|
+ if node.run_state[:seen_attributes].has_key?(fully_qualified_attribute_short_filename)
+ Chef::Log.debug("I am not loading attribute file #{fully_qualified_attribute_short_filename}, because I have already seen it.")
+ next
+ end
+
+ Chef::Log.debug("Loading Attribute #{fully_qualified_attribute_short_filename}")
+ node.run_state[:seen_attributes][fully_qualified_attribute_short_filename] = true
+
+ if amatch = fully_qualified_attribute_short_filename.match(/(.+?)::(.+)/)
+ cookbook_name = amatch[1].to_sym
+ node.load_attribute_by_short_filename(amatch[2], cookbook_name)
+ else
+ cookbook_name = fully_qualified_attribute_short_filename.to_sym
+ node.load_attribute_by_short_filename("default", cookbook_name)
+ end
+ end
+ true
+ end
+
+ end
+ end
+end
+
+
+
diff --git a/chef/lib/chef/mixin/language_include_attribute.rb b/chef/lib/chef/mixin/language_include_attribute.rb
index 5d926a6761..283773b25d 100644
--- a/chef/lib/chef/mixin/language_include_attribute.rb
+++ b/chef/lib/chef/mixin/language_include_attribute.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.
@@ -16,46 +16,14 @@
# limitations under the License.
#
-require 'chef/log'
+require 'chef/dsl/include_attribute'
class Chef
module Mixin
- module LanguageIncludeAttribute
-
- # Loads the attribute file specified by the short name of the
- # file, e.g., loads specified cookbook's
- # "attributes/mailservers.rb"
- # if passed
- # "mailservers"
- def include_attribute(*fully_qualified_attribute_short_filenames)
- if self.kind_of?(Chef::Node)
- node = self
- else
- node = @node
- end
-
- fully_qualified_attribute_short_filenames.flatten.each do |fully_qualified_attribute_short_filename|
- if node.run_state[:seen_attributes].has_key?(fully_qualified_attribute_short_filename)
- Chef::Log.debug("I am not loading attribute file #{fully_qualified_attribute_short_filename}, because I have already seen it.")
- next
- end
-
- Chef::Log.debug("Loading Attribute #{fully_qualified_attribute_short_filename}")
- node.run_state[:seen_attributes][fully_qualified_attribute_short_filename] = true
-
- if amatch = fully_qualified_attribute_short_filename.match(/(.+?)::(.+)/)
- cookbook_name = amatch[1].to_sym
- node.load_attribute_by_short_filename(amatch[2], cookbook_name)
- else
- cookbook_name = fully_qualified_attribute_short_filename.to_sym
- node.load_attribute_by_short_filename("default", cookbook_name)
- end
- end
- true
- end
- end
+ # DEPRECATED: This is just here for compatibility, use
+ # Chef::DSL::IncludeAttribute instead.
+ LanguageIncludeAttribute = Chef::DSL::IncludeAttribute
end
end
-
diff --git a/chef/lib/chef/mixins.rb b/chef/lib/chef/mixins.rb
index fba2017a3a..557932c0e6 100644
--- a/chef/lib/chef/mixins.rb
+++ b/chef/lib/chef/mixins.rb
@@ -7,7 +7,6 @@ require 'chef/mixin/create_path'
require 'chef/mixin/deep_merge'
require 'chef/mixin/enforce_ownership_and_permissions'
require 'chef/mixin/from_file'
-require 'chef/mixin/language_include_attribute'
require 'chef/mixin/params_validate'
require 'chef/mixin/path_sanity'
require 'chef/mixin/template'
diff --git a/chef/lib/chef/node.rb b/chef/lib/chef/node.rb
index 4500c7eb12..e52338716c 100644
--- a/chef/lib/chef/node.rb
+++ b/chef/lib/chef/node.rb
@@ -26,7 +26,7 @@ require 'chef/nil_argument'
require 'chef/mixin/check_helper'
require 'chef/mixin/params_validate'
require 'chef/mixin/from_file'
-require 'chef/mixin/language_include_attribute'
+require 'chef/dsl/include_attribute'
require 'chef/mixin/deep_merge'
require 'chef/environment'
require 'chef/couchdb'
@@ -56,7 +56,7 @@ class Chef
include Chef::Mixin::CheckHelper
include Chef::Mixin::FromFile
include Chef::Mixin::ParamsValidate
- include Chef::Mixin::LanguageIncludeAttribute
+ include Chef::DSL::IncludeAttribute
include Chef::IndexQueue::Indexable
DESIGN_DOCUMENT = {