summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorMatt Robinson <matt@puppetlabs.com>2011-03-23 13:19:53 -0700
committerMatt Robinson <matt@puppetlabs.com>2011-03-23 13:19:53 -0700
commit36f4dc5e1527fc46f097080c12bb1ee5c3d46714 (patch)
tree1f1a5547aac5eb338f274a786f4d56db32aec7a2 /lib/puppet
parentad85b67ade99a3ec4ed4a8e578c9d288706b567d (diff)
parent36a5665f3e0aeb8b9141cb8be2f69f8568078986 (diff)
downloadpuppet-36f4dc5e1527fc46f097080c12bb1ee5c3d46714.tar.gz
puppet-36f4dc5e1527fc46f097080c12bb1ee5c3d46714.tar.xz
puppet-36f4dc5e1527fc46f097080c12bb1ee5c3d46714.zip
Merge branch 'ticket/next/6820_ruby19_fixes' into next
* ticket/next/6820_ruby19_fixes: (#6820) Fix File class lookup in the file type for Ruby 1.9 (#6820) Fix nagios parser to use proper hash syntax for Ruby 1.9 (#6820) Fix Invalid multibyte character (#6820) Fix RDOC parser to work with Ruby 1.9 (#6820) Fix invalid next that should be a return (#2782) Fix constant_defined?
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/external/nagios/parser.rb2
-rw-r--r--lib/puppet/provider/service/daemontools.rb2
-rw-r--r--lib/puppet/type/file.rb28
-rw-r--r--lib/puppet/util/classgen.rb14
-rw-r--r--lib/puppet/util/rdoc/parser.rb12
5 files changed, 38 insertions, 20 deletions
diff --git a/lib/puppet/external/nagios/parser.rb b/lib/puppet/external/nagios/parser.rb
index 5504f5818..17db5e307 100644
--- a/lib/puppet/external/nagios/parser.rb
+++ b/lib/puppet/external/nagios/parser.rb
@@ -753,7 +753,7 @@ module_eval <<'.,.,', 'grammar.ry', 40
module_eval <<'.,.,', 'grammar.ry', 42
def _reduce_10( val, _values, result )
-result = {val[0],val[1]}
+result = {val[0] => val[1]}
result
end
.,.,
diff --git a/lib/puppet/provider/service/daemontools.rb b/lib/puppet/provider/service/daemontools.rb
index bbb962a71..f5a073329 100644
--- a/lib/puppet/provider/service/daemontools.rb
+++ b/lib/puppet/provider/service/daemontools.rb
@@ -67,7 +67,7 @@ Puppet::Type.type(:service).provide :daemontools, :parent => :base do
path = self.defpath
unless FileTest.directory?(path)
Puppet.notice "Service path #{path} does not exist"
- next
+ return
end
# reject entries that aren't either a directory
diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb
index 16b1f962d..1a6d0c3ac 100644
--- a/lib/puppet/type/file.rb
+++ b/lib/puppet/type/file.rb
@@ -44,7 +44,7 @@ Puppet::Type.newtype(:file) do
# convert the current path in an index into the collection and the last
# path name. The aim is to use less storage for all common paths in a hierarchy
munge do |value|
- path, name = File.split(value.gsub(/\/+/,'/'))
+ path, name = ::File.split(value.gsub(/\/+/,'/'))
{ :index => Puppet::FileCollection.collection.index(path), :name => name }
end
@@ -55,7 +55,7 @@ Puppet::Type.newtype(:file) do
if value[:name] == '/'
basedir
else
- File.join( basedir, value[:name] )
+ ::File.join( basedir, value[:name] )
end
end
end
@@ -248,7 +248,7 @@ Puppet::Type.newtype(:file) do
# Autorequire any parent directories.
autorequire(:file) do
- basedir = File.dirname(self[:path])
+ basedir = ::File.dirname(self[:path])
if basedir != self[:path]
basedir
else
@@ -309,7 +309,7 @@ Puppet::Type.newtype(:file) do
def asuser
if self.should(:owner) and ! self.should(:owner).is_a?(Symbol)
writeable = Puppet::Util::SUIDManager.asuser(self.should(:owner)) {
- FileTest.writable?(File.dirname(self[:path]))
+ FileTest.writable?(::File.dirname(self[:path]))
}
# If the parent directory is writeable, then we execute
@@ -412,7 +412,7 @@ Puppet::Type.newtype(:file) do
# Create a new file or directory object as a child to the current
# object.
def newchild(path)
- full_path = File.join(self[:path], path)
+ full_path = ::File.join(self[:path], path)
# Add some new values to our original arguments -- these are the ones
# set at initialization. We specifically want to exclude any param
@@ -486,16 +486,16 @@ Puppet::Type.newtype(:file) do
# not likely to have many actual conflicts, which is good, because
# this is a pretty inefficient implementation.
def remove_less_specific_files(files)
- mypath = self[:path].split(File::Separator)
+ mypath = self[:path].split(::File::Separator)
other_paths = catalog.vertices.
select { |r| r.is_a?(self.class) and r[:path] != self[:path] }.
- collect { |r| r[:path].split(File::Separator) }.
+ collect { |r| r[:path].split(::File::Separator) }.
select { |p| p[0,mypath.length] == mypath }
return files if other_paths.empty?
files.reject { |file|
- path = file[:path].split(File::Separator)
+ path = file[:path].split(::File::Separator)
other_paths.any? { |p| path[0,p.length] == p }
}
end
@@ -612,7 +612,7 @@ Puppet::Type.newtype(:file) do
end
when "link", "file"
debug "Removing existing #{s.ftype} for replacement with #{should}"
- File.unlink(self[:path])
+ ::File.unlink(self[:path])
else
self.fail "Could not back up files of type #{s.ftype}"
end
@@ -677,7 +677,7 @@ Puppet::Type.newtype(:file) do
path = self[:path]
begin
- File.send(method, self[:path])
+ ::File.send(method, self[:path])
rescue Errno::ENOENT => error
return nil
rescue Errno::EACCES => error
@@ -703,7 +703,7 @@ Puppet::Type.newtype(:file) do
use_temporary_file = write_temporary_file?
if use_temporary_file
path = "#{self[:path]}.puppettmp_#{rand(10000)}"
- path = "#{self[:path]}.puppettmp_#{rand(10000)}" while File.exists?(path) or File.symlink?(path)
+ path = "#{self[:path]}.puppettmp_#{rand(10000)}" while ::File.exists?(path) or ::File.symlink?(path)
else
path = self[:path]
end
@@ -712,18 +712,18 @@ Puppet::Type.newtype(:file) do
umask = mode ? 000 : 022
mode_int = mode ? mode.to_i(8) : nil
- content_checksum = Puppet::Util.withumask(umask) { File.open(path, 'w', mode_int ) { |f| write_content(f) } }
+ content_checksum = Puppet::Util.withumask(umask) { ::File.open(path, 'w', mode_int ) { |f| write_content(f) } }
# And put our new file in place
if use_temporary_file # This is only not true when our file is empty.
begin
fail_if_checksum_is_wrong(path, content_checksum) if validate_checksum?
- File.rename(path, self[:path])
+ ::File.rename(path, self[:path])
rescue => detail
fail "Could not rename temporary file #{path} to #{self[:path]}: #{detail}"
ensure
# Make sure the created file gets removed
- File.unlink(path) if FileTest.exists?(path)
+ ::File.unlink(path) if FileTest.exists?(path)
end
end
diff --git a/lib/puppet/util/classgen.rb b/lib/puppet/util/classgen.rb
index ed69c5878..1e99aa873 100644
--- a/lib/puppet/util/classgen.rb
+++ b/lib/puppet/util/classgen.rb
@@ -124,11 +124,23 @@ module Puppet::Util::ClassGen
klass
end
+ # const_defined? in Ruby 1.9 behaves differently in terms
+ # of which class hierarchy it polls for nested namespaces
+ #
+ # See http://redmine.ruby-lang.org/issues/show/1915
+ def is_constant_defined?(const)
+ if ::RUBY_VERSION =~ /1.9/
+ const_defined?(const, false)
+ else
+ const_defined?(const)
+ end
+ end
+
# Handle the setting and/or removing of the associated constant.
def handleclassconst(klass, name, options)
const = genconst_string(name, options)
- if const_defined?(const)
+ if is_constant_defined?(const)
if options[:overwrite]
Puppet.info "Redefining #{name} in #{self}"
remove_const(const)
diff --git a/lib/puppet/util/rdoc/parser.rb b/lib/puppet/util/rdoc/parser.rb
index 0f746e2ea..762ce25f0 100644
--- a/lib/puppet/util/rdoc/parser.rb
+++ b/lib/puppet/util/rdoc/parser.rb
@@ -7,13 +7,19 @@
require "rdoc/code_objects"
require "puppet/util/rdoc/code_objects"
require "rdoc/tokenstream"
-require "rdoc/markup/simple_markup/preprocess"
-require "rdoc/parsers/parserfactory"
+
+if ::RUBY_VERSION =~ /1.9/
+ require "rdoc/markup/preprocess"
+ require "rdoc/parser"
+else
+ require "rdoc/markup/simple_markup/preprocess"
+ require "rdoc/parsers/parserfactory"
+end
module RDoc
class Parser
- extend ParserFactory
+ extend ParserFactory unless ::RUBY_VERSION =~ /1.9/
SITE = "__site__"