Check for deprecated uses of top level (i.e. in Object) uses of Rake class
names. If someone tries to reference the constant name, display a warning
and return the proper object. Using the —classic-namespace command
line option will define these constants in Object and avoid this handler.
42: def const_missing(const_name)
43: case const_name
44: when :Task
45: Rake.application.const_warning(const_name)
46: Rake::Task
47: when :FileTask
48: Rake.application.const_warning(const_name)
49: Rake::FileTask
50: when :FileCreationTask
51: Rake.application.const_warning(const_name)
52: Rake::FileCreationTask
53: when :RakeApp
54: Rake.application.const_warning(const_name)
55: Rake::Application
56: else
57: rake_original_const_missing(const_name)
58: end
59: end
Check for an existing method in the current class before extending. IF the
method already exists, then a warning is printed and the extension is not
added. Otherwise the block is yielded and any definitions in the block will
take effect.
Usage:
class String
rake_extension("xyz") do
def xyz
...
end
end
end
26: def rake_extension(method)
27: if method_defined?(method)
28: $stderr.puts "WARNING: Possible conflict with Rake extension: #{self}##{method} already exists"
29: else
30: yield
31: end
32: end