craigmarksmith-rake 0.8.3.100 → 0.8.4.101

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.
@@ -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
data/lib/rake.rb CHANGED
@@ -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.4.1'
32
+ RAKEVERSION = '0.8.4.101'
33
33
 
34
34
  require 'rbconfig'
35
35
  require 'fileutils'
@@ -2137,9 +2137,10 @@ module Rake
2137
2137
  t.name_with_args, max_column ? truncate(t.comment, max_column) : t.comment
2138
2138
  end
2139
2139
  end
2140
- if options.interactive
2140
+ if options.interactive && !displayable_tasks.empty?
2141
2141
  printf "Choose a task: "
2142
- displayable_tasks[readline.to_i].invoke
2142
+ task_input = readline
2143
+ displayable_tasks[task_input.to_i].invoke unless task_input.nil? || task_input.empty?
2143
2144
  end
2144
2145
  end
2145
2146
  end
@@ -0,0 +1,5 @@
1
+ if ARGV[0] != ARGV[1]
2
+ exit 0
3
+ else
4
+ exit 1
5
+ end
@@ -43,7 +43,7 @@ class TestApplication < Test::Unit::TestCase
43
43
 
44
44
  def test_interactive_task
45
45
  flexmock(@app)
46
- @app.should_receive(:readline).and_return(0).once
46
+ @app.should_receive(:readline).and_return('0').once
47
47
  @app.options.show_task_pattern = //
48
48
  @app.options.interactive = true
49
49
  @app.last_description = "COMMENT"
@@ -55,6 +55,31 @@ class TestApplication < Test::Unit::TestCase
55
55
  assert_match(/^0\) rake t/, out)
56
56
  assert_match(/# COMMENT/, out)
57
57
  end
58
+
59
+ def test_should_not_run_any_tasks_when_user_enters_nothing
60
+ flexmock(@app)
61
+ @app.should_receive(:readline).and_return('').once
62
+ @app.options.show_task_pattern = //
63
+ @app.options.interactive = true
64
+ @app.last_description = "COMMENT"
65
+ test_task = Rake::Task
66
+ flexmock(test_task)
67
+ test_task.new_instances.should_receive(:invoke).never
68
+ @app.define_task(test_task, "t")
69
+ out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end
70
+ assert_match(/^0\) rake t/, out)
71
+ assert_match(/# COMMENT/, out)
72
+ end
73
+
74
+ def test_should_not_ask_the_user_to_enter_an_option_when_no_tasks_are_listed
75
+ flexmock(@app)
76
+ @app.options.show_task_pattern = //
77
+ @app.options.interactive = true
78
+ @app.last_description = "COMMENT"
79
+ out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end
80
+ assert_no_match(/^0\) rake t/, out)
81
+ assert_no_match(/Choose a task:/, out)
82
+ end
58
83
 
59
84
  def test_display_tasks_with_long_comments
60
85
  in_environment('RAKE_COLUMNS' => '80') do
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'test/unit'
4
+ require 'rake'
5
+
6
+ require 'test/capture_stdout'
7
+ require 'test/rake_test_setup'
8
+
9
+ class PseudoStatusTest < Test::Unit::TestCase
10
+ def test_with_zero_exit_status
11
+ s = Rake::PseudoStatus.new
12
+ assert_equal 0, s.exitstatus
13
+ assert_equal 0, s.to_i
14
+ assert_equal 0, s >> 8
15
+ assert ! s.stopped?
16
+ assert s.exited?
17
+ end
18
+ def test_with_99_exit_status
19
+ s = Rake::PseudoStatus.new(99)
20
+ assert_equal 99, s.exitstatus
21
+ assert_equal 25344, s.to_i
22
+ assert_equal 99, s >> 8
23
+ assert ! s.stopped?
24
+ assert s.exited?
25
+ end
26
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: craigmarksmith-rake
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.3.100
4
+ version: 0.8.4.101
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-12-12 21:00:00 -08:00
12
+ date: 2009-04-05 16:00:00 -07:00
13
13
  default_executable: rake
14
14
  dependencies: []
15
15
 
@@ -51,6 +51,7 @@ files:
51
51
  - README
52
52
  - TODO
53
53
  - bin/rake
54
+ - lib/rake/alt_system.rb
54
55
  - lib/rake/classic_namespace.rb
55
56
  - lib/rake/clean.rb
56
57
  - lib/rake/contrib/compositepublisher.rb
@@ -64,7 +65,6 @@ files:
64
65
  - lib/rake/packagetask.rb
65
66
  - lib/rake/rake_test_loader.rb
66
67
  - 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
@@ -73,6 +73,7 @@ files:
73
73
  - lib/rake.rb
74
74
  - test/capture_stdout.rb
75
75
  - test/check_expansion.rb
76
+ - test/check_no_expansion.rb
76
77
  - test/contrib/test_sys.rb
77
78
  - test/data/rakelib/test1.rb
78
79
  - test/data/rbext/rakefile.rb
@@ -100,6 +101,7 @@ files:
100
101
  - test/test_namespace.rb
101
102
  - test/test_package_task.rb
102
103
  - test/test_pathmap.rb
104
+ - test/test_pseudo_status.rb
103
105
  - test/test_rake.rb
104
106
  - test/test_rdoc_task.rb
105
107
  - test/test_require.rb