jimweirich-rake 0.8.1.7 → 0.8.1.8

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/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.1.7'
32
+ RAKEVERSION = '0.8.1.8'
33
33
 
34
34
  require 'rbconfig'
35
35
  require 'getoptlong'
@@ -1888,6 +1888,7 @@ module Rake
1888
1888
  @default_loader = Rake::DefaultLoader.new
1889
1889
  @original_dir = Dir.pwd
1890
1890
  @top_level_tasks = []
1891
+ add_loader('rb', DefaultLoader.new)
1891
1892
  add_loader('rf', DefaultLoader.new)
1892
1893
  add_loader('rake', DefaultLoader.new)
1893
1894
  @tty_output = STDOUT.tty?
@@ -1995,14 +1996,13 @@ module Rake
1995
1996
 
1996
1997
  # True if one of the files in RAKEFILES is in the current directory.
1997
1998
  # If a match is found, it is copied into @rakefile.
1998
- def have_project_rakefile
1999
+ def have_rakefile
1999
2000
  @rakefiles.each do |fn|
2000
2001
  if File.exist?(fn) || fn == ''
2001
- @rakefile = fn
2002
- return true
2002
+ return fn
2003
2003
  end
2004
2004
  end
2005
- return false
2005
+ return nil
2006
2006
  end
2007
2007
 
2008
2008
  # True if we are outputting to TTY, false otherwise
@@ -2075,7 +2075,7 @@ module Rake
2075
2075
  def windows?
2076
2076
  Config::CONFIG['host_os'] =~ /mswin/
2077
2077
  end
2078
-
2078
+
2079
2079
  def truncate(string, width)
2080
2080
  if string.length <= width
2081
2081
  string
@@ -2190,6 +2190,14 @@ module Rake
2190
2190
  options.silent = true
2191
2191
  }
2192
2192
  ],
2193
+ ['--system', '-g',
2194
+ "Using system wide (global) rakefiles (usually '~/.rake/*.rake').",
2195
+ lambda { |value| options.load_system = true }
2196
+ ],
2197
+ ['--no-system', '-G',
2198
+ "Use standard project Rakefile search paths, ignore system wide rakefiles.",
2199
+ lambda { |value| options.ignore_system = true }
2200
+ ],
2193
2201
  ['--tasks', '-T [PATTERN]', "Display the tasks (matching optional PATTERN) with descriptions, then exit.",
2194
2202
  lambda { |value|
2195
2203
  options.show_tasks = true
@@ -2216,9 +2224,6 @@ module Rake
2216
2224
 
2217
2225
  options.rakelib = ['rakelib']
2218
2226
 
2219
- # opts = GetoptLong.new(*command_line_options)
2220
- # opts.each { |opt, value| do_option(opt, value) }
2221
-
2222
2227
  parsed_argv = nil
2223
2228
  opts = OptionParser.new do |opts|
2224
2229
  opts.banner = "rake [-f rakefile] {options} targets..."
@@ -2264,34 +2269,40 @@ module Rake
2264
2269
  fail LoadError, "Can't find #{file_name}"
2265
2270
  end
2266
2271
 
2267
- def raw_load_rakefile # :nodoc:
2272
+ def find_rakefile_location
2268
2273
  here = Dir.pwd
2269
- if (options.load_system || ! have_project_rakefile) && ! options.ignore_system && have_system_rakefiles
2274
+ while ! (fn = have_rakefile)
2275
+ Dir.chdir("..")
2276
+ if Dir.pwd == here || options.nosearch
2277
+ fail "No Rakefile found (looking for: #{@rakefiles.join(', ')})"
2278
+ end
2279
+ here = Dir.pwd
2280
+ end
2281
+ [fn, here]
2282
+ ensure
2283
+ Dir.chdir(Rake.original_dir)
2284
+ end
2285
+
2286
+ def raw_load_rakefile # :nodoc:
2287
+ rakefile, location = find_rakefile_location
2288
+ if (! options.ignore_system) && (options.load_system || rakefile.nil?)
2289
+ puts "(in #{Dir.pwd})" unless options.silent
2270
2290
  Dir["#{system_dir}/*.rake"].each do |name|
2271
2291
  add_import name
2272
2292
  end
2273
2293
  else
2274
- while ! have_project_rakefile
2275
- Dir.chdir("..")
2276
- if Dir.pwd == here || options.nosearch
2277
- fail "No Rakefile found (looking for: #{@rakefiles.join(', ')})"
2278
- end
2279
- here = Dir.pwd
2280
- end
2294
+ @rakefile = rakefile
2295
+ Dir.chdir(location)
2296
+ puts "(in #{Dir.pwd})" unless options.silent
2297
+ $rakefile = @rakefile
2298
+ load File.expand_path(@rakefile) if @rakefile && @rakefile != ''
2281
2299
  end
2282
- puts "(in #{Dir.pwd})" unless options.silent
2283
- $rakefile = @rakefile
2284
- load File.expand_path(@rakefile) if @rakefile && @rakefile != ''
2285
2300
  options.rakelib.each do |rlib|
2286
2301
  Dir["#{rlib}/*.rake"].each do |name| add_import name end
2287
2302
  end
2288
2303
  load_imports
2289
2304
  end
2290
2305
 
2291
- def have_system_rakefiles
2292
- Dir[File.join(system_dir, '*.rake')].size > 0
2293
- end
2294
-
2295
2306
  # The directory path containing the system wide rakefiles.
2296
2307
  def system_dir
2297
2308
  if ENV['RAKE_SYSTEM']
@@ -1,6 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'rubygems'
3
+ begin
4
+ require 'rubygems'
5
+ rescue LoadError => ex
6
+ end
4
7
  require 'test/unit'
5
8
  require 'fileutils'
6
9
  require 'session'
@@ -86,6 +89,22 @@ class FunctionalTest < Test::Unit::TestCase
86
89
  assert_match %r{^OK$}, @out
87
90
  end
88
91
 
92
+ def test_system
93
+ ENV['RAKE_SYSTEM'] = 'test/data/sys'
94
+ rake '-g', "sys1"
95
+ assert_match %r{^SYS1}, @out
96
+ ensure
97
+ ENV['RAKE_SYSTEM'] = nil
98
+ end
99
+
100
+ def test_no_system
101
+ ENV['RAKE_SYSTEM'] = 'test/data/sys'
102
+ rake '-G', "sys1"
103
+ assert_match %r{^Don't know how to build task}, @err # emacs wart: '
104
+ ensure
105
+ ENV['RAKE_SYSTEM'] = nil
106
+ end
107
+
89
108
  def test_nosearch
90
109
  mkdir_p "test/data/nosearch", :verbose => false rescue nil
91
110
  Dir.chdir("test/data/nosearch") do rake "-N" end
@@ -39,29 +39,27 @@ class TestApplication < Test::Unit::TestCase
39
39
  end
40
40
 
41
41
  def test_display_tasks_with_long_comments
42
- ENV['RAKE_COLUMNS'] = '80'
43
- @app.options.show_task_pattern = //
44
- @app.last_description = "1234567890" * 8
45
- @app.define_task(Rake::Task, "t")
46
- out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end
47
- assert_match(/^rake t/, out)
48
- assert_match(/# 12345678901234567890123456789012345678901234567890123456789012345\.\.\./, out)
49
- ensure
50
- ENV['RAKE_COLUMNS'] = nil
42
+ in_environment('RAKE_COLUMNS' => '80') do
43
+ @app.options.show_task_pattern = //
44
+ @app.last_description = "1234567890" * 8
45
+ @app.define_task(Rake::Task, "t")
46
+ out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end
47
+ assert_match(/^rake t/, out)
48
+ assert_match(/# 12345678901234567890123456789012345678901234567890123456789012345\.\.\./, out)
49
+ end
51
50
  end
52
51
 
53
52
  def test_display_tasks_with_task_name_wider_than_tty_display
54
- ENV['RAKE_COLUMNS'] = '80'
55
- @app.options.show_task_pattern = //
56
- description = "something short"
57
- task_name = "task name" * 80
58
- @app.last_description = "something short"
59
- @app.define_task(Rake::Task, task_name )
60
- out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end
61
- # Ensure the entire task name is output and we end up showing no description
62
- assert_match(/rake #{task_name} # .../, out)
63
- ensure
64
- ENV['RAKE_COLUMNS'] = nil
53
+ in_environment('RAKE_COLUMNS' => '80') do
54
+ @app.options.show_task_pattern = //
55
+ description = "something short"
56
+ task_name = "task name" * 80
57
+ @app.last_description = "something short"
58
+ @app.define_task(Rake::Task, task_name )
59
+ out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end
60
+ # Ensure the entire task name is output and we end up showing no description
61
+ assert_match(/rake #{task_name} # .../, out)
62
+ end
65
63
  end
66
64
 
67
65
  def test_display_tasks_with_very_long_task_name_to_a_non_tty_shows_name_and_comment
@@ -87,16 +85,15 @@ class TestApplication < Test::Unit::TestCase
87
85
  end
88
86
 
89
87
  def test_display_tasks_with_long_comments_to_a_non_tty_with_columns_set_truncates_comments
90
- ENV['RAKE_COLUMNS'] = '80'
91
- @app.options.show_task_pattern = //
92
- @app.tty_output = false
93
- @app.last_description = "1234567890" * 8
94
- @app.define_task(Rake::Task, "t")
95
- out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end
96
- assert_match(/^rake t/, out)
97
- assert_match(/# 12345678901234567890123456789012345678901234567890123456789012345\.\.\./, out)
98
- ensure
99
- ENV['RAKE_COLUMNS'] = nil
88
+ in_environment("RAKE_COLUMNS" => '80') do
89
+ @app.options.show_task_pattern = //
90
+ @app.tty_output = false
91
+ @app.last_description = "1234567890" * 8
92
+ @app.define_task(Rake::Task, "t")
93
+ out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end
94
+ assert_match(/^rake t/, out)
95
+ assert_match(/# 12345678901234567890123456789012345678901234567890123456789012345\.\.\./, out)
96
+ end
100
97
  end
101
98
 
102
99
  def test_display_tasks_with_full_descriptions
@@ -110,43 +107,37 @@ class TestApplication < Test::Unit::TestCase
110
107
  end
111
108
 
112
109
  def test_finding_rakefile
113
- assert @app.instance_eval { have_project_rakefile }
114
- assert_equal "rakefile", @app.rakefile.downcase
110
+ assert_equal "rakefile", @app.instance_eval { have_rakefile }
115
111
  end
116
112
 
117
113
  def test_not_finding_rakefile
118
114
  @app.instance_eval { @rakefiles = ['NEVER_FOUND'] }
119
- assert( ! @app.instance_eval do have_project_rakefile end )
115
+ assert( ! @app.instance_eval do have_rakefile end )
120
116
  assert_nil @app.rakefile
121
117
  end
122
118
 
123
119
  def test_load_rakefile
124
- original_dir = Dir.pwd
125
- Dir.chdir("test/data/unittest")
126
- @app.instance_eval do
127
- handle_options
128
- options.silent = true
129
- options.ignore_system = true
130
- load_rakefile
131
- end
132
- assert_equal "rakefile", @app.rakefile.downcase
133
- assert_match(%r(unittest$), Dir.pwd)
134
- ensure
135
- Dir.chdir(original_dir)
120
+ in_environment("PWD" => "test/data/unittest") do
121
+ @app.instance_eval do
122
+ handle_options
123
+ options.silent = true
124
+ load_rakefile
125
+ end
126
+ assert_equal "rakefile", @app.rakefile.downcase
127
+ assert_match(%r(unittest$), Dir.pwd)
128
+ end
136
129
  end
137
130
 
138
131
  def test_load_rakefile_from_subdir
139
- original_dir = Dir.pwd
140
- Dir.chdir("test/data/unittest/subdir")
141
- @app.instance_eval do
142
- handle_options
143
- options.silent = true
144
- load_rakefile
132
+ in_environment("PWD" => "test/data/unittest/subdir") do
133
+ @app.instance_eval do
134
+ handle_options
135
+ options.silent = true
136
+ load_rakefile
137
+ end
138
+ assert_equal "rakefile", @app.rakefile.downcase
139
+ assert_match(%r(unittest$), Dir.pwd)
145
140
  end
146
- assert_equal "rakefile", @app.rakefile.downcase
147
- assert_match(%r(unittest$), Dir.pwd)
148
- ensure
149
- Dir.chdir(original_dir)
150
141
  end
151
142
 
152
143
  def test_load_rakefile_not_found
@@ -154,7 +145,6 @@ class TestApplication < Test::Unit::TestCase
154
145
  @app.instance_eval do
155
146
  handle_options
156
147
  options.silent = true
157
- options.ignore_system = true
158
148
  end
159
149
  ex = assert_raise(RuntimeError) do
160
150
  @app.instance_eval do raw_load_rakefile end
@@ -164,7 +154,7 @@ class TestApplication < Test::Unit::TestCase
164
154
  end
165
155
 
166
156
  def test_load_from_system_rakefile
167
- in_environment('RAKE_SYSTEM' => 'test') do
157
+ in_environment('RAKE_SYSTEM' => 'test/data/sys') do
168
158
  @app.options.rakelib = []
169
159
  @app.instance_eval do
170
160
  handle_options
@@ -172,17 +162,11 @@ class TestApplication < Test::Unit::TestCase
172
162
  options.load_system = true
173
163
  load_rakefile
174
164
  end
175
- assert_equal "test", @app.system_dir
165
+ assert_equal "test/data/sys", @app.system_dir
176
166
  assert_nil @app.rakefile
177
167
  end
178
168
  end
179
169
 
180
- def test_not_caring_about_finding_rakefile
181
- @app.instance_eval do @rakefiles = [''] end
182
- assert(@app.instance_eval do have_project_rakefile end)
183
- assert_equal '', @app.rakefile
184
- end
185
-
186
170
  def test_loading_imports
187
171
  mock = flexmock("loader")
188
172
  mock.should_receive(:load).with("x.dummy").once
@@ -283,7 +267,7 @@ class TestApplication < Test::Unit::TestCase
283
267
  end
284
268
 
285
269
  private
286
-
270
+
287
271
  def set_env(settings)
288
272
  result = {}
289
273
  settings.each do |k, v|
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.1.7
4
+ version: 0.8.1.8
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-08-23 21:00:00 -07:00
12
+ date: 2008-08-29 21:00:00 -07:00
13
13
  default_executable: rake
14
14
  dependencies: []
15
15