[Rake-devel] Environment changes in the beta

James M. Lawrence quixoticsycophant at gmail.com
Tue Mar 1 22:55:18 EST 2011


% cat mystuff.rb
module MyStuff
  CONST_B = 44
end

% cat Rakefile
require 'rake'
require './mystuff'

module MyStuff
  CONST_A = 33
end

p MyStuff::CONST_A
p MyStuff::CONST_B
# => uninitialized constant Rake::Environment::MyStuff::CONST_B

task :default

% rake --version
rake, version 0.9.0.beta.1

% rake
33
rake aborted!
uninitialized constant Rake::Environment::MyStuff::CONST_B

Writing ::MyStuff::CONST_B instead works, and conversely
::MyStuff::CONST_A is an error.

It seems that Rake::DSL already provides the necessary partitioning.
If I wanted to keep the global scope clean, I would do

module MyStuff
  extend Rake::DSL

  task :default do
    # ...
  end
end

Could an example like that in the README replace the need for
environment.rb?


More information about the Rake-devel mailing list