jimweirich-rake 0.8.3.99 → 0.8.3.100

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.
@@ -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
@@ -0,0 +1,145 @@
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
+ module Rake
28
+ end
29
+
30
+ #
31
+ # Alternate implementations of system() and backticks `` for Windows.
32
+ #
33
+ module Rake::RepairedSystem
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 Config::CONFIG["host_os"] !~ %r!(msdos|mswin|djgpp|mingw)!
42
+ define_module_function :system, &Kernel.method(:system)
43
+ define_module_function :'`', &Kernel.method(:'`')
44
+ else
45
+ BINARY_EXTS = %w[com exe]
46
+
47
+ BATCHFILE_EXTS = %w[bat] +
48
+ if (t = ENV["COMSPEC"]) and t =~ %r!command\.exe\Z!i
49
+ []
50
+ else
51
+ %w[cmd]
52
+ end
53
+
54
+ RUNNABLE_EXTS = BINARY_EXTS + BATCHFILE_EXTS
55
+
56
+ RUNNABLE_PATTERN, BINARY_PATTERN, BATCHFILE_PATTERN =
57
+ [RUNNABLE_EXTS, BINARY_EXTS, BATCHFILE_EXTS].map { |exts|
58
+ if exts.size > 1
59
+ %r!\.(#{exts.join('|')})\Z!i
60
+ else
61
+ %r!\.#{exts.first}\Z!i
62
+ end
63
+ }
64
+
65
+ define_module_function :system_previous, &Kernel.method(:system)
66
+ define_module_function :backticks_previous, &Kernel.method(:'`')
67
+
68
+ module_function
69
+
70
+ def repair_command(cmd)
71
+ if (match = cmd.match(%r!\A\s*\"(.*?)\"!)) or
72
+ (match = cmd.match(%r!\A(\S+)!))
73
+ if runnable = find_runnable(match.captures.first)
74
+ quote(to_backslashes(runnable)) + match.post_match
75
+ else
76
+ cmd
77
+ end
78
+ else
79
+ cmd
80
+ end
81
+ end
82
+
83
+ def join_command(*args)
84
+ first =
85
+ if args.first =~ %r!\s!
86
+ quote(args.first)
87
+ else
88
+ args.first
89
+ end
90
+ [to_backslashes(first), *tail(args)].join(" ")
91
+ end
92
+
93
+ def to_backslashes(string)
94
+ string.gsub("/", "\\")
95
+ end
96
+
97
+ def quote(string)
98
+ %Q!"#{string}"!
99
+ end
100
+
101
+ def tail(array)
102
+ array[1..-1]
103
+ end
104
+
105
+ def find_runnable(file)
106
+ if file =~ RUNNABLE_PATTERN
107
+ file
108
+ else
109
+ [nil, ".", *ENV["PATH"].split(";")].each { |path|
110
+ RUNNABLE_EXTS.each { |ext|
111
+ test = (path ? "#{path}/" : "") + "#{file}.#{ext}"
112
+ if File.exist?(test)
113
+ return test
114
+ end
115
+ }
116
+ }
117
+ nil
118
+ end
119
+ end
120
+
121
+ def system(cmd, *args)
122
+ file = cmd.to_s
123
+ repaired_args =
124
+ if args.empty?
125
+ [repair_command(file)]
126
+ elsif file =~ BATCHFILE_PATTERN
127
+ [ENV["COMSPEC"], "/c", to_backslashes(File.expand_path(file)), *args]
128
+ elsif runnable = find_runnable(file)
129
+ [to_backslashes(File.expand_path(runnable)), *args]
130
+ else
131
+ # maybe a built-in shell command
132
+ [join_command(file, *args)]
133
+ end
134
+ if repaired_args.size == 1
135
+ system_previous("call #{repaired_args.first}")
136
+ else
137
+ system_previous(*repaired_args)
138
+ end
139
+ end
140
+
141
+ def `(cmd) #`
142
+ backticks_previous(repair_command(cmd))
143
+ end
144
+ end
145
+ end
data/lib/rake/win32.rb CHANGED
@@ -1,3 +1,6 @@
1
+
2
+ require 'rake/repaired_system'
3
+
1
4
  module Rake
2
5
 
3
6
  # Win 32 interface methods for Rake. Windows specific functionality
@@ -17,11 +20,7 @@ module Rake
17
20
 
18
21
  # Run a command line on windows.
19
22
  def rake_system(*cmd)
20
- if cmd.size == 1
21
- system("call #{cmd}")
22
- else
23
- system(*cmd)
24
- end
23
+ RepairedSystem.system(*cmd)
25
24
  end
26
25
 
27
26
  # The standard directory containing system wide rake files on
data/lib/rake.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  #--
4
4
 
5
- # Copyright (c) 2003, 2004, 2005, 2006, 2007 Jim Weirich
5
+ # Copyright 2003, 2004, 2005, 2006, 2007, 2008 by Jim Weirich (jim@weirichhouse.org)
6
6
  #
7
7
  # Permission is hereby granted, free of charge, to any person obtaining a copy
8
8
  # of this software and associated documentation files (the "Software"), to
@@ -29,7 +29,7 @@
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.3.99'
32
+ RAKEVERSION = '0.8.3.100'
33
33
 
34
34
  require 'rbconfig'
35
35
  require 'fileutils'
@@ -74,7 +74,7 @@ end # module Module
74
74
  #
75
75
  class String
76
76
  rake_extension("ext") do
77
- # Replace the file extension with +newext+. If there is no extenson on
77
+ # Replace the file extension with +newext+. If there is no extension on
78
78
  # the string, append the new extension to the end. If the new extension
79
79
  # is not given, or is the empty string, remove any existing extension.
80
80
  #
@@ -1461,8 +1461,8 @@ module Rake
1461
1461
  collect { |fn| fn.pathmap(spec) }
1462
1462
  end
1463
1463
 
1464
- # Return a new array with <tt>String#ext</tt> method applied to each
1465
- # member of the array.
1464
+ # Return a new file list with <tt>String#ext</tt> method applied
1465
+ # to each member of the array.
1466
1466
  #
1467
1467
  # This method is a shortcut for:
1468
1468
  #
@@ -2050,7 +2050,7 @@ module Rake
2050
2050
  exit(1)
2051
2051
  rescue Exception => ex
2052
2052
  # Exit with error message
2053
- $stderr.puts "rake aborted!"
2053
+ $stderr.puts "#{name} aborted!"
2054
2054
  $stderr.puts ex.message
2055
2055
  if options.trace
2056
2056
  $stderr.puts ex.backtrace.join("\n")
@@ -2092,14 +2092,14 @@ module Rake
2092
2092
  tty_output? || ENV['RAKE_COLUMNS']
2093
2093
  end
2094
2094
 
2095
- # Display the tasks and dependencies.
2095
+ # Display the tasks and comments.
2096
2096
  def display_tasks_and_comments
2097
2097
  displayable_tasks = tasks.select { |t|
2098
2098
  t.comment && t.name =~ options.show_task_pattern
2099
2099
  }
2100
2100
  if options.full_description
2101
2101
  displayable_tasks.each do |t|
2102
- puts "rake #{t.name_with_args}"
2102
+ puts "#{name} #{t.name_with_args}"
2103
2103
  t.full_comment.split("\n").each do |line|
2104
2104
  puts " #{line}"
2105
2105
  end
@@ -2158,7 +2158,7 @@ module Rake
2158
2158
  # Display the tasks and prerequisites
2159
2159
  def display_prerequisites
2160
2160
  tasks.each do |t|
2161
- puts "rake #{t.name}"
2161
+ puts "#{name} #{t.name}"
2162
2162
  t.prerequisites.each { |pre| puts " #{pre}" }
2163
2163
  end
2164
2164
  end
@@ -2270,7 +2270,7 @@ module Rake
2270
2270
  verbose(true)
2271
2271
  }
2272
2272
  ],
2273
- ['--verbose', '-v', "Log message to standard output (default).",
2273
+ ['--verbose', '-v', "Log message to standard output.",
2274
2274
  lambda { |value| verbose(true) }
2275
2275
  ],
2276
2276
  ['--version', '-V', "Display the program version.",
@@ -199,8 +199,8 @@ class TestApplication < Test::Unit::TestCase
199
199
  flexmock(Rake::Win32, :windows? => true)
200
200
  flexmock(@app, :standard_system_dir => "XX")
201
201
  flexmock(@app).should_receive(:load).and_return(nil)
202
- flexmock(File).should_receive(:directory?).with("D:/AD/Rake").and_return(true)
203
- in_environment('RAKE_SYSTEM' => nil, 'HOME' => nil, 'HOMEDRIVE' => 'D:', 'HOMEPATH' => '\\AD') do
202
+ flexmock(File).should_receive(:directory?).with("C:/AD/Rake").and_return(true)
203
+ in_environment('RAKE_SYSTEM' => nil, 'HOME' => nil, 'HOMEDRIVE' => 'C:', 'HOMEPATH' => '\\AD') do
204
204
  @app.options.rakelib = []
205
205
  @app.instance_eval do
206
206
  handle_options
@@ -209,7 +209,7 @@ class TestApplication < Test::Unit::TestCase
209
209
  options.rakelib = []
210
210
  load_rakefile
211
211
  end
212
- assert_equal "D:/AD/Rake", @app.system_dir
212
+ assert_equal "C:/AD/Rake", @app.system_dir
213
213
  end
214
214
  end
215
215
 
@@ -224,18 +224,14 @@ class TestFileUtils < Test::Unit::TestCase
224
224
  end
225
225
  assert block_run, "The block must be run"
226
226
 
227
- if windows?
228
- puts "SKIPPING test_ruby/part 2 when in windows"
229
- else
230
- # This one does not get expanded
231
- block_run = false
232
- ruby '-e', %{exit "#{env_var}".length} do |ok, status| # " (emacs wart)
233
- assert(!ok)
234
- assert_equal 15, status.exitstatus
235
- block_run = true
236
- end
237
- assert block_run, "The block must be run"
227
+ # This one does not get expanded
228
+ block_run = false
229
+ ruby '-e', %{exit %{#{env_var}}.length} do |ok, status| # " (emacs wart)
230
+ assert(!ok)
231
+ assert_equal env_var.length, status.exitstatus
232
+ block_run = true
238
233
  end
234
+ assert block_run, "The block must be run"
239
235
  end
240
236
  end
241
237
 
data/test/test_rules.rb CHANGED
@@ -25,7 +25,7 @@ class TestRules < Test::Unit::TestCase
25
25
  end
26
26
 
27
27
  def teardown
28
- FileList['testdata/*'].each do |f| rm_r(f, :verbose=>false) end
28
+ FileList['testdata/*'].uniq.each do |f| rm_r(f, :verbose=>false) end
29
29
  end
30
30
 
31
31
  def test_multiple_rules1
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.3.99
4
+ version: 0.8.3.100
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-10-31 21:00:00 -07:00
12
+ date: 2008-12-12 21:00:00 -08:00
13
13
  default_executable: rake
14
14
  dependencies: []
15
15
 
@@ -49,7 +49,6 @@ files:
49
49
  - MIT-LICENSE
50
50
  - Rakefile
51
51
  - README
52
- - TAGS
53
52
  - TODO
54
53
  - bin/rake
55
54
  - lib/rake/classic_namespace.rb
@@ -65,6 +64,7 @@ files:
65
64
  - lib/rake/packagetask.rb
66
65
  - lib/rake/rake_test_loader.rb
67
66
  - lib/rake/rdoctask.rb
67
+ - lib/rake/repaired_system.rb
68
68
  - lib/rake/ruby182_test_unit_fix.rb
69
69
  - lib/rake/runtest.rb
70
70
  - lib/rake/tasklib.rb