Permalink
Browse files

partial implementation of system rakefiles

  • Loading branch information...
1 parent 4b4bce1 commit 2da66fd91be5feef7097bf403c5e5ff87500d104 @jimweirich committed Aug 30, 2008
Showing with 55 additions and 8 deletions.
  1. +38 −8 lib/rake.rb
  2. +3 −0 test/data/sys/sys1.rake
  3. +14 −0 test/test_application.rb
View
@@ -2213,9 +2213,6 @@ def handle_options
options.rakelib = ['rakelib']
- # opts = GetoptLong.new(*command_line_options)
- # opts.each { |opt, value| do_option(opt, value) }
-
parsed_argv = nil
opts = OptionParser.new do |opts|
opts.banner = "rake [-f rakefile] {options} targets..."
@@ -2277,17 +2274,50 @@ def find_rakefile_location
def raw_load_rakefile # :nodoc:
rakefile, location = find_rakefile_location
- @rakefile = rakefile
- Dir.chdir(location)
- puts "(in #{Dir.pwd})" unless options.silent
- $rakefile = @rakefile
- load File.expand_path(@rakefile) if @rakefile != ''
+ if (! options.ignore_system) && (options.load_system || rakefile.nil?)
+ puts "(in #{Dir.pwd})" unless options.silent
+ puts "NO SYSTEM HERE"
+ else
+ @rakefile = rakefile
+ Dir.chdir(location)
+ puts "(in #{Dir.pwd})" unless options.silent
+ $rakefile = @rakefile
+ load File.expand_path(@rakefile) if @rakefile && @rakefile != ''
+ end
options.rakelib.each do |rlib|
Dir["#{rlib}/*.rake"].each do |name| add_import name end
end
load_imports
end
+ # The directory path containing the system wide rakefiles.
+ def system_dir
+ if ENV['RAKE_SYSTEM']
+ ENV['RAKE_SYSTEM']
+ elsif windows?
+ win32_system_dir
+ else
+ standard_system_dir
+ end
+ end
+
+ # The standard directory containing system wide rake files.
+ def standard_system_dir #:nodoc:
+ File.join(File.expand_path('~'), '.rake')
+ end
+ private :standard_system_dir
+
+ # The standard directory containing system wide rake files on Win
+ # 32 systems.
+ def win32_system_dir #:nodoc:
+ unless File.exists?(win32home = File.join(ENV['APPDATA'], 'Rake'))
+ raise Win32HomeError, "# Unable to determine home path environment variable."
+ else
+ win32home
+ end
+ end
+ private :win32_system_dir
+
# Collect the list of tasks on the command line. If no tasks are
# given, return a list containing only the default task.
# Environmental assignments are processed at this time as well.
View
@@ -0,0 +1,3 @@
+task "sys1" do
+ puts "SYS1"
+end
View
@@ -153,6 +153,20 @@ def test_load_rakefile_not_found
end
end
+ def test_load_from_system_rakefile
+ in_environment('RAKE_SYSTEM' => 'test/data/sys') do
+ @app.options.rakelib = []
+ @app.instance_eval do
+ handle_options
+ options.silent = true
+ options.load_system = true
+ load_rakefile
+ end
+ assert_equal "test/data/sys", @app.system_dir
+ assert_nil @app.rakefile
+ end
+ end
+
def test_loading_imports
mock = flexmock("loader")
mock.should_receive(:load).with("x.dummy").once

0 comments on commit 2da66fd

Please sign in to comment.