48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/path/implementation.rb', line 48
def Path.configure(config)
config = config[:+]
unless [:defined, :warning, :error, :string].include? config
raise ArgumentError, "Invalid configuration: #{config.inspect}"
end
if @plus_configured
raise "Path.configure(:+ => ...) has already been called: #{@plus_configured}"
end
remove_method :+ if method_defined? :+
case config
when :defined
alias :+ :/
when :warning
def +(other)
warn 'Warning: use of deprecated Path#+ as Path#/: ' <<
"#{inspect} + #{other.inspect}\n#{caller.first}"
self / other
end
when :error
when :string
def +(other)
warn 'Warning: use of deprecated Path#+ as String#+: ' <<
"#{inspect} + #{other.inspect}\n#{caller.first}" if $VERBOSE
Path.new(to_s + other.to_s)
end
end
@plus_configured = caller.first
end
|