There's a limitation in Ruby 1.8.x that makes constants behave differently than developers seem to expect: Constants defined inside a do/end block do not get inserted into the namespace of 'self', they instead go into the toplevel (Object) namespace. These providers exhibit bugs since they use constants with the same name in the same namespace. Other providers and other dynamically generated classes using constants without an explicit namespace should be considered to have a code smell.
Signed-off-by: Jesse Wolfe <[email protected]> --- lib/puppet/provider/package/dpkg.rb | 8 ++++---- lib/puppet/provider/package/pkg.rb | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/puppet/provider/package/dpkg.rb b/lib/puppet/provider/package/dpkg.rb index d6ec56a..06050ce 100755 --- a/lib/puppet/provider/package/dpkg.rb +++ b/lib/puppet/provider/package/dpkg.rb @@ -32,14 +32,14 @@ Puppet::Type.type(:package).provide :dpkg, :parent => Puppet::Provider::Package return packages end - REGEX = %r{^(\S+) +(\S+) +(\S+) (\S+) (\S*)$} - FIELDS = [:desired, :error, :status, :name, :ensure] + self::REGEX = %r{^(\S+) +(\S+) +(\S+) (\S+) (\S*)$} + self::FIELDS = [:desired, :error, :status, :name, :ensure] def self.parse_line(line) - if match = REGEX.match(line) + if match = self::REGEX.match(line) hash = {} - FIELDS.zip(match.captures) { |field,value| + self::FIELDS.zip(match.captures) { |field,value| hash[field] = value } diff --git a/lib/puppet/provider/package/pkg.rb b/lib/puppet/provider/package/pkg.rb index 978042d..148ef0d 100644 --- a/lib/puppet/provider/package/pkg.rb +++ b/lib/puppet/provider/package/pkg.rb @@ -27,14 +27,14 @@ Puppet::Type.type(:package).provide :pkg, :parent => Puppet::Provider::Package d packages end - REGEX = %r{^(\S+)\s+(\S+)\s+(\S+)\s+} - FIELDS = [:name, :version, :status] + self::REGEX = %r{^(\S+)\s+(\S+)\s+(\S+)\s+} + self::FIELDS = [:name, :version, :status] def self.parse_line(line) hash = {} - if match = REGEX.match(line) + if match = self::REGEX.match(line) - FIELDS.zip(match.captures) { |field,value| + self::FIELDS.zip(match.captures) { |field,value| hash[field] = value } -- 1.6.3.3 -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
