rake 0.7.3 → 0.8.7

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.
Files changed (66) hide show
  1. data/CHANGES +126 -1
  2. data/README +86 -132
  3. data/Rakefile +111 -64
  4. data/TODO +1 -0
  5. data/bin/rake +24 -0
  6. data/doc/command_line_usage.rdoc +102 -0
  7. data/doc/rakefile.rdoc +126 -3
  8. data/doc/release_notes/rake-0.7.3.rdoc +0 -0
  9. data/doc/release_notes/rake-0.8.0.rdoc +114 -0
  10. data/doc/release_notes/rake-0.8.2.rdoc +165 -0
  11. data/doc/release_notes/rake-0.8.3.rdoc +112 -0
  12. data/doc/release_notes/rake-0.8.4.rdoc +147 -0
  13. data/doc/release_notes/rake-0.8.5.rdoc +53 -0
  14. data/doc/release_notes/rake-0.8.6.rdoc +55 -0
  15. data/doc/release_notes/rake-0.8.7.rdoc +55 -0
  16. data/lib/rake/alt_system.rb +108 -0
  17. data/lib/rake/contrib/ftptools.rb +24 -10
  18. data/lib/rake/contrib/publisher.rb +1 -1
  19. data/lib/rake/contrib/sys.rb +5 -2
  20. data/lib/rake/gempackagetask.rb +2 -6
  21. data/lib/rake/loaders/makefile.rb +17 -15
  22. data/lib/rake/rdoctask.rb +83 -21
  23. data/lib/rake/ruby182_test_unit_fix.rb +0 -0
  24. data/lib/rake/tasklib.rb +8 -3
  25. data/lib/rake/testtask.rb +1 -1
  26. data/lib/rake/win32.rb +55 -0
  27. data/lib/rake.rb +861 -386
  28. data/test/check_expansion.rb +5 -0
  29. data/test/check_no_expansion.rb +5 -0
  30. data/test/data/file_creation_task/Rakefile +4 -1
  31. data/test/data/multidesc/Rakefile +3 -0
  32. data/test/data/sample.mf +6 -1
  33. data/test/data/statusreturn/Rakefile +8 -0
  34. data/test/filecreation.rb +0 -2
  35. data/test/functional.rb +3 -1
  36. data/test/in_environment.rb +30 -0
  37. data/test/rake_test_setup.rb +24 -0
  38. data/test/session_functional.rb +145 -24
  39. data/test/shellcommand.rb +0 -0
  40. data/test/test_application.rb +345 -95
  41. data/test/test_definitions.rb +4 -1
  42. data/test/test_earlytime.rb +2 -2
  43. data/test/test_extension.rb +63 -0
  44. data/test/test_file_task.rb +20 -16
  45. data/test/test_filelist.rb +59 -10
  46. data/test/test_fileutils.rb +59 -38
  47. data/test/test_ftp.rb +5 -1
  48. data/test/test_invocation_chain.rb +81 -0
  49. data/test/test_makefile_loader.rb +5 -2
  50. data/test/test_namespace.rb +37 -14
  51. data/test/test_package_task.rb +3 -15
  52. data/test/test_pathmap.rb +24 -2
  53. data/test/test_pseudo_status.rb +26 -0
  54. data/test/test_rake.rb +9 -2
  55. data/test/test_rdoc_task.rb +88 -0
  56. data/test/test_require.rb +3 -1
  57. data/test/test_rules.rb +56 -12
  58. data/test/test_task_arguments.rb +89 -0
  59. data/test/test_task_manager.rb +27 -2
  60. data/test/test_tasklib.rb +12 -0
  61. data/test/test_tasks.rb +248 -20
  62. data/test/test_test_task.rb +3 -2
  63. data/test/test_top_level_functions.rb +10 -3
  64. data/test/test_win32.rb +72 -0
  65. metadata +105 -69
  66. /data/test/contrib/{testsys.rb → test_sys.rb} +0 -0
@@ -0,0 +1,55 @@
1
+ = Rake 0.8.7 Released
2
+
3
+ Rake version 0.8.5 introduced greatly improved support for executing
4
+ commands on Windows. The "sh" command now has the same semantics on
5
+ Windows that it has on Unix based platforms.
6
+
7
+ Rake version 0.8.6 includes minor fixes the the RDoc generation.
8
+ Rake version 0.8.7 includes a minor fix for JRuby running on windows.
9
+
10
+ == Changes
11
+
12
+ === New Features / Enhancements in Version 0.8.5
13
+
14
+ * Improved implementation of the Rake system command for Windows.
15
+ (patch from James M. Lawrence/quix)
16
+
17
+ * Support for Ruby 1.9's improved system command. (patch from James
18
+ M. Lawrence/quix)
19
+
20
+ * Rake now includes the configured extension when invoking an
21
+ executable (Config::CONFIG['EXEEXT])
22
+
23
+ === Bug Fixes in Version 0.8.5
24
+
25
+ * Environment variable keys are now correctly cased (it matters in
26
+ some implementations).
27
+
28
+ == What is Rake
29
+
30
+ Rake is a build tool similar to the make program in many ways. But
31
+ instead of cryptic make recipes, Rake uses standard Ruby code to
32
+ declare tasks and dependencies. You have the full power of a modern
33
+ scripting language built right into your build tool.
34
+
35
+ == Availability
36
+
37
+ The easiest way to get and install rake is via RubyGems ...
38
+
39
+ gem install rake (you may need root/admin privileges)
40
+
41
+ Otherwise, you can get it from the more traditional places:
42
+
43
+ Home Page:: http://rake.rubyforge.org/
44
+ Download:: http://rubyforge.org/project/showfiles.php?group_id=50
45
+ GitHub:: git://github.com/jimweirich/rake.git
46
+
47
+ == Thanks
48
+
49
+ As usual, it was input from users that drove a alot of these changes. The
50
+ following people either contributed patches, made suggestions or made
51
+ otherwise helpful comments. Thanks to ...
52
+
53
+ * Charles Nutter
54
+
55
+ -- Jim Weirich
@@ -0,0 +1,108 @@
1
+ #
2
+ # Copyright (c) 2008 James M. Lawrence
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person
5
+ # obtaining a copy of this software and associated documentation files
6
+ # (the "Software"), to deal in the Software without restriction,
7
+ # including without limitation the rights to use, copy, modify, merge,
8
+ # publish, distribute, sublicense, and/or sell copies of the Software,
9
+ # and to permit persons to whom the Software is furnished to do so,
10
+ # subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19
+ # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20
+ # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ # SOFTWARE.
23
+ #
24
+
25
+ require 'rbconfig'
26
+
27
+ #
28
+ # Alternate implementations of system() and backticks `` on Windows
29
+ # for ruby-1.8 and earlier.
30
+ #
31
+ module Rake::AltSystem
32
+ WINDOWS = Config::CONFIG["host_os"] =~ %r!(msdos|mswin|djgpp|mingw)!
33
+
34
+ class << self
35
+ def define_module_function(name, &block)
36
+ define_method(name, &block)
37
+ module_function(name)
38
+ end
39
+ end
40
+
41
+ if WINDOWS and RUBY_VERSION < "1.9.0"
42
+ RUNNABLE_EXTS = %w[com exe bat cmd]
43
+ RUNNABLE_PATTERN = %r!\.(#{RUNNABLE_EXTS.join('|')})\Z!i
44
+
45
+ define_module_function :kernel_system, &Kernel.method(:system)
46
+ define_module_function :kernel_backticks, &Kernel.method(:'`')
47
+
48
+ module_function
49
+
50
+ def repair_command(cmd)
51
+ "call " + (
52
+ if cmd =~ %r!\A\s*\".*?\"!
53
+ # already quoted
54
+ cmd
55
+ elsif match = cmd.match(%r!\A\s*(\S+)!)
56
+ if match[1] =~ %r!/!
57
+ # avoid x/y.bat interpretation as x with option /y
58
+ %Q!"#{match[1]}"! + match.post_match
59
+ else
60
+ # a shell command will fail if quoted
61
+ cmd
62
+ end
63
+ else
64
+ # empty or whitespace
65
+ cmd
66
+ end
67
+ )
68
+ end
69
+
70
+ def find_runnable(file)
71
+ if file =~ RUNNABLE_PATTERN
72
+ file
73
+ else
74
+ RUNNABLE_EXTS.each { |ext|
75
+ if File.exist?(test = "#{file}.#{ext}")
76
+ return test
77
+ end
78
+ }
79
+ nil
80
+ end
81
+ end
82
+
83
+ def system(cmd, *args)
84
+ repaired = (
85
+ if args.empty?
86
+ [repair_command(cmd)]
87
+ elsif runnable = find_runnable(cmd)
88
+ [File.expand_path(runnable), *args]
89
+ else
90
+ # non-existent file
91
+ [cmd, *args]
92
+ end
93
+ )
94
+ kernel_system(*repaired)
95
+ end
96
+
97
+ def backticks(cmd)
98
+ kernel_backticks(repair_command(cmd))
99
+ end
100
+
101
+ define_module_function :'`', &method(:backticks)
102
+ else
103
+ # Non-Windows or ruby-1.9+: same as Kernel versions
104
+ define_module_function :system, &Kernel.method(:system)
105
+ define_module_function :backticks, &Kernel.method(:'`')
106
+ define_module_function :'`', &Kernel.method(:'`')
107
+ end
108
+ end
@@ -6,7 +6,6 @@
6
6
  # use.
7
7
 
8
8
  require 'date'
9
- require 'parsedate'
10
9
  require 'net/ftp'
11
10
 
12
11
  module Rake # :nodoc:
@@ -20,6 +19,10 @@ module Rake # :nodoc:
20
19
  @date_class ||= Date
21
20
  end
22
21
 
22
+ def self.time
23
+ @time_class ||= Time
24
+ end
25
+
23
26
  def initialize(path, entry)
24
27
  @path = path
25
28
  @mode, line, @owner, @group, size, d1, d2, d3, @name = entry.split(' ')
@@ -54,17 +57,28 @@ module Rake # :nodoc:
54
57
  end
55
58
 
56
59
  def determine_time(d1, d2, d3)
57
- elements = ParseDate.parsedate("#{d1} #{d2} #{d3}")
58
- if elements[0].nil?
59
- today = self.class.date.today
60
- if elements[1] > today.month
61
- elements[0] = today.year - 1
62
- else
63
- elements[0] = today.year
60
+ now = self.class.time.now
61
+ if /:/ =~ d3
62
+ h, m = d3.split(':')
63
+ result = Time.parse("#{d1} #{d2} #{now.year} #{d3}")
64
+ if result > now
65
+ result = Time.parse("#{d1} #{d2} #{now.year-1} #{d3}")
64
66
  end
67
+ else
68
+ result = Time.parse("#{d1} #{d2} #{d3}")
65
69
  end
66
- elements = elements.collect { |el| el.nil? ? 0 : el }
67
- Time.mktime(*elements[0,7])
70
+ result
71
+ # elements = ParseDate.parsedate("#{d1} #{d2} #{d3}")
72
+ # if elements[0].nil?
73
+ # today = self.class.date.today
74
+ # if elements[1] > today.month
75
+ # elements[0] = today.year - 1
76
+ # else
77
+ # elements[0] = today.year
78
+ # end
79
+ # end
80
+ # elements = elements.collect { |el| el.nil? ? 0 : el }
81
+ # Time.mktime(*elements[0,7])
68
82
  end
69
83
  end
70
84
 
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- # Copyright 2003, 2004 by Jim Weirich (jim@weirichhouse.org)
3
+ # Copyright 2003, 2004, 2005, 2006, 2007, 2008 by Jim Weirich (jim@weirichhouse.org)
4
4
  # All rights reserved.
5
5
 
6
6
  # Permission is granted for use, copying, modification, distribution,
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  #--
4
- # Copyright (c) 2003, 2004 Jim Weirich
4
+ # Copyright 2003, 2004, 2005, 2006, 2007, 2008 by Jim Weirich (jim@weirichhouse.org)
5
5
  #
6
6
  # Permission is hereby granted, free of charge, to any person obtaining
7
7
  # a copy of this software and associated documentation files (the
@@ -23,7 +23,10 @@
23
23
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
24
  #++
25
25
  #
26
- require 'ftools'
26
+ begin
27
+ require 'ftools'
28
+ rescue LoadError
29
+ end
27
30
  require 'rbconfig'
28
31
 
29
32
  ######################################################################
@@ -6,12 +6,8 @@
6
6
  require 'rubygems'
7
7
  require 'rake'
8
8
  require 'rake/packagetask'
9
-
10
- begin
11
- Gem.manage_gems
12
- rescue NoMethodError => ex
13
- # Using rubygems prior to 0.6.1
14
- end
9
+ require 'rubygems/user_interaction'
10
+ require 'rubygems/builder'
15
11
 
16
12
  module Rake
17
13
 
@@ -4,34 +4,36 @@ module Rake
4
4
 
5
5
  # Makefile loader to be used with the import file loader.
6
6
  class MakefileLoader
7
+ SPACE_MARK = "__&NBSP;__"
7
8
 
8
9
  # Load the makefile dependencies in +fn+.
9
10
  def load(fn)
10
- buffer = ''
11
11
  open(fn) do |mf|
12
- mf.each do |line|
13
- next if line =~ /^\s*#/
14
- buffer << line
15
- if buffer =~ /\\$/
16
- buffer.sub!(/\\\n/, ' ')
17
- state = :append
18
- else
19
- process_line(buffer)
20
- buffer = ''
21
- end
12
+ lines = mf.read
13
+ lines.gsub!(/\\ /, SPACE_MARK)
14
+ lines.gsub!(/#[^\n]*\n/m, "")
15
+ lines.gsub!(/\\\n/, ' ')
16
+ lines.split("\n").each do |line|
17
+ process_line(line)
22
18
  end
23
19
  end
24
- process_line(buffer) if buffer != ''
25
20
  end
26
21
 
27
22
  private
28
23
 
29
24
  # Process one logical line of makefile data.
30
25
  def process_line(line)
31
- file_task, args = line.split(':')
26
+ file_tasks, args = line.split(':')
32
27
  return if args.nil?
33
- dependents = args.split
34
- file file_task => dependents
28
+ dependents = args.split.map { |d| respace(d) }
29
+ file_tasks.strip.split.each do |file_task|
30
+ file_task = respace(file_task)
31
+ file file_task => dependents
32
+ end
33
+ end
34
+
35
+ def respace(str)
36
+ str.gsub(/#{SPACE_MARK}/, ' ')
35
37
  end
36
38
  end
37
39
 
data/lib/rake/rdoctask.rb CHANGED
@@ -28,6 +28,11 @@ module Rake
28
28
  # rd.rdoc_files.include("README.rdoc", "lib/**/*.rb")
29
29
  # end
30
30
  #
31
+ # The +rd+ object passed to the block is an RDocTask object. See the
32
+ # attributes list for the RDocTask class for available customization options.
33
+ #
34
+ # == Specifying different task names
35
+ #
31
36
  # You may wish to give the task a different name, such as if you are
32
37
  # generating two sets of documentation. For instance, if you want to have a
33
38
  # development set of documentation including private methods:
@@ -39,7 +44,17 @@ module Rake
39
44
  # end
40
45
  #
41
46
  # The tasks would then be named :<em>rdoc_dev</em>, :clobber_<em>rdoc_dev</em>, and
42
- # :re<em>rdoc_dev</em>.
47
+ # :re<em>rdoc_dev</em>.
48
+ #
49
+ # If you wish to have completely different task names, then pass a Hash as
50
+ # first argument. With the <tt>:rdoc</tt>, <tt>:clobber_rdoc</tt> and
51
+ # <tt>:rerdoc</tt> options, you can customize the task names to your liking.
52
+ # For example:
53
+ #
54
+ # Rake::RDocTask.new(:rdoc => "rdoc", :clobber_rdoc => "rdoc:clean", :rerdoc => "rdoc:force")
55
+ #
56
+ # This will create the tasks <tt>:rdoc</tt>, <tt>:rdoc_clean</tt> and
57
+ # <tt>:rdoc:force</tt>.
43
58
  #
44
59
  class RDocTask < TaskLib
45
60
  # Name of the main, top level task. (default is :rdoc)
@@ -48,34 +63,45 @@ module Rake
48
63
  # Name of directory to receive the html output files. (default is "html")
49
64
  attr_accessor :rdoc_dir
50
65
 
51
- # Title of RDoc documentation. (default is none)
66
+ # Title of RDoc documentation. (defaults to rdoc's default)
52
67
  attr_accessor :title
53
68
 
54
69
  # Name of file to be used as the main, top level file of the
55
70
  # RDoc. (default is none)
56
71
  attr_accessor :main
57
72
 
58
- # Name of template to be used by rdoc. (default is 'html')
73
+ # Name of template to be used by rdoc. (defaults to rdoc's default)
59
74
  attr_accessor :template
60
75
 
61
76
  # List of files to be included in the rdoc generation. (default is [])
62
77
  attr_accessor :rdoc_files
63
78
 
64
- # List of options to be passed rdoc. (default is [])
79
+ # Additional list of options to be passed rdoc. (default is [])
65
80
  attr_accessor :options
66
81
 
67
- # Run the rdoc process as an external shell (default is false)
82
+ # Whether to run the rdoc process as an external shell (default is false)
68
83
  attr_accessor :external
69
-
70
- # Create an RDoc task named <em>rdoc</em>. Default task name is +rdoc+.
71
- def initialize(name=:rdoc) # :yield: self
84
+
85
+ attr_accessor :inline_source
86
+
87
+ # Create an RDoc task with the given name. See the RDocTask class overview
88
+ # for documentation.
89
+ def initialize(name = :rdoc) # :yield: self
90
+ if name.is_a?(Hash)
91
+ invalid_options = name.keys.map { |k| k.to_sym } - [:rdoc, :clobber_rdoc, :rerdoc]
92
+ if !invalid_options.empty?
93
+ raise ArgumentError, "Invalid option(s) passed to RDocTask.new: #{invalid_options.join(", ")}"
94
+ end
95
+ end
96
+
72
97
  @name = name
73
98
  @rdoc_files = Rake::FileList.new
74
99
  @rdoc_dir = 'html'
75
100
  @main = nil
76
101
  @title = nil
77
- @template = 'html'
102
+ @template = nil
78
103
  @external = false
104
+ @inline_source = true
79
105
  @options = []
80
106
  yield self if block_given?
81
107
  define
@@ -83,31 +109,32 @@ module Rake
83
109
 
84
110
  # Create the tasks defined by this task lib.
85
111
  def define
86
- if name.to_s != "rdoc"
112
+ if rdoc_task_name != "rdoc"
87
113
  desc "Build the RDOC HTML Files"
114
+ else
115
+ desc "Build the #{rdoc_task_name} HTML Files"
88
116
  end
89
-
90
- desc "Build the #{name} HTML Files"
91
- task name
117
+ task rdoc_task_name
92
118
 
93
119
  desc "Force a rebuild of the RDOC files"
94
- task paste("re", name) => [paste("clobber_", name), name]
120
+ task rerdoc_task_name => [clobber_task_name, rdoc_task_name]
95
121
 
96
122
  desc "Remove rdoc products"
97
- task paste("clobber_", name) do
123
+ task clobber_task_name do
98
124
  rm_r rdoc_dir rescue nil
99
125
  end
100
-
101
- task :clobber => [paste("clobber_", name)]
126
+
127
+ task :clobber => [clobber_task_name]
102
128
 
103
129
  directory @rdoc_dir
104
- task name => [rdoc_target]
105
- file rdoc_target => @rdoc_files + [$rakefile] do
130
+ task rdoc_task_name => [rdoc_target]
131
+ file rdoc_target => @rdoc_files + [Rake.application.rakefile] do
106
132
  rm_r @rdoc_dir rescue nil
133
+ @before_running_rdoc.call if @before_running_rdoc
107
134
  args = option_list + @rdoc_files
108
135
  if @external
109
136
  argstring = args.join(' ')
110
- sh %{ruby -Ivendor vender/rd #{argstring}}
137
+ sh %{ruby -Ivendor vendor/rd #{argstring}}
111
138
  else
112
139
  require 'rdoc/rdoc'
113
140
  RDoc::RDoc.new.document(args)
@@ -122,6 +149,7 @@ module Rake
122
149
  result << "--main" << quote(main) if main
123
150
  result << "--title" << quote(title) if title
124
151
  result << "-T" << quote(template) if template
152
+ result << "--inline-source" if inline_source && !@options.include?("--inline-source") && !@options.include?("-S")
125
153
  result
126
154
  end
127
155
 
@@ -136,12 +164,46 @@ module Rake
136
164
  def option_string
137
165
  option_list.join(' ')
138
166
  end
167
+
168
+ # The block passed to this method will be called just before running the
169
+ # RDoc generator. It is allowed to modify RDocTask attributes inside the
170
+ # block.
171
+ def before_running_rdoc(&block)
172
+ @before_running_rdoc = block
173
+ end
139
174
 
140
175
  private
141
-
176
+
142
177
  def rdoc_target
143
178
  "#{rdoc_dir}/index.html"
144
179
  end
180
+
181
+ def rdoc_task_name
182
+ case name
183
+ when Hash
184
+ (name[:rdoc] || "rdoc").to_s
185
+ else
186
+ name.to_s
187
+ end
188
+ end
189
+
190
+ def clobber_task_name
191
+ case name
192
+ when Hash
193
+ (name[:clobber_rdoc] || "clobber_rdoc").to_s
194
+ else
195
+ "clobber_#{name}"
196
+ end
197
+ end
198
+
199
+ def rerdoc_task_name
200
+ case name
201
+ when Hash
202
+ (name[:rerdoc] || "rerdoc").to_s
203
+ else
204
+ "re#{name}"
205
+ end
206
+ end
145
207
 
146
208
  end
147
209
  end
File without changes
data/lib/rake/tasklib.rb CHANGED
@@ -6,11 +6,16 @@ module Rake
6
6
 
7
7
  # Base class for Task Libraries.
8
8
  class TaskLib
9
-
10
9
  include Cloneable
11
10
 
12
- # Make a symbol by pasting two strings together.
13
- def paste(a,b)
11
+ # Make a symbol by pasting two strings together.
12
+ #
13
+ # NOTE: DEPRECATED! This method is kinda stupid. I don't know why
14
+ # I didn't just use string interpolation. But now other task
15
+ # libraries depend on this so I can't remove it without breaking
16
+ # other people's code. So for now it stays for backwards
17
+ # compatibility. BUT DON'T USE IT.
18
+ def paste(a,b) # :nodoc:
14
19
  (a.to_s + b.to_s).intern
15
20
  end
16
21
  end
data/lib/rake/testtask.rb CHANGED
@@ -109,7 +109,7 @@ module Rake
109
109
  when :rake
110
110
  rake_loader
111
111
  end
112
- @ruby_opts.unshift( "-I#{lib_path}" )
112
+ @ruby_opts.unshift( "-I\"#{lib_path}\"" )
113
113
  @ruby_opts.unshift( "-w" ) if @warning
114
114
  ruby @ruby_opts.join(" ") +
115
115
  " \"#{run_code}\" " +
data/lib/rake/win32.rb ADDED
@@ -0,0 +1,55 @@
1
+
2
+ module Rake
3
+ require 'rake/alt_system'
4
+
5
+ # Win 32 interface methods for Rake. Windows specific functionality
6
+ # will be placed here to collect that knowledge in one spot.
7
+ module Win32
8
+
9
+ # Error indicating a problem in locating the home directory on a
10
+ # Win32 system.
11
+ class Win32HomeError < RuntimeError
12
+ end
13
+
14
+ class << self
15
+ # True if running on a windows system.
16
+ def windows?
17
+ AltSystem::WINDOWS
18
+ end
19
+
20
+ # Run a command line on windows.
21
+ def rake_system(*cmd)
22
+ AltSystem.system(*cmd)
23
+ end
24
+
25
+ # The standard directory containing system wide rake files on
26
+ # Win 32 systems. Try the following environment variables (in
27
+ # order):
28
+ #
29
+ # * HOME
30
+ # * HOMEDRIVE + HOMEPATH
31
+ # * APPDATA
32
+ # * USERPROFILE
33
+ #
34
+ # If the above are not defined, the return nil.
35
+ def win32_system_dir #:nodoc:
36
+ win32_shared_path = ENV['HOME']
37
+ if win32_shared_path.nil? && ENV['HOMEDRIVE'] && ENV['HOMEPATH']
38
+ win32_shared_path = ENV['HOMEDRIVE'] + ENV['HOMEPATH']
39
+ end
40
+
41
+ win32_shared_path ||= ENV['APPDATA']
42
+ win32_shared_path ||= ENV['USERPROFILE']
43
+ raise Win32HomeError, "Unable to determine home path environment variable." if
44
+ win32_shared_path.nil? or win32_shared_path.empty?
45
+ normalize(File.join(win32_shared_path, 'Rake'))
46
+ end
47
+
48
+ # Normalize a win32 path so that the slashes are all forward slashes.
49
+ def normalize(path)
50
+ path.gsub(/\\/, '/')
51
+ end
52
+
53
+ end
54
+ end
55
+ end