2
unless defined? JRUBY_VERSION
3
Process.maxgroups = 1024
7
def self.caller(skip=nil)
9
Kernel.caller.reject { |call|
10
in_gem_wrapper ||= call =~ /#{Regexp.escape $0}:\d+:in `load'/
17
require "puppet/util/zaml.rb"
25
self.to_s <=> other.to_s
29
[Object, Exception, Integer, Struct, Date, Time, Range, Regexp, Hash, Array, Float, String, FalseClass, TrueClass, Symbol, NilClass, Class].each { |cls|
31
def to_yaml(ignored=nil)
42
# Workaround for bug in MRI 1.8.7, see
43
# http://redmine.ruby-lang.org/issues/show/2708
46
if RUBY_VERSION == '1.8.7'
55
# ActiveSupport 2.3.x mixes in a dangerous method
56
# that can cause rspec to fork bomb
57
# and other strange things like that.
59
raise NotImplementedError, "Kernel.daemonize is too dangerous, please don't try to use it."
62
# The following code allows callers to make assertions that are only
63
# checked when the environment variable PUPPET_ENABLE_ASSERTIONS is
64
# set to a non-empty string. For example:
66
# assert_that { condition }
67
# assert_that(message) { condition }
68
if ENV["PUPPET_ENABLE_ASSERTIONS"].to_s != ''
69
def assert_that(message = nil)
71
raise Exception.new("Assertion failure: #{message}")
75
def assert_that(message = nil)
80
# Workaround for yaml_initialize, which isn't supported before Ruby
82
if RUBY_VERSION == '1.8.1' || RUBY_VERSION == '1.8.2'
83
YAML.add_ruby_type( /^object/ ) { |tag, val|
84
type, obj_class = YAML.read_type_class( tag, Object )
85
r = YAML.object_maker( obj_class, val )
86
if r.respond_to? :yaml_initialize
87
r.instance_eval { instance_variables.each { |name| remove_instance_variable name } }
88
r.yaml_initialize(tag, val)
95
# Ruby < 1.8.7 doesn't have this method but we use it in tests
97
return [] if num < 0 || num > size
98
return [[]] if num == 0
99
return map{|e| [e] } if num == 1
101
self[0, size - (num - 1)].inject([]) do |ret, e|
103
ret += tmp.combination(num - 1).map{|a| a.unshift(e) }
105
end unless method_defined? :combination
111
Proc.new { |*args| args.shift.__send__(self, *args) }
112
end unless method_defined? :to_proc