summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-12-09 15:30:11 -0600
committerLuke Kanies <luke@madstop.com>2008-12-09 15:30:11 -0600
commitc927ce05bbd96fa9aacc8e52f8eb797403a1e433 (patch)
tree721ca37083dcf46f4f94610d8003df53450c64c1
parente88746b48cfd4ce7cd9acd0baf61d9b660b460e9 (diff)
downloadpuppet-c927ce05bbd96fa9aacc8e52f8eb797403a1e433.tar.gz
puppet-c927ce05bbd96fa9aacc8e52f8eb797403a1e433.tar.xz
puppet-c927ce05bbd96fa9aacc8e52f8eb797403a1e433.zip
Renaming Puppet::ResourceReference to Puppet::Resource::Reference
Signed-off-by: Luke Kanies <luke@madstop.com>
-rw-r--r--lib/puppet/node/catalog.rb4
-rw-r--r--lib/puppet/parser/ast/resource_defaults.rb2
-rw-r--r--lib/puppet/parser/collector.rb2
-rw-r--r--lib/puppet/parser/resource/reference.rb4
-rw-r--r--lib/puppet/resource.rb8
-rw-r--r--lib/puppet/resource/reference.rb (renamed from lib/puppet/resource_reference.rb)3
-rw-r--r--lib/puppet/transportable.rb10
-rw-r--r--lib/puppet/type.rb4
-rw-r--r--lib/puppet/type/component.rb2
-rwxr-xr-xspec/unit/resource.rb20
-rwxr-xr-xspec/unit/resource/reference.rb (renamed from spec/unit/resource_reference.rb)34
11 files changed, 47 insertions, 46 deletions
diff --git a/lib/puppet/node/catalog.rb b/lib/puppet/node/catalog.rb
index f6c0a1959..bc522cc1e 100644
--- a/lib/puppet/node/catalog.rb
+++ b/lib/puppet/node/catalog.rb
@@ -368,12 +368,12 @@ class Puppet::Node::Catalog < Puppet::SimpleGraph
# Always create a resource reference, so that it always canonizes how we
# are referring to them.
if title
- ref = Puppet::ResourceReference.new(type, title).to_s
+ ref = Puppet::Resource::Reference.new(type, title).to_s
else
# If they didn't provide a title, then we expect the first
# argument to be of the form 'Class[name]', which our
# Reference class canonizes for us.
- ref = Puppet::ResourceReference.new(nil, type).to_s
+ ref = Puppet::Resource::Reference.new(nil, type).to_s
end
@resource_table[ref]
end
diff --git a/lib/puppet/parser/ast/resource_defaults.rb b/lib/puppet/parser/ast/resource_defaults.rb
index 4919817fb..ed83d3573 100644
--- a/lib/puppet/parser/ast/resource_defaults.rb
+++ b/lib/puppet/parser/ast/resource_defaults.rb
@@ -12,7 +12,7 @@ class Puppet::Parser::AST
# object type.
def evaluate(scope)
# Use a resource reference to canonize the type
- ref = Puppet::ResourceReference.new(@type, "whatever")
+ ref = Puppet::Resource::Reference.new(@type, "whatever")
type = ref.type
params = @params.safeevaluate(scope)
diff --git a/lib/puppet/parser/collector.rb b/lib/puppet/parser/collector.rb
index 0f9072510..fb7d95c52 100644
--- a/lib/puppet/parser/collector.rb
+++ b/lib/puppet/parser/collector.rb
@@ -35,7 +35,7 @@ class Puppet::Parser::Collector
@scope = scope
# Canonize the type
- @type = Puppet::ResourceReference.new(type, "whatever").type
+ @type = Puppet::Resource::Reference.new(type, "whatever").type
@equery = equery
@vquery = vquery
diff --git a/lib/puppet/parser/resource/reference.rb b/lib/puppet/parser/resource/reference.rb
index cb505d606..e552b51fe 100644
--- a/lib/puppet/parser/resource/reference.rb
+++ b/lib/puppet/parser/resource/reference.rb
@@ -1,7 +1,7 @@
-require 'puppet/resource_reference'
+require 'puppet/resource/reference'
# A reference to a resource. Mostly just the type and title.
-class Puppet::Parser::Resource::Reference < Puppet::ResourceReference
+class Puppet::Parser::Resource::Reference < Puppet::Resource::Reference
include Puppet::Util::MethodHelper
include Puppet::Util::Errors
diff --git a/lib/puppet/resource.rb b/lib/puppet/resource.rb
index 9bbec2a4c..1cd0c2e5f 100644
--- a/lib/puppet/resource.rb
+++ b/lib/puppet/resource.rb
@@ -1,6 +1,6 @@
require 'puppet'
require 'puppet/util/tagging'
-require 'puppet/resource_reference'
+require 'puppet/resource/reference'
# The simplest resource class. Eventually it will function as the
# base class for all resource-like behaviour.
@@ -36,7 +36,7 @@ class Puppet::Resource
# Create our resource.
def initialize(type, title, parameters = {})
- @reference = Puppet::ResourceReference.new(type, title)
+ @reference = Puppet::Resource::Reference.new(type, title)
@parameters = {}
parameters.each do |param, value|
@@ -130,11 +130,11 @@ class Puppet::Resource
# Now convert to a transobject
result = Puppet::TransObject.new(@reference.title, @reference.type)
to_hash.each do |p, v|
- if v.is_a?(Puppet::ResourceReference)
+ if v.is_a?(Puppet::Resource::Reference)
v = v.to_trans_ref
elsif v.is_a?(Array)
v = v.collect { |av|
- if av.is_a?(Puppet::ResourceReference)
+ if av.is_a?(Puppet::Resource::Reference)
av = av.to_trans_ref
end
av
diff --git a/lib/puppet/resource_reference.rb b/lib/puppet/resource/reference.rb
index 43479ff0c..dfd6d03cb 100644
--- a/lib/puppet/resource_reference.rb
+++ b/lib/puppet/resource/reference.rb
@@ -3,10 +3,11 @@
# Copyright (c) 2007. All rights reserved.
require 'puppet'
+require 'puppet/resource'
# A simple class to canonize how we refer to and retrieve
# resources.
-class Puppet::ResourceReference
+class Puppet::Resource::Reference
attr_reader :type
attr_accessor :title, :catalog
diff --git a/lib/puppet/transportable.rb b/lib/puppet/transportable.rb
index 41c51fde6..b809d5b94 100644
--- a/lib/puppet/transportable.rb
+++ b/lib/puppet/transportable.rb
@@ -1,5 +1,5 @@
require 'puppet'
-require 'puppet/resource_reference'
+require 'puppet/resource/reference'
require 'yaml'
module Puppet
@@ -36,7 +36,7 @@ module Puppet
def ref
unless defined? @ref
- @ref = Puppet::ResourceReference.new(@type, @name)
+ @ref = Puppet::Resource::Reference.new(@type, @name)
end
@ref.to_s
end
@@ -221,11 +221,11 @@ module Puppet
def to_ref
unless defined? @ref
if self.type and self.name
- @ref = Puppet::ResourceReference.new(self.type, self.name)
+ @ref = Puppet::Resource::Reference.new(self.type, self.name)
elsif self.type and ! self.name # This is old-school node types
- @ref = Puppet::ResourceReference.new("node", self.type)
+ @ref = Puppet::Resource::Reference.new("node", self.type)
elsif ! self.type and self.name
- @ref = Puppet::ResourceReference.new("component", self.name)
+ @ref = Puppet::Resource::Reference.new("component", self.name)
else
@ref = nil
end
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb
index be37c44c8..6f965c28d 100644
--- a/lib/puppet/type.rb
+++ b/lib/puppet/type.rb
@@ -9,7 +9,7 @@ require 'puppet/metatype/manager'
require 'puppet/util/errors'
require 'puppet/util/log_paths'
require 'puppet/util/logging'
-require 'puppet/resource_reference'
+require 'puppet/resource/reference'
require 'puppet/util/cacher'
# see the bottom of the file for the rest of the inclusions
@@ -1537,7 +1537,7 @@ class Type
# we just have a name and a type, and we need to convert it
# to an object...
tname, name = value
- reference = Puppet::ResourceReference.new(tname, name)
+ reference = Puppet::Resource::Reference.new(tname, name)
reference.catalog = resource.catalog
# Either of the two retrieval attempts could have returned
diff --git a/lib/puppet/type/component.rb b/lib/puppet/type/component.rb
index 498f1c503..c9e1d8973 100644
--- a/lib/puppet/type/component.rb
+++ b/lib/puppet/type/component.rb
@@ -85,7 +85,7 @@ Puppet::Type.newtype(:component) do
@children = []
super
- @reference = Puppet::ResourceReference.new(:component, @title)
+ @reference = Puppet::Resource::Reference.new(:component, @title)
if catalog and ! catalog.resource(@reference.to_s)
catalog.alias(self, @reference.to_s)
diff --git a/spec/unit/resource.rb b/spec/unit/resource.rb
index b21a6fccb..f90856177 100755
--- a/spec/unit/resource.rb
+++ b/spec/unit/resource.rb
@@ -18,8 +18,8 @@ describe Puppet::Resource do
end
it "should create a resource reference with its type and title" do
- ref = Puppet::ResourceReference.new("file", "/f")
- Puppet::ResourceReference.expects(:new).with("file", "/f").returns ref
+ ref = Puppet::Resource::Reference.new("file", "/f")
+ Puppet::Resource::Reference.expects(:new).with("file", "/f").returns ref
Puppet::Resource.new("file", "/f")
end
@@ -41,24 +41,24 @@ describe Puppet::Resource do
end
it "should use the resource reference to determine its type" do
- ref = Puppet::ResourceReference.new("file", "/f")
- Puppet::ResourceReference.expects(:new).returns ref
+ ref = Puppet::Resource::Reference.new("file", "/f")
+ Puppet::Resource::Reference.expects(:new).returns ref
resource = Puppet::Resource.new("file", "/f")
ref.expects(:type).returns "mytype"
resource.type.should == "mytype"
end
it "should use its resource reference to determine its title" do
- ref = Puppet::ResourceReference.new("file", "/f")
- Puppet::ResourceReference.expects(:new).returns ref
+ ref = Puppet::Resource::Reference.new("file", "/f")
+ Puppet::Resource::Reference.expects(:new).returns ref
resource = Puppet::Resource.new("file", "/f")
ref.expects(:title).returns "mytitle"
resource.title.should == "mytitle"
end
it "should use its resource reference to produce its canonical reference string" do
- ref = Puppet::ResourceReference.new("file", "/f")
- Puppet::ResourceReference.expects(:new).returns ref
+ ref = Puppet::Resource::Reference.new("file", "/f")
+ Puppet::Resource::Reference.expects(:new).returns ref
resource = Puppet::Resource.new("file", "/f")
ref.expects(:to_s).returns "Foo[bar]"
resource.ref.should == "Foo[bar]"
@@ -266,12 +266,12 @@ describe Puppet::Resource do
end
it "should convert resource references into the backward-compatible form" do
- @resource[:foo] = Puppet::ResourceReference.new(:file, "/f")
+ @resource[:foo] = Puppet::Resource::Reference.new(:file, "/f")
@resource.to_trans["foo"].should == %w{file /f}
end
it "should convert resource references into the backward-compatible form even when within arrays" do
- @resource[:foo] = ["a", Puppet::ResourceReference.new(:file, "/f")]
+ @resource[:foo] = ["a", Puppet::Resource::Reference.new(:file, "/f")]
@resource.to_trans["foo"].should == ["a", %w{file /f}]
end
end
diff --git a/spec/unit/resource_reference.rb b/spec/unit/resource/reference.rb
index baa3890cb..e16fe55ba 100755
--- a/spec/unit/resource_reference.rb
+++ b/spec/unit/resource/reference.rb
@@ -1,73 +1,73 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.dirname(__FILE__) + '/../../spec_helper'
-require 'puppet/resource_reference'
+require 'puppet/resource/reference'
-describe Puppet::ResourceReference do
+describe Puppet::Resource::Reference do
it "should have a :title attribute" do
- Puppet::ResourceReference.new(:file, "foo").title.should == "foo"
+ Puppet::Resource::Reference.new(:file, "foo").title.should == "foo"
end
it "should canonize types to capitalized strings" do
- Puppet::ResourceReference.new(:file, "foo").type.should == "File"
+ Puppet::Resource::Reference.new(:file, "foo").type.should == "File"
end
it "should canonize qualified types so all strings are capitalized" do
- Puppet::ResourceReference.new("foo::bar", "foo").type.should == "Foo::Bar"
+ Puppet::Resource::Reference.new("foo::bar", "foo").type.should == "Foo::Bar"
end
it "should set its type to 'Class' and its title to the passed title if the passed type is :component and the title has no square brackets in it" do
- ref = Puppet::ResourceReference.new(:component, "foo")
+ ref = Puppet::Resource::Reference.new(:component, "foo")
ref.type.should == "Class"
ref.title.should == "foo"
end
it "should interpret the title as a reference and assign appropriately if the type is :component and the title contains square brackets" do
- ref = Puppet::ResourceReference.new(:component, "foo::bar[yay]")
+ ref = Puppet::Resource::Reference.new(:component, "foo::bar[yay]")
ref.type.should == "Foo::Bar"
ref.title.should == "yay"
end
it "should set the type to 'Class' if it is nil and the title contains no square brackets" do
- ref = Puppet::ResourceReference.new(nil, "yay")
+ ref = Puppet::Resource::Reference.new(nil, "yay")
ref.type.should == "Class"
ref.title.should == "yay"
end
it "should interpret the title as a reference and assign appropriately if the type is nil and the title contains square brackets" do
- ref = Puppet::ResourceReference.new(nil, "foo::bar[yay]")
+ ref = Puppet::Resource::Reference.new(nil, "foo::bar[yay]")
ref.type.should == "Foo::Bar"
ref.title.should == "yay"
end
it "should interpret the title as a reference and assign appropriately if the type is nil and the title contains nested square brackets" do
- ref = Puppet::ResourceReference.new(nil, "foo::bar[baz[yay]]")
+ ref = Puppet::Resource::Reference.new(nil, "foo::bar[baz[yay]]")
ref.type.should == "Foo::Bar"
ref.title.should =="baz[yay]"
end
it "should be considered builtin if an existing resource type matches the type" do
- Puppet::ResourceReference.new("file", "/f").should be_builtin_type
+ Puppet::Resource::Reference.new("file", "/f").should be_builtin_type
end
it "should be not considered builtin if an existing resource type does not match the type" do
- Puppet::ResourceReference.new("foobar", "/f").should_not be_builtin_type
+ Puppet::Resource::Reference.new("foobar", "/f").should_not be_builtin_type
end
it "should be able to produce a backward-compatible reference array" do
- Puppet::ResourceReference.new("foobar", "/f").to_trans_ref.should == %w{Foobar /f}
+ Puppet::Resource::Reference.new("foobar", "/f").to_trans_ref.should == %w{Foobar /f}
end
it "should downcase resource types when producing a backward-compatible reference array for builtin resource types" do
- Puppet::ResourceReference.new("file", "/f").to_trans_ref.should == %w{file /f}
+ Puppet::Resource::Reference.new("file", "/f").to_trans_ref.should == %w{file /f}
end
end
-describe Puppet::ResourceReference, "when resolving resources with a catalog" do
+describe Puppet::Resource::Reference, "when resolving resources with a catalog" do
it "should resolve all resources using the catalog" do
config = mock 'catalog'
- ref = Puppet::ResourceReference.new("foo::bar", "yay")
+ ref = Puppet::Resource::Reference.new("foo::bar", "yay")
ref.catalog = config
config.expects(:resource).with("Foo::Bar[yay]").returns(:myresource)