Reviewed-by: Jesse Wolfe <je...@puppetlabs.com>
Signed-off-by: Matt Robinson <ma...@puppetlabs.com>
---
Local-branch: ticket/next/6830-ready_to_merge
lib/puppet/transaction/event.rb | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/puppet/transaction/event.rb b/lib/puppet/transaction/event.rb
index cd695cf..d3f25b7 100644
--- a/lib/puppet/transaction/event.rb
+++ b/lib/puppet/transaction/event.rb
@@ -48,7 +48,7 @@ class Puppet::Transaction::Event
end
def to_yaml_properties
- (YAML_ATTRIBUTES & instance_variables).sort
+ (YAML_ATTRIBUTES.map {|ya| ya.to_s} & instance_variables.map{|iv| iv.to_s}).sort
end
private
--
1.7.3.1
class Bar < Foo
end
a = Class.new(Bar) do
def self.to_s
"some other class"
end
end
In Ruby 1.9 this prints
Bar inherited from Foo
#<Class:0x0000010086c198> inherited from Bar
In Ruby 1.8 the to_s override used to be in effect so printed:
Bar inherited from Foo
some other class inherited from Bar
Reviewed-by: Jesse Wolfe <je...@puppetlabs.com>
Signed-off-by: Matt Robinson <ma...@puppetlabs.com>
---
Local-branch: ticket/next/6830-ready_to_merge
spec/unit/indirector/active_record_spec.rb | 7 +++----
spec/unit/indirector/code_spec.rb | 9 ++++-----
spec/unit/indirector/direct_file_server_spec.rb | 9 ++++-----
spec/unit/indirector/exec_spec.rb | 12 ++++++------
spec/unit/indirector/file_server_spec.rb | 11 ++++++-----
spec/unit/indirector/file_spec.rb | 9 ++++-----
spec/unit/indirector/ldap_spec.rb | 7 +++----
spec/unit/indirector/memory_spec.rb | 7 +++----
spec/unit/indirector/plain_spec.rb | 7 +++----
spec/unit/indirector/queue_spec.rb | 7 +++----
spec/unit/indirector/rest_spec.rb | 20 ++++++++++++++------
spec/unit/indirector/ssl_file_spec.rb | 13 +++++++------
spec/unit/indirector/yaml_spec.rb | 13 +++++++------
13 files changed, 67 insertions(+), 64 deletions(-)
diff --git a/spec/unit/indirector/active_record_spec.rb b/spec/unit/indirector/active_record_spec.rb
index 4765cc5..4fab17d 100755
--- a/spec/unit/indirector/active_record_spec.rb
+++ b/spec/unit/indirector/active_record_spec.rb
@@ -14,10 +14,9 @@ describe Puppet::Indirector::ActiveRecord do
@indirection = stub 'indirection', :name => :mystuff, :register_terminus_type => nil, :model => @model
Puppet::Indirector::Indirection.stubs(:instance).returns(@indirection)
- @active_record_class = Class.new(Puppet::Indirector::ActiveRecord) do
- def self.to_s
- "Mystuff::Testing"
- end
+ module Testing; end
+ @active_record_class = class Testing::MyActiveRecord < Puppet::Indirector::ActiveRecord
+ self
end
@ar_model = mock 'ar_model'
diff --git a/spec/unit/indirector/code_spec.rb b/spec/unit/indirector/code_spec.rb
index 452d009..1c9e4d2 100755
--- a/spec/unit/indirector/code_spec.rb
+++ b/spec/unit/indirector/code_spec.rb
@@ -4,16 +4,15 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'puppet/indirector/code'
describe Puppet::Indirector::Code do
- before do
+ before :all do
Puppet::Indirector::Terminus.stubs(:register_terminus_class)
@model = mock 'model'
@indirection = stub 'indirection', :name => :mystuff, :register_terminus_type => nil, :model => @model
Puppet::Indirector::Indirection.stubs(:instance).returns(@indirection)
- @code_class = Class.new(Puppet::Indirector::Code) do
- def self.to_s
- "Mystuff::Testing"
- end
+ module Testing; end
+ @code_class = class Testing::MyCode < Puppet::Indirector::Code
+ self
end
@searcher = @code_class.new
diff --git a/spec/unit/indirector/direct_file_server_spec.rb b/spec/unit/indirector/direct_file_server_spec.rb
index 8eab4ad..5d9af62 100755
--- a/spec/unit/indirector/direct_file_server_spec.rb
+++ b/spec/unit/indirector/direct_file_server_spec.rb
@@ -8,16 +8,15 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'puppet/indirector/direct_file_server'
describe Puppet::Indirector::DirectFileServer do
- before :each do
+ before :all do
Puppet::Indirector::Terminus.stubs(:register_terminus_class)
@model = mock 'model'
@indirection = stub 'indirection', :name => :mystuff, :register_terminus_type => nil, :model => @model
Puppet::Indirector::Indirection.stubs(:instance).returns(@indirection)
- @direct_file_class = Class.new(Puppet::Indirector::DirectFileServer) do
- def self.to_s
- "Testing::Mytype"
- end
+ module Testing; end
+ @direct_file_class = class Testing::Mytype < Puppet::Indirector::DirectFileServer
+ self
end
@server = @direct_file_class.new
diff --git a/spec/unit/indirector/exec_spec.rb b/spec/unit/indirector/exec_spec.rb
index d4fb224..5abb00a 100755
--- a/spec/unit/indirector/exec_spec.rb
+++ b/spec/unit/indirector/exec_spec.rb
@@ -5,17 +5,17 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'puppet/indirector/exec'
describe Puppet::Indirector::Exec do
- before do
+ before :all do
@indirection = stub 'indirection', :name => :testing
Puppet::Indirector::Indirection.expects(:instance).with(:testing).returns(@indirection)
- @exec_class = Class.new(Puppet::Indirector::Exec) do
- def self.to_s
- "Testing::Mytype"
- end
-
+ module Testing; end
+ @exec_class = class Testing::MyTesting < Puppet::Indirector::Exec
attr_accessor :command
+ self
end
+ end
+ before :each do
@searcher = @exec_class.new
@searcher.command = ["/echo"]
diff --git a/spec/unit/indirector/file_server_spec.rb b/spec/unit/indirector/file_server_spec.rb
index a81d504..079eba0 100755
--- a/spec/unit/indirector/file_server_spec.rb
+++ b/spec/unit/indirector/file_server_spec.rb
@@ -10,18 +10,19 @@ require 'puppet/file_serving/configuration'
describe Puppet::Indirector::FileServer do
- before :each do
+ before :all do
Puppet::Indirector::Terminus.stubs(:register_terminus_class)
@model = mock 'model'
@indirection = stub 'indirection', :name => :mystuff, :register_terminus_type => nil, :model => @model
Puppet::Indirector::Indirection.stubs(:instance).returns(@indirection)
- @file_server_class = Class.new(Puppet::Indirector::FileServer) do
- def self.to_s
- "Testing::Mytype"
- end
+ module Testing; end
+ @file_server_class = class Testing::MyFileServer < Puppet::Indirector::FileServer
+ self
end
+ end
+ before :each do
@file_server = @file_server_class.new
@uri = "puppet://host/my/local/file"
diff --git a/spec/unit/indirector/file_spec.rb b/spec/unit/indirector/file_spec.rb
index 8fd197e..96d5b2a 100755
--- a/spec/unit/indirector/file_spec.rb
+++ b/spec/unit/indirector/file_spec.rb
@@ -5,16 +5,15 @@ require 'puppet/indirector/file'
describe Puppet::Indirector::File do
- before :each do
+ before :all do
Puppet::Indirector::Terminus.stubs(:register_terminus_class)
@model = mock 'model'
@indirection = stub 'indirection', :name => :mystuff, :register_terminus_type => nil, :model => @model
Puppet::Indirector::Indirection.stubs(:instance).returns(@indirection)
- @file_class = Class.new(Puppet::Indirector::File) do
- def self.to_s
- "Testing::Mytype"
- end
+ module Testing; end
+ @file_class = class Testing::MyFile < Puppet::Indirector::File
+ self
end
@searcher = @file_class.new
diff --git a/spec/unit/indirector/ldap_spec.rb b/spec/unit/indirector/ldap_spec.rb
index 2178a87..ab5dab9 100755
--- a/spec/unit/indirector/ldap_spec.rb
+++ b/spec/unit/indirector/ldap_spec.rb
@@ -8,10 +8,9 @@ describe Puppet::Indirector::Ldap do
before do
@indirection = stub 'indirection', :name => :testing
Puppet::Indirector::Indirection.stubs(:instance).returns(@indirection)
- @ldap_class = Class.new(Puppet::Indirector::Ldap) do
- def self.to_s
- "Testing::Mytype"
- end
+ module Testing; end
+ @ldap_class = class Testing::MyLdap < Puppet::Indirector::Ldap
+ self
end
@connection = mock 'ldap'
diff --git a/spec/unit/indirector/memory_spec.rb b/spec/unit/indirector/memory_spec.rb
index f901032..751adb1 100755
--- a/spec/unit/indirector/memory_spec.rb
+++ b/spec/unit/indirector/memory_spec.rb
@@ -14,10 +14,9 @@ describe Puppet::Indirector::Memory do
@indirection = stub 'indirection', :name => :mystuff, :register_terminus_type => nil, :model => @model
Puppet::Indirector::Indirection.stubs(:instance).returns(@indirection)
- @memory_class = Class.new(Puppet::Indirector::Memory) do
- def self.to_s
- "Mystuff::Testing"
- end
+ module Testing; end
+ @memory_class = class Testing::MyMemory < Puppet::Indirector::Memory
+ self
end
@searcher = @memory_class.new
diff --git a/spec/unit/indirector/plain_spec.rb b/spec/unit/indirector/plain_spec.rb
index 54c0233..dfaa701 100755
--- a/spec/unit/indirector/plain_spec.rb
+++ b/spec/unit/indirector/plain_spec.rb
@@ -10,10 +10,9 @@ describe Puppet::Indirector::Plain do
@indirection = stub 'indirection', :name => :mystuff, :register_terminus_type => nil, :model => @model
Puppet::Indirector::Indirection.stubs(:instance).returns(@indirection)
- @plain_class = Class.new(Puppet::Indirector::Plain) do
- def self.to_s
- "Mystuff::Testing"
- end
+ module Testing; end
+ @plain_class = class Testing::MyPlain < Puppet::Indirector::Plain
+ self
end
@searcher = @plain_class.new
diff --git a/spec/unit/indirector/queue_spec.rb b/spec/unit/indirector/queue_spec.rb
index 49e5e10..6f5b44b 100755
--- a/spec/unit/indirector/queue_spec.rb
+++ b/spec/unit/indirector/queue_spec.rb
@@ -31,10 +31,9 @@ describe Puppet::Indirector::Queue, :if => Puppet.features.pson? do
@model = mock 'model'
@indirection = stub 'indirection', :name => :my_queue, :register_terminus_type => nil, :model => @model
Puppet::Indirector::Indirection.stubs(:instance).with(:my_queue).returns(@indirection)
- @store_class = Class.new(Puppet::Indirector::Queue) do
- def self.to_s
- 'MyQueue::MyType'
- end
+ module MyQueue; end
+ @store_class = class MyQueue::MyType < Puppet::Indirector::Queue
+ self
end
@store = @store_class.new
diff --git a/spec/unit/indirector/rest_spec.rb b/spec/unit/indirector/rest_spec.rb
index 547e68d..326d85f 100755
--- a/spec/unit/indirector/rest_spec.rb
+++ b/spec/unit/indirector/rest_spec.rb
@@ -26,19 +26,27 @@ shared_examples_for "a REST http call" do
end
describe Puppet::Indirector::REST do
- before do
+ before :all do
Puppet::Indirector::Terminus.stubs(:register_terminus_class)
@model = stub('model', :supported_formats => %w{}, :convert_from => nil)
@instance = stub('model instance', :name= => nil)
@indirection = stub('indirection', :name => :mystuff, :register_terminus_type => nil, :model => @model)
- Puppet::Indirector::Indirection.stubs(:instance).returns(@indirection)
+ Puppet::Indirector::Indirection.expects(:instance).returns(@indirection)
- @rest_class = Class.new(Puppet::Indirector::REST) do
- def self.to_s
- "This::Is::A::Test::Class"
+ module This
+ module Is
+ module A
+ module Test
+ end
+ end
end
end
+ @rest_class = class This::Is::A::Test::Class < Puppet::Indirector::REST
+ self
+ end
+ end
+ before :each do
@response = stub('mock response', :body => 'result', :code => "200")
@response.stubs(:[]).with('content-type').returns "text/plain"
@response.stubs(:[]).with('content-encoding').returns nil
diff --git a/spec/unit/indirector/ssl_file_spec.rb b/spec/unit/indirector/ssl_file_spec.rb
index 4549127..ca97cf4 100755
--- a/spec/unit/indirector/ssl_file_spec.rb
+++ b/spec/unit/indirector/ssl_file_spec.rb
@@ -8,15 +8,16 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'puppet/indirector/ssl_file'
describe Puppet::Indirector::SslFile do
- before do
- @model = mock 'model'
+ before :all do
@indirection = stub 'indirection', :name => :testing, :model => @model
Puppet::Indirector::Indirection.expects(:instance).with(:testing).returns(@indirection)
- @file_class = Class.new(Puppet::Indirector::SslFile) do
- def self.to_s
- "Testing::Mytype"
- end
+ module Testing; end
+ @file_class = class Testing::MyType < Puppet::Indirector::SslFile
+ self
end
+ end
+ before :each do
+ @model = mock 'model'
@setting = :certdir
@file_class.store_in @setting
diff --git a/spec/unit/indirector/yaml_spec.rb b/spec/unit/indirector/yaml_spec.rb
index 3501799..188e300 100755
--- a/spec/unit/indirector/yaml_spec.rb
+++ b/spec/unit/indirector/yaml_spec.rb
@@ -5,14 +5,15 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'puppet/indirector/yaml'
describe Puppet::Indirector::Yaml, " when choosing file location" do
- before :each do
+ before :all do
@indirection = stub 'indirection', :name => :my_yaml, :register_terminus_type => nil
- Puppet::Indirector::Indirection.stubs(:instance).with(:my_yaml).returns(@indirection)
- @store_class = Class.new(Puppet::Indirector::Yaml) do
- def self.to_s
- "MyYaml::MyType"
- end
+ Puppet::Indirector::Indirection.expects(:instance).with(:my_yaml).returns(@indirection)
+ module MyYaml; end
+ @store_class = class MyYaml::MyType < Puppet::Indirector::Yaml
+ self
end
+ end
+ before :each do
@store = @store_class.new
@subject = Object.new
--
1.7.3.1
undefined method `collect' for "dev2 dev1":String
Reviewed-by: Jesse Wolfe <je...@puppetlabs.com>
Signed-off-by: Matt Robinson <ma...@puppetlabs.com>
---
Local-branch: ticket/next/6830-ready_to_merge
lib/puppet/type/zpool.rb | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/lib/puppet/type/zpool.rb b/lib/puppet/type/zpool.rb
index 40ee8f2..2da713c 100755
--- a/lib/puppet/type/zpool.rb
+++ b/lib/puppet/type/zpool.rb
@@ -4,6 +4,7 @@ module Puppet
class VDev < Property
def flatten_and_sort(array)
+ array = [array] unless array.is_a? Array
array.collect { |a| a.split(' ') }.flatten.sort
end
--
1.7.3.1
Remaining big issues are dealing with RDoc (RDoc moved everything around in Ruby 1.9 and seems to have removed the HTML Generator), and dealing with catalog GET requests being too large (#6117).
undefined method `dirname' for Puppet::Type::File:Class
Reviewed-by: Jesse Wolfe <je...@puppetlabs.com>
Signed-off-by: Matt Robinson <ma...@puppetlabs.com>
---
Local-branch: ticket/next/6830-ready_to_merge
lib/puppet/type/tidy.rb | 6 +++---
lib/puppet/type/zone.rb | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/puppet/type/tidy.rb b/lib/puppet/type/tidy.rb
index 93a7e96..146481f 100755
--- a/lib/puppet/type/tidy.rb
+++ b/lib/puppet/type/tidy.rb
@@ -254,7 +254,7 @@ Puppet::Type.newtype(:tidy) do
if parameter
files = Puppet::FileServing::Fileset.new(self[:path], parameter).files.collect do |f|
- f == "." ? self[:path] : File.join(self[:path], f)
+ f == "." ? self[:path] : ::File.join(self[:path], f)
end
else
files = [self[:path]]
@@ -270,7 +270,7 @@ Puppet::Type.newtype(:tidy) do
files_by_name = result.inject({}) { |hash, file| hash[file[:path]] = file; hash }
files_by_name.keys.sort { |a,b| b <=> b }.each do |path|
- dir = File.dirname(path)
+ dir = ::File.dirname(path)
next unless resource = files_by_name[dir]
if resource[:require]
resource[:require] << Puppet::Resource.new(:file, path)
@@ -321,7 +321,7 @@ Puppet::Type.newtype(:tidy) do
def stat(path)
begin
- File.lstat(path)
+ ::File.lstat(path)
rescue Errno::ENOENT => error
info "File does not exist"
return nil
diff --git a/lib/puppet/type/zone.rb b/lib/puppet/type/zone.rb
index 1bae931..0fc702c 100644
--- a/lib/puppet/type/zone.rb
+++ b/lib/puppet/type/zone.rb
@@ -409,7 +409,7 @@ Puppet::Type.newtype(:zone) do
# both as prerequisites.
autorequire(:file) do
if @parameters.include? :path
- [@parameters[:path].value, File.dirname(@parameters[:path].value)]
+ [@parameters[:path].value, ::File.dirname(@parameters[:path].value)]
else
nil
end
--
1.7.3.1
p Foo.new.instance_variables
In Ruby 1.8 this prints
["@a", "@b"]
In Ruby 1.9 this prints
[:@a, :@b]
Reviewed-by: Jesse Wolfe <je...@puppetlabs.com>
Signed-off-by: Matt Robinson <ma...@puppetlabs.com>
---
Local-branch: ticket/next/6830-ready_to_merge
lib/puppet/simple_graph.rb | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/lib/puppet/simple_graph.rb b/lib/puppet/simple_graph.rb
index ed71a64..27e068e 100644
--- a/lib/puppet/simple_graph.rb
+++ b/lib/puppet/simple_graph.rb
@@ -570,7 +570,10 @@ class Puppet::SimpleGraph
end
def to_yaml_properties
- other_vars = instance_variables.reject { |v| %w{@in_to @out_from @upstream_from @downstream_from}.include?(v) }
+ other_vars = instance_variables.
+ map {|v| v.to_s}.
+ reject { |v| %w{@in_to @out_from @upstream_from @downstream_from}.include?(v) }
+
(other_vars + %w{@vertices @edges}).sort.uniq
end
--
1.7.3.1
unexpected invocation: #<Mock:option1>.to_a()
Could have stubbed to_a also, but less stubbing is better in these cases
Reviewed-by: Jesse Wolfe <je...@puppetlabs.com>
Signed-off-by: Matt Robinson <ma...@puppetlabs.com>
---
Local-branch: ticket/next/6830-ready_to_merge
spec/unit/parser/ast/casestatement_spec.rb | 26 +++++++++++++++-----------
1 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/spec/unit/parser/ast/casestatement_spec.rb b/spec/unit/parser/ast/casestatement_spec.rb
index a77c04c..bce3ad8 100755
--- a/spec/unit/parser/ast/casestatement_spec.rb
+++ b/spec/unit/parser/ast/casestatement_spec.rb
@@ -13,11 +13,14 @@ describe Puppet::Parser::AST::CaseStatement do
@test = stub 'test'
@test.stubs(:safeevaluate).with(@scope).returns("value")
- @option1 = stub 'option1', :eachopt => nil, :default? => false
- @option2 = stub 'option2', :eachopt => nil, :default? => false
+ @option1 = Puppet::Parser::AST::CaseOpt.new({})
+ @option1.stubs(:eachopt)
+ @option1.stubs(:default?).returns false
+ @option2 = Puppet::Parser::AST::CaseOpt.new({})
+ @option2.stubs(:eachopt)
+ @option2.stubs(:default?).returns false
- @options = stub 'options'
- @options.stubs(:each).multiple_yields(@option1, @option2)
+ @options = Puppet::Parser::AST::ASTArray.new(:children => [@option1, @option2])
@casestmt = Puppet::Parser::AST::CaseStatement.new :test => @test, :options => @options
end
@@ -29,8 +32,6 @@ describe Puppet::Parser::AST::CaseStatement do
end
it "should scan each option" do
- @options.expects(:each).multiple_yields(@option1, @option2)
-
@casestmt.evaluate(@scope)
end
@@ -137,12 +138,15 @@ describe Puppet::Parser::AST::CaseStatement do
options = tests.collect do |result, values|
values = values.collect { |v| AST::Leaf.new :value => v }
- AST::CaseOpt.new(
- :value => AST::ASTArray.new(:children => values),
-
- :statements => AST::Leaf.new(:value => result))
+ AST::CaseOpt.new(
+ :value => AST::ASTArray.new(:children => values),
+ :statements => AST::Leaf.new(:value => result)
+ )
end
- options << AST::CaseOpt.new(:value => AST::Default.new(:value => "default"), :statements => AST::Leaf.new(:value => "default"))
+ options << AST::CaseOpt.new(
+ :value => AST::Default.new(:value => "default"),
+ :statements => AST::Leaf.new(:value => "default")
+ )
ast = nil
param = AST::Variable.new(:value => "testparam")
--
1.7.3.1
undefined method `to_i' for :now:Symbol
Reviewed-by: Jesse Wolfe <je...@puppetlabs.com>
Signed-off-by: Matt Robinson <ma...@puppetlabs.com>
---
Local-branch: ticket/next/6830-ready_to_merge
spec/unit/network/authconfig_spec.rb | 2 +-
spec/unit/network/rest_authconfig_spec.rb | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/spec/unit/network/authconfig_spec.rb b/spec/unit/network/authconfig_spec.rb
index 4367e25..9d69e99 100755
--- a/spec/unit/network/authconfig_spec.rb
+++ b/spec/unit/network/authconfig_spec.rb
@@ -12,7 +12,7 @@ describe Puppet::Network::AuthConfig do
FileTest.stubs(:exists?).returns(true)
File.stubs(:stat).returns(stub('stat', :ctime => :now))
- Time.stubs(:now).returns :now
+ Time.stubs(:now).returns Time.now
@authconfig = Puppet::Network::AuthConfig.new("dummy", false)
end
diff --git a/spec/unit/network/rest_authconfig_spec.rb b/spec/unit/network/rest_authconfig_spec.rb
index 270d1d0..e0bcb5a 100755
--- a/spec/unit/network/rest_authconfig_spec.rb
+++ b/spec/unit/network/rest_authconfig_spec.rb
@@ -22,7 +22,7 @@ describe Puppet::Network::RestAuthConfig do
before :each do
FileTest.stubs(:exists?).returns(true)
File.stubs(:stat).returns(stub('stat', :ctime => :now))
- Time.stubs(:now).returns :now
+ Time.stubs(:now).returns Time.now
@authconfig = Puppet::Network::RestAuthConfig.new("dummy", false)
@authconfig.stubs(:read)
--
1.7.3.1
ruby-1.9.2-p136 :001 > require 'md5'
LoadError: no such file to load -- md5
ruby-1.9.2-p136 :002 > require 'digest/md5'
=> true
ruby-1.9.2-p136 :003 > Digest::MD5.hexdigest('mystring')
=> "169319501261c644a58610f967e8f9d0"
ruby-1.9.2-p136 :004 > Digest::MD5.new('mystring')
=> #<Digest::MD5: d41d8cd98f00b204e9800998ecf8427e>
ruby-1.8.7-p330 :001 > require 'digest/md5'
=> []
ruby-1.8.7-p330 :002 > require 'md5'
=> ["MD5"]
ruby-1.8.7-p330 :003 > Digest::MD5.hexdigest('mystring')
=> "169319501261c644a58610f967e8f9d0"
ruby-1.8.7-p330 :004 > MD5.new('mystring')
=> #<MD5: 169319501261c644a58610f967e8f9d0>
ruby-1.8.7-p330 :005 > MD5.new('mystring').to_s
=> "169319501261c644a58610f967e8f9d0"
ruby-1.8.7-p330 :006 > Digest::MD5.new('mystring')
ArgumentError: wrong number of arguments (1 for 0)
Reviewed-by: Jesse Wolfe <je...@puppetlabs.com>
Signed-off-by: Matt Robinson <ma...@puppetlabs.com>
---
Local-branch: ticket/next/6830-ready_to_merge
lib/puppet/parser/functions/fqdn_rand.rb | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/puppet/parser/functions/fqdn_rand.rb b/lib/puppet/parser/functions/fqdn_rand.rb
index 52946f2..91157a1 100644
--- a/lib/puppet/parser/functions/fqdn_rand.rb
+++ b/lib/puppet/parser/functions/fqdn_rand.rb
@@ -5,8 +5,8 @@ Puppet::Parser::Functions::newfunction(:fqdn_rand, :type => :rvalue, :doc =>
$random_number = fqdn_rand(30)
$random_number_seed = fqdn_rand(30,30)") do |args|
- require 'md5'
+ require 'digest/md5'
max = args.shift
- srand MD5.new([lookupvar('fqdn'),args].join(':')).to_s.hex
+ srand(Digest::MD5.hexdigest([lookupvar('fqdn'),args].join(':')).hex)
rand(max).to_s
end
--
1.7.3.1