jimweirich-rake 0.8.2 → 0.8.2.99

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGES CHANGED
@@ -1,6 +1,12 @@
1
1
 
2
2
  = Rake Changelog
3
3
 
4
+ == Version 0.8.3
5
+
6
+ * Enhanced the system directory detection in windows. We now check
7
+ HOMEDRIVE/HOMEPATH and USERPROFILE if APPDATA isn't found. (Patch
8
+ supplied by James Tucker).
9
+
4
10
  == Version 0.8.2
5
11
 
6
12
  * Fixed bug in package task so that it will include the subdir
data/README CHANGED
@@ -1,6 +1,6 @@
1
1
  = RAKE -- Ruby Make
2
2
 
3
- Supporting Rake version: 0.8.3
3
+ Supporting Rake version: 0.8.2
4
4
 
5
5
  This package contains Rake, a simple ruby build program with
6
6
  capabilities similar to make.
data/lib/rake.rb CHANGED
@@ -29,16 +29,17 @@
29
29
  # as a library via a require statement, but it can be distributed
30
30
  # independently as an application.
31
31
 
32
- RAKEVERSION = '0.8.2'
32
+ RAKEVERSION = '0.8.2.99'
33
33
 
34
34
  require 'rbconfig'
35
- require 'getoptlong'
36
35
  require 'fileutils'
37
36
  require 'singleton'
38
37
  require 'monitor'
39
38
  require 'optparse'
40
39
  require 'ostruct'
41
40
 
41
+ require 'rake/win32'
42
+
42
43
  ######################################################################
43
44
  # Rake extensions to Module.
44
45
  #
@@ -262,11 +263,6 @@ module Rake
262
263
  end
263
264
  end
264
265
 
265
- # Error indicating a problem in locating the home directory on a
266
- # Win32 system.
267
- class Win32HomeError < RuntimeError
268
- end
269
-
270
266
  # --------------------------------------------------------------------------
271
267
  # Rake module singleton methods.
272
268
  #
@@ -943,7 +939,8 @@ end
943
939
  # added to the FileUtils utility functions.
944
940
  #
945
941
  module FileUtils
946
- RUBY = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
942
+ RUBY = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']).
943
+ sub(/.*\s.*/m, '"\&"')
947
944
 
948
945
  OPT_TABLE['sh'] = %w(noop verbose)
949
946
  OPT_TABLE['ruby'] = %w(noop verbose)
@@ -989,23 +986,14 @@ module FileUtils
989
986
  end
990
987
 
991
988
  def rake_system(*cmd)
992
- if Rake.application.windows?
993
- rake_win32_system(*cmd)
989
+ if Rake::Win32.windows?
990
+ Rake::Win32.rake_system(*cmd)
994
991
  else
995
992
  system(*cmd)
996
993
  end
997
994
  end
998
995
  private :rake_system
999
996
 
1000
- def rake_win32_system(*cmd)
1001
- if cmd.size == 1
1002
- system("call #{cmd}")
1003
- else
1004
- system(*cmd)
1005
- end
1006
- end
1007
- private :rake_win32_system
1008
-
1009
997
  # Run a Ruby interpreter with the given arguments.
1010
998
  #
1011
999
  # Example:
@@ -1587,7 +1575,7 @@ module Rake
1587
1575
  class << self
1588
1576
 
1589
1577
  # Yield each file or directory component.
1590
- def each_dir_parent(dir)
1578
+ def each_dir_parent(dir) # :nodoc:
1591
1579
  old_length = nil
1592
1580
  while dir != '.' && dir.length != old_length
1593
1581
  yield(dir)
@@ -2145,7 +2133,7 @@ module Rake
2145
2133
  end
2146
2134
 
2147
2135
  def windows?
2148
- Config::CONFIG['host_os'] =~ /mswin/
2136
+ Win32.windows?
2149
2137
  end
2150
2138
 
2151
2139
  def truncate(string, width)
@@ -2346,7 +2334,7 @@ module Rake
2346
2334
  rakefile, location = find_rakefile_location
2347
2335
  if (! options.ignore_system) &&
2348
2336
  (options.load_system || rakefile.nil?) &&
2349
- directory?(system_dir)
2337
+ system_dir && File.directory?(system_dir)
2350
2338
  puts "(in #{Dir.pwd})" unless options.silent
2351
2339
  glob("#{system_dir}/*.rake") do |name|
2352
2340
  add_import name
@@ -2375,38 +2363,24 @@ module Rake
2375
2363
 
2376
2364
  # The directory path containing the system wide rakefiles.
2377
2365
  def system_dir
2378
- if ENV['RAKE_SYSTEM']
2379
- ENV['RAKE_SYSTEM']
2380
- elsif windows?
2381
- win32_system_dir
2382
- else
2383
- standard_system_dir
2384
- end
2366
+ @system_dir ||=
2367
+ begin
2368
+ if ENV['RAKE_SYSTEM']
2369
+ ENV['RAKE_SYSTEM']
2370
+ elsif Win32.windows?
2371
+ Win32.win32_system_dir
2372
+ else
2373
+ standard_system_dir
2374
+ end
2375
+ end
2385
2376
  end
2386
-
2377
+
2387
2378
  # The standard directory containing system wide rake files.
2388
2379
  def standard_system_dir #:nodoc:
2389
2380
  File.join(File.expand_path('~'), '.rake')
2390
2381
  end
2391
2382
  private :standard_system_dir
2392
2383
 
2393
- # The standard directory containing system wide rake files on Win
2394
- # 32 systems.
2395
- def win32_system_dir #:nodoc:
2396
- win32home = File.join(ENV['APPDATA'], 'Rake')
2397
- unless directory?(win32home)
2398
- raise Win32HomeError, "Unable to determine home path environment variable."
2399
- else
2400
- win32home
2401
- end
2402
- end
2403
- private :win32_system_dir
2404
-
2405
- def directory?(path)
2406
- File.directory?(path)
2407
- end
2408
- private :directory?
2409
-
2410
2384
  # Collect the list of tasks on the command line. If no tasks are
2411
2385
  # given, return a list containing only the default task.
2412
2386
  # Environmental assignments are processed at this time as well.
data/lib/rake/win32.rb ADDED
@@ -0,0 +1,54 @@
1
+ module Rake
2
+
3
+ # Win 32 interface methods for Rake. Windows specific functionality
4
+ # will be placed here to collect that knowledge in one spot.
5
+ module Win32
6
+
7
+ # Error indicating a problem in locating the home directory on a
8
+ # Win32 system.
9
+ class Win32HomeError < RuntimeError
10
+ end
11
+
12
+ class << self
13
+ # True if running on a windows system.
14
+ def windows?
15
+ Config::CONFIG['host_os'] =~ /mswin/
16
+ end
17
+
18
+ # Run a command line on windows.
19
+ def rake_system(*cmd)
20
+ if cmd.size == 1
21
+ system("call #{cmd}")
22
+ else
23
+ system(*cmd)
24
+ end
25
+ end
26
+
27
+ # The standard directory containing system wide rake files on
28
+ # Win 32 systems. Try the following environment variables (in
29
+ # order):
30
+ #
31
+ # * APPDATA
32
+ # * HOMEDRIVE + HOMEPATH
33
+ # * USERPROFILE
34
+ #
35
+ # If the above are not defined, the return nil.
36
+ def win32_system_dir #:nodoc:
37
+ win32_shared_path = ENV['APPDATA']
38
+ if win32_shared_path.nil? && ENV['HOMEDRIVE'] && ENV['HOMEPATH']
39
+ win32_shared_path = ENV['HOMEDRIVE'] + ENV['HOMEPATH']
40
+ end
41
+ win32_shared_path ||= ENV['USERPROFILE']
42
+ raise Win32HomeError, "Unable to determine home path environment variable." if
43
+ win32_shared_path.nil? or win32_shared_path.empty?
44
+ normalize(File.join(win32_shared_path, 'Rake'))
45
+ end
46
+
47
+ # Normalize a win32 path so that the slashes are all forward slashes.
48
+ def normalize(path)
49
+ path.gsub(/\\/, '/')
50
+ end
51
+
52
+ end
53
+ end
54
+ end
@@ -1,5 +1,10 @@
1
1
  # Common setup for all test files.
2
2
 
3
- require 'rubygems'
4
- gem 'flexmock'
3
+ begin
4
+ require 'rubygems'
5
+ gem 'flexmock'
6
+ rescue LoadError
7
+ # got no gems
8
+ end
9
+
5
10
  require 'flexmock/test_unit'
@@ -193,10 +193,10 @@ class TestApplication < Test::Unit::TestCase
193
193
  end
194
194
 
195
195
  def test_load_from_system_rakefile_on_windows
196
- flexmock(@app, :windows? => true,
197
- :standard_system_dir => "XX")
196
+ flexmock(Rake::Win32, :windows? => true)
197
+ flexmock(@app, :standard_system_dir => "XX")
198
198
  flexmock(@app).should_receive(:directory?).with("/AD/Rake").and_return(true)
199
- flexmock(@app).should_receive(:load).and_return { |fn| puts "LOADING #{fn}" }
199
+ flexmock(@app).should_receive(:load).and_return(nil)
200
200
  in_environment('RAKE_SYSTEM' => nil, 'APPDATA' => '/AD') do
201
201
  @app.options.rakelib = []
202
202
  @app.instance_eval do
@@ -209,26 +209,6 @@ class TestApplication < Test::Unit::TestCase
209
209
  end
210
210
  end
211
211
 
212
- def test_load_from_system_rakefile_on_windows_with_no_appdata
213
- flexmock(@app, :windows? => true,
214
- :standard_system_dir => "XX"
215
- )
216
- flexmock(File).should_receive(:exists?).with("/AD/Rake").and_return(false)
217
- out = capture_stderr do
218
- assert_raise(SystemExit) do
219
- in_environment('RAKE_SYSTEM' => nil, 'APPDATA' => "/AD") do
220
- @app.options.rakelib = []
221
- @app.instance_eval do
222
- handle_options
223
- options.silent = true
224
- options.load_system = true
225
- load_rakefile
226
- end
227
- end
228
- end
229
- end
230
- end
231
-
232
212
  def test_loading_imports
233
213
  mock = flexmock("loader")
234
214
  mock.should_receive(:load).with("x.dummy").once
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'test/unit'
4
+ require 'test/rake_test_setup'
5
+ require 'test/in_environment'
6
+
7
+ require 'rake'
8
+
9
+ class TestWin32 < Test::Unit::TestCase
10
+ include InEnvironment
11
+
12
+ Win32 = Rake::Win32
13
+
14
+ def test_win32_system_dir_uses_appdata_if_defined
15
+ in_environment('RAKE_SYSTEM' => nil, 'APPDATA' => '\\AD') do
16
+ assert_equal "/AD/Rake", Win32.win32_system_dir
17
+ end
18
+ end
19
+
20
+ def test_win32_system_dir_uses_homedrive_otherwise
21
+ in_environment(
22
+ 'RAKE_SYSTEM' => nil,
23
+ 'APPDATA' => nil,
24
+ 'HOMEDRIVE' => "C:",
25
+ "HOMEPATH" => "\\HP"
26
+ ) do
27
+ assert_equal "C:/HP/Rake", Win32.win32_system_dir
28
+ end
29
+ end
30
+
31
+ def test_win32_system_dir_uses_userprofile_otherwise
32
+ in_environment(
33
+ 'RAKE_SYSTEM' => nil,
34
+ 'APPDATA' => nil,
35
+ 'HOMEDRIVE' => nil,
36
+ "HOMEPATH" => nil,
37
+ "USERPROFILE" => '\\UP'
38
+ ) do
39
+ assert_equal "/UP/Rake", Win32.win32_system_dir
40
+ end
41
+ end
42
+
43
+ def test_win32_system_dir_nil_of_no_env_vars
44
+ in_environment(
45
+ 'RAKE_SYSTEM' => nil,
46
+ 'APPDATA' => nil,
47
+ 'HOMEDRIVE' => nil,
48
+ "HOMEPATH" => nil,
49
+ "USERPROFILE" => nil
50
+ ) do
51
+ assert_raise(Rake::Win32::Win32HomeError) do
52
+ Win32.win32_system_dir
53
+ end
54
+ end
55
+ end
56
+
57
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jimweirich-rake
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: 0.8.2.99
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Weirich
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-09-08 21:00:00 -07:00
12
+ date: 2008-09-20 21:00:00 -07:00
13
13
  default_executable: rake
14
14
  dependencies: []
15
15
 
@@ -46,6 +46,7 @@ files:
46
46
  - MIT-LICENSE
47
47
  - Rakefile
48
48
  - README
49
+ - TAGS
49
50
  - TODO
50
51
  - bin/rake
51
52
  - lib/rake/classic_namespace.rb
@@ -65,6 +66,7 @@ files:
65
66
  - lib/rake/runtest.rb
66
67
  - lib/rake/tasklib.rb
67
68
  - lib/rake/testtask.rb
69
+ - lib/rake/win32.rb
68
70
  - lib/rake.rb
69
71
  - test/capture_stdout.rb
70
72
  - test/check_expansion.rb
@@ -104,6 +106,7 @@ files:
104
106
  - test/test_tasks.rb
105
107
  - test/test_test_task.rb
106
108
  - test/test_top_level_functions.rb
109
+ - test/test_win32.rb
107
110
  - test/data/imports/deps.mf
108
111
  - test/data/sample.mf
109
112
  - test/data/chains/Rakefile