jimweirich-rake 0.8.1.6 → 0.8.1.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.
data/CHANGES CHANGED
@@ -1,6 +1,7 @@
1
+
1
2
  = Rake Changelog
2
3
 
3
- == Pre-Version 0.8.2
4
+ == Version 0.8.2
4
5
 
5
6
  * Fixed bug in package task so that it will include the subdir
6
7
  directory in the package for testing. (Bug found by Adam Majer)
@@ -48,6 +49,10 @@
48
49
  :with_defaults method. (Idea for default argument merging supplied
49
50
  by (Adam Q. Salter)
50
51
 
52
+ * The -T output will only self-truncate if the output is a tty.
53
+ However, if RAKE_COLUMNS is explicitly set, it will be honored in
54
+ any case. (Patch provided by Gavin Stark).
55
+
51
56
  == Version 0.8.1
52
57
 
53
58
  * Removed requires on parsedate.rb (in Ftptools)
data/README CHANGED
@@ -1,6 +1,6 @@
1
1
  = RAKE -- Ruby Make
2
2
 
3
- Supporting Rake version: 0.7.x
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.
@@ -26,6 +26,13 @@ The latest version of rake can be found at
26
26
 
27
27
  * http://rubyforge.org/project/showfiles.php?group_id=50
28
28
 
29
+ == Source Repository
30
+
31
+ Rake is currently hosted at github. The github web page is
32
+ http://github.com/jimweirich/rake. The public git clone URL is
33
+
34
+ * git://github.com/jimweirich/rake.git
35
+
29
36
  == Installation
30
37
 
31
38
  === Normal Installation
@@ -46,6 +53,7 @@ Download and install rake with the following.
46
53
 
47
54
  If you wish to run the unit and functional tests that come with Rake:
48
55
 
56
+ * Install the 'session' gem in order to run the functional tests.
49
57
  * CD into the top project directory of rake.
50
58
  * Type one of the following:
51
59
 
@@ -60,6 +68,7 @@ If you wish to run the unit and functional tests that come with Rake:
60
68
  * Rake Project Page: http://rubyforge.org/projects/rake
61
69
  * Rake API Documents: http://rake.rubyforge.org
62
70
  * Rake Source Code Repo: http://github.com/jimweirich/rake
71
+ * Rake Git Repo Clone URL: git://github.com/jimweirich/rake.git
63
72
 
64
73
  == Presentations and Articles about Rake
65
74
 
@@ -158,7 +167,7 @@ Options are:
158
167
  [<tt><em>name</em>=<em>value</em></tt>]
159
168
  Set the environment variable <em>name</em> to <em>value</em>
160
169
  during the execution of the <b>rake</b> command. You can access
161
- the value by using ENV['<em>name</em>'].
170
+ the value by using ENV['<em>name</em>'].
162
171
 
163
172
  [<tt>--classic-namespace</tt> (-n)]
164
173
  Import the Task, FileTask, and FileCreateTask into the top-level
@@ -167,10 +176,22 @@ Options are:
167
176
  'rake/classic_namespace'</code> in your Rakefile to get the
168
177
  classic behavior.
169
178
 
179
+ [<tt>--describe</tt> _pattern_ (-D)]
180
+ Describe the tasks (matching optional PATTERN), then exit.
181
+
170
182
  [<tt>--dry-run</tt> (-n)]
171
183
  Do a dry run. Print the tasks invoked and executed, but do not
172
184
  actually execute any of the actions.
173
185
 
186
+ [<tt>--execute</tt> _code_ (-e)]
187
+ Execute some Ruby code and exit.
188
+
189
+ [<tt>--execute-print</tt> _code_ (-p)]
190
+ Execute some Ruby code, print the result, and exit.
191
+
192
+ [<tt>--execute-continue</tt> _code_ (-p)]
193
+ Execute some Ruby code, then continue with normal task processing.
194
+
174
195
  [<tt>--help</tt> (-H)]
175
196
  Display some help text and exit.
176
197
 
@@ -194,9 +215,18 @@ Options are:
194
215
  directory where the Rakefile is found will become the current
195
216
  directory for the actions executed in the Rakefile.
196
217
 
218
+ [<tt>--rakelibdir</tt> _rakelibdir_ (-R)]
219
+ Auto-import any .rake files in RAKELIBDIR. (default is 'rakelib')
220
+
197
221
  [<tt>--require</tt> _name_ (-r)]
198
222
  Require _name_ before executing the Rakefile.
199
223
 
224
+ [<tt>--rules</tt>]
225
+ Trace the rules resolution.
226
+
227
+ [<tt>--silent (-s)]
228
+ Like --quiet, but also suppresses the 'in directory' announcement.
229
+
200
230
  [<tt>--tasks</tt> (-T)]
201
231
  Display a list of the major tasks and their comments. Comments
202
232
  are defined using the "desc" command.
data/Rakefile CHANGED
@@ -216,7 +216,7 @@ else
216
216
  pkg.need_tar = true
217
217
  end
218
218
 
219
- file "rake.gemspec" => "Rakefile" do |t|
219
+ file "rake.gemspec" => ["Rakefile", "lib/rake.rb"] do |t|
220
220
  require 'yaml'
221
221
  open(t.name, "w") { |f| f.puts SPEC.to_yaml }
222
222
  end
data/doc/rakefile.rdoc CHANGED
@@ -1,4 +1,4 @@
1
- = Rakefile Format
1
+ = Rakefile Format (as of version 0.8.2)
2
2
 
3
3
  First of all, there is no special format for a Rakefile. A Rakefile
4
4
  contains executable Ruby code. Anything legal in a ruby script is
@@ -150,6 +150,124 @@ to do extra synchronization for Rake's benefit. However, if there are
150
150
  user data structures shared between the parallel prerequisites, the
151
151
  user must do whatever is necessary to prevent race conditions.
152
152
 
153
+ == Tasks with Arguments
154
+
155
+ Prior to version 0.8.0, rake was only able to handle command line
156
+ arguments of the form NAME=VALUE that were passed into Rake via the
157
+ ENV hash. Many folks had asked for some kind of simple command line
158
+ arguments, perhaps using "--" to separate regular task names from
159
+ argument values on the command line. The problem is that there was no
160
+ easy way to associate positional arguments on the command line with
161
+ different tasks. Suppose both tasks :a and :b expect a command line
162
+ argument: does the first value go with :a? What if :b is run first?
163
+ Should it then get the first command line argument.
164
+
165
+ Rake 0.8.0 solves this problem by explicitly passing values directly
166
+ to the tasks that need them. For example, if I had a release task
167
+ that required a version number, I could say:
168
+
169
+ rake release[0.8.2]
170
+
171
+ And the string "0.8.2" will be passed to the :release task. Multiple
172
+ arguments can be passed by separating them with a comma, for example:
173
+
174
+ rake name[john,doe]
175
+
176
+ Just a few words of caution. The rake task name and its arguments
177
+ need to be a single command line argument to rake. This generally
178
+ means no spaces. If spaces are needed, then the entire rake +
179
+ argument string should be quoted. Something like this:
180
+
181
+ rake "name[billy bob, smith]"
182
+
183
+ (Quoting rules vary between operating systems and shells, so make sure
184
+ you consult the proper docs for your OS/shell).
185
+
186
+ === Tasks that Expect Parameters
187
+
188
+ Parameters are only given to tasks that are setup to expect them. In
189
+ order to handle named parameters, the task declaration syntax for
190
+ tasks has been extended slightly.
191
+
192
+ For example, a task that needs a first name and last name might be
193
+ declared as:
194
+
195
+ task :name, :first_name, :last_name
196
+
197
+ The first argument is still the name of the task (:name in this case).
198
+ The next to argumements are the names of the parameters expected by
199
+ :name (:first_name and :last_name in the example).
200
+
201
+ To access the values of the paramters, the block defining the task
202
+ behaviour can now accept a second parameter:
203
+
204
+ task :name, :first_name, :last_name do |t, args|
205
+ puts "First name is #{args.first_name}"
206
+ puts "Last name is #{args.last_name}"
207
+ end
208
+
209
+ The first argument of the block "t" is always bound to the current
210
+ task object. The second argument "args" is an open-struct like object
211
+ that allows access to the task arguments. Extra command line
212
+ arguments to a task are ignored. Missing command line arguments are
213
+ given the nil value.
214
+
215
+ If you wish to specify default values for the arguments, you can use
216
+ the with_defaults method in the task body. Here is the above example
217
+ where we specify default values for the first and last names:
218
+
219
+ task :name, :first_name, :last_name do |t, args|
220
+ args.with_defaults(:first_name => "John", :last_name => "Dough")
221
+ puts "First name is #{args.first_name}"
222
+ puts "Last name is #{args.last_name}"
223
+ end
224
+
225
+ === Tasks that Expect Parameters and Have Prerequisites
226
+
227
+ Tasks that use parameters have a slightly different format for
228
+ prerequisites. Use the <tt>:needs</tt> keyword to specify the
229
+ prerequisites for tasks with arguments. For example:
230
+
231
+ task :name, :first_name, :last_name, :needs => [:pre_name] do |t, args|
232
+ args.with_defaults(:first_name => "John", :last_name => "Dough")
233
+ puts "First name is #{args.first_name}"
234
+ puts "Last name is #{args.last_name}"
235
+ end
236
+
237
+ == Accessing Task Programatically
238
+
239
+ Sometimes it is useful to manipulate tasks programatically in a
240
+ Rakefile. To find a task object, use the <tt>:[]</tt> operator on the
241
+ <tt>Rake::Task</tt>.
242
+
243
+ === Programmatic Task Example
244
+
245
+ For example, the following Rakefile defines two tasks. The :doit task
246
+ simply prints a simple "DONE" message. The :dont class will lookup
247
+ the doit class and remove (clear) all of its prerequisites and
248
+ actions.
249
+
250
+ task :doit do
251
+ puts "DONE"
252
+ end
253
+
254
+ task :dont do
255
+ Rake::Task[:doit].clear
256
+ end
257
+
258
+ Running this example:
259
+
260
+ $ rake doit
261
+ (in /Users/jim/working/git/rake/x)
262
+ DONE
263
+ $ rake dont doit
264
+ (in /Users/jim/working/git/rake/x)
265
+ $
266
+
267
+ The ability to programmatically manipulate tasks gives rake very
268
+ powerful meta-programming capabilities w.r.t. task execution, but
269
+ should be used with cation.
270
+
153
271
  == Rules
154
272
 
155
273
  When a file is named as a prerequisite, but does not have a file task
@@ -372,8 +490,6 @@ Or give it a glob pattern:
372
490
 
373
491
  fl = FileList['*.rb']
374
492
 
375
-
376
-
377
493
  == Odds and Ends
378
494
 
379
495
  === do/end verses { }
@@ -0,0 +1,163 @@
1
+ = Rake 0.8.2 Released
2
+
3
+ Rake version 0.8.2 is a new release of rake that includes a number of
4
+ new features and numerous bug fixes.
5
+
6
+ == Changes
7
+
8
+ === New Features in Version 0.8.2
9
+
10
+ * Switched from getoptlong to optparse (patches supplied by Edwin
11
+ Pratomo).
12
+
13
+ * The -T option will now attempt to dynamically sense the size of the
14
+ terminal. The -T output will only self-truncate if the output is a
15
+ tty. However, if RAKE_COLUMNS is explicitly set, it will be honored
16
+ in any case. (Patch provided by Gavin Stark).
17
+
18
+ * The following public methods have been added to rake task objects:
19
+
20
+ * task.clear -- Clear both the prerequisites and actions of the
21
+ target rake task.
22
+ * task.clear_prerequisites -- Clear all the existing prerequisites
23
+ from the target rake task.
24
+ * task.clear_actions -- Clear all the existing actions from the
25
+ target rake task.
26
+ * task.reenable -- Re-enable a task, allowing its actions to be
27
+ executed again if the task is invoked.
28
+
29
+ * Changed RDoc test task to have no default template. This makes it
30
+ easier for the tempate to pick up the template from the environment.
31
+
32
+ * Default values for task arguments can easily be specified with the
33
+ :with_defaults method. (Idea for default argument merging supplied
34
+ by (Adam Q. Salter)
35
+
36
+ === Bug Fixes in Version 0.8.2
37
+
38
+ * Fixed bug in package task so that it will include the subdir
39
+ directory in the package for testing. (Bug found by Adam Majer)
40
+
41
+ * Fixed filename dependency order bug in test_inspect_pending and
42
+ test_to_s_pending. (Bug found by Adam Majer)
43
+
44
+ * Fixed check for file utils options to make them immune to the
45
+ symbol/string differences. (Patch supplied by Edwin Pratomo)
46
+
47
+ * Fixed bug with rules involving multiple source, where only the first
48
+ dependency of a rule has any effect (Patch supplied by Emanuel
49
+ Inderm�hle)
50
+
51
+ * FileList#clone and FileList#dup have better sematics w.r.t. taint
52
+ and freeze.
53
+
54
+ * Changed from using Mutex to Monitor. Evidently Mutex causes thread
55
+ join errors when Ruby is compiled with -disable-pthreads. (Patch
56
+ supplied by Ittay Dror)
57
+
58
+ * Fixed bug in makefile parser that had problems with extra spaces in
59
+ file task names. (Patch supplied by Ittay Dror)
60
+
61
+ == Other changes in Version 0.8.2
62
+
63
+ * Added ENV var to rake's own Rakefile to prevent OS X from including
64
+ extended attribute junk in the rake package tar file. (Bug found by
65
+ Adam Majer)
66
+
67
+ * Added a performance patch for reading large makefile dependency
68
+ files. (Patch supplied by Ittay Dror)
69
+
70
+ == What is Rake
71
+
72
+ Rake is a build tool similar to the make program in many ways. But
73
+ instead of cryptic make recipes, Rake uses standard Ruby code to
74
+ declare tasks and dependencies. You have the full power of a modern
75
+ scripting language built right into your build tool.
76
+
77
+ == Availability
78
+
79
+ The easiest way to get and install rake is via RubyGems ...
80
+
81
+ gem install rake (you may need root/admin privileges)
82
+
83
+ Otherwise, you can get it from the more traditional places:
84
+
85
+ Home Page:: http://rake.rubyforge.org/
86
+ Download:: http://rubyforge.org/project/showfiles.php?group_id=50
87
+
88
+ == Task Argument Examples
89
+
90
+ Prior to version 0.8.0, rake was only able to handle command line
91
+ arguments of the form NAME=VALUE that were passed into Rake via the
92
+ ENV hash. Many folks had asked for some kind of simple command line
93
+ arguments, perhaps using "--" to separate regular task names from
94
+ argument values on the command line. The problem is that there was no
95
+ easy way to associate positional arguments on the command line with
96
+ different tasks. Suppose both tasks :a and :b expect a command line
97
+ argument: does the first value go with :a? What if :b is run first?
98
+ Should it then get the first command line argument.
99
+
100
+ Rake 0.8.0 solves this problem by explicitly passing values directly
101
+ to the tasks that need them. For example, if I had a release task
102
+ that required a version number, I could say:
103
+
104
+ rake release[0.8.2]
105
+
106
+ And the string "0.8.2" will be passed to the :release task. Multiple
107
+ arguments can be passed by separating them with a comma, for example:
108
+
109
+ rake name[john,doe]
110
+
111
+ Just a few words of caution. The rake task name and its arguments
112
+ need to be a single command line argument to rake. This generally
113
+ means no spaces. If spaces are needed, then the entire rake +
114
+ argument string should be quoted. Something like this:
115
+
116
+ rake "name[billy bob, smith]"
117
+
118
+ (Quoting rules vary between operating systems and shells, so make sure
119
+ you consult the proper docs for your OS/shell).
120
+
121
+ === Tasks that Expect Parameters
122
+
123
+ Parameters are only given to tasks that are setup to expect them. In
124
+ order to handle named parameters, the task declaration syntax for
125
+ tasks has been extended slightly.
126
+
127
+ For example, a task that needs a first name and last name might be
128
+ declared as:
129
+
130
+ task :name, :first_name, :last_name
131
+
132
+ The first argument is still the name of the task (:name in this case).
133
+ The next to argumements are the names of the parameters expected by
134
+ :name (:first_name and :last_name in the example).
135
+
136
+ To access the values of the paramters, the block defining the task
137
+ behaviour can now accept a second parameter:
138
+
139
+ task :name, :first_name, :last_name do |t, args|
140
+ puts "First name is #{args.first_name}"
141
+ puts "Last name is #{args.last_name}"
142
+ end
143
+
144
+ The first argument of the block "t" is always bound to the current
145
+ task object. The second argument "args" is an open-struct like object
146
+ that allows access to the task arguments. Extra command line
147
+ arguments to a task are ignored. Missing command line arguments are
148
+ given the nil value.
149
+
150
+ == Thanks
151
+
152
+ As usual, it was input from users that drove a alot of these changes. The
153
+ following people either contributed patches, made suggestions or made
154
+ otherwise helpful comments. Thanks to ...
155
+
156
+ * Edwin Pratomo
157
+ * Gavin Stark
158
+ * Adam Q. Salter
159
+ * Adam Majer
160
+ * Emanuel Inderm�hle
161
+ * Ittay Dror
162
+
163
+ -- Jim Weirich
@@ -21,11 +21,12 @@ module Rake
21
21
 
22
22
  # Process one logical line of makefile data.
23
23
  def process_line(line)
24
- file_task, args = line.split(':')
24
+ file_tasks, args = line.split(':')
25
25
  return if args.nil?
26
- file_task.strip!
27
26
  dependents = args.split
28
- file file_task => dependents
27
+ file_tasks.strip.split.each do |file_task|
28
+ file file_task => dependents
29
+ end
29
30
  end
30
31
  end
31
32
 
@@ -122,6 +122,7 @@ module Rake
122
122
  task :package => ["#{package_dir}/#{file}"]
123
123
  file "#{package_dir}/#{file}" => [package_dir_path] + package_files do
124
124
  chdir(package_dir) do
125
+ sh %{env}
125
126
  sh %{#{@tar_command} #{flag}cvf #{file} #{package_name}}
126
127
  end
127
128
  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.1.6'
32
+ RAKEVERSION = '0.8.1.7'
33
33
 
34
34
  require 'rbconfig'
35
35
  require 'getoptlong'
@@ -359,6 +359,8 @@ module Rake
359
359
  end
360
360
  end
361
361
 
362
+ EMPTY_TASK_ARGS = TaskArguments.new([], [])
363
+
362
364
  ####################################################################
363
365
  # InvocationChain tracks the chain of task invocations to detect
364
366
  # circular dependencies.
@@ -508,25 +510,26 @@ module Rake
508
510
  @arg_names || []
509
511
  end
510
512
 
511
- # Reenable the task, allowing it to be invoked again
513
+ # Reenable the task, allowing its tasks to be executed if the task
514
+ # is invoked again.
512
515
  def reenable
513
516
  @already_invoked = false
514
517
  end
515
518
 
516
- # Clear an existing task of both prerequisites and actions
519
+ # Clear the existing prerequisites and actions of a rake task.
517
520
  def clear
518
521
  clear_prerequisites
519
522
  clear_actions
520
523
  self
521
524
  end
522
525
 
523
- # Clear the prerequisites of a task.
526
+ # Clear the existing prerequisites of a rake task.
524
527
  def clear_prerequisites
525
528
  prerequisites.clear
526
529
  self
527
530
  end
528
531
 
529
- # Clear the actions on a task.
532
+ # Clear the existing actions on a rake task.
530
533
  def clear_actions
531
534
  actions.clear
532
535
  self
@@ -540,7 +543,7 @@ module Rake
540
543
 
541
544
  # Same as invoke, but explicitly pass a call chain to detect
542
545
  # circular dependencies.
543
- def invoke_with_call_chain(task_args, invocation_chain)
546
+ def invoke_with_call_chain(task_args, invocation_chain) # :nodoc:
544
547
  new_chain = InvocationChain.append(self, invocation_chain)
545
548
  @lock.synchronize do
546
549
  if application.options.trace
@@ -555,7 +558,7 @@ module Rake
555
558
  protected :invoke_with_call_chain
556
559
 
557
560
  # Invoke all the prerequisites of a task.
558
- def invoke_prerequisites(task_args, invocation_chain)
561
+ def invoke_prerequisites(task_args, invocation_chain) # :nodoc:
559
562
  @prerequisites.each { |n|
560
563
  prereq = application[n, @scope]
561
564
  prereq_args = task_args.new_scope(prereq.arg_names)
@@ -1887,6 +1890,7 @@ module Rake
1887
1890
  @top_level_tasks = []
1888
1891
  add_loader('rf', DefaultLoader.new)
1889
1892
  add_loader('rake', DefaultLoader.new)
1893
+ @tty_output = STDOUT.tty?
1890
1894
  end
1891
1895
 
1892
1896
  # Run the Rake application. The run method performs the following three steps:
@@ -1991,7 +1995,7 @@ module Rake
1991
1995
 
1992
1996
  # True if one of the files in RAKEFILES is in the current directory.
1993
1997
  # If a match is found, it is copied into @rakefile.
1994
- def have_rakefile
1998
+ def have_project_rakefile
1995
1999
  @rakefiles.each do |fn|
1996
2000
  if File.exist?(fn) || fn == ''
1997
2001
  @rakefile = fn
@@ -2001,6 +2005,22 @@ module Rake
2001
2005
  return false
2002
2006
  end
2003
2007
 
2008
+ # True if we are outputting to TTY, false otherwise
2009
+ def tty_output?
2010
+ @tty_output
2011
+ end
2012
+
2013
+ # Override the detected TTY output state (mostly for testing)
2014
+ def tty_output=( tty_output_state )
2015
+ @tty_output = tty_output_state
2016
+ end
2017
+
2018
+ # We will truncate output if we are outputting to a TTY or if we've been
2019
+ # given an explicit column width to honor
2020
+ def truncate_output?
2021
+ tty_output? || ENV['RAKE_COLUMNS']
2022
+ end
2023
+
2004
2024
  # Display the tasks and dependencies.
2005
2025
  def display_tasks_and_comments
2006
2026
  displayable_tasks = tasks.select { |t|
@@ -2016,10 +2036,10 @@ module Rake
2016
2036
  end
2017
2037
  else
2018
2038
  width = displayable_tasks.collect { |t| t.name_with_args.length }.max || 10
2019
- max_column = terminal_width - name.size - width - 7
2039
+ max_column = truncate_output? ? terminal_width - name.size - width - 7 : nil
2020
2040
  displayable_tasks.each do |t|
2021
2041
  printf "#{name} %-#{width}s # %s\n",
2022
- t.name_with_args, truncate(t.comment, max_column)
2042
+ t.name_with_args, max_column ? truncate(t.comment, max_column) : t.comment
2023
2043
  end
2024
2044
  end
2025
2045
  end
@@ -2052,11 +2072,15 @@ module Rake
2052
2072
  RUBY_PLATFORM =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux|)/i
2053
2073
  end
2054
2074
 
2075
+ def windows?
2076
+ Config::CONFIG['host_os'] =~ /mswin/
2077
+ end
2078
+
2055
2079
  def truncate(string, width)
2056
2080
  if string.length <= width
2057
2081
  string
2058
2082
  else
2059
- string[0, width-3] + "..."
2083
+ ( string[0, width-3] || "" ) + "..."
2060
2084
  end
2061
2085
  end
2062
2086
 
@@ -2091,38 +2115,38 @@ module Rake
2091
2115
  options.show_task_pattern = Regexp.new(value || '')
2092
2116
  }
2093
2117
  ],
2118
+ ['--dry-run', '-n', "Do a dry run without executing actions.",
2119
+ lambda { |value|
2120
+ verbose(true)
2121
+ nowrite(true)
2122
+ options.dryrun = true
2123
+ options.trace = true
2124
+ }
2125
+ ],
2094
2126
  ['--execute', '-e CODE', "Execute some Ruby code and exit.",
2095
2127
  lambda { |value|
2096
2128
  eval(value)
2097
2129
  exit
2098
2130
  }
2099
2131
  ],
2100
- ['--execute-print', '-p CODE', "Execute some Ruby code, print, then exit.",
2132
+ ['--execute-print', '-p CODE', "Execute some Ruby code, print the result, then exit.",
2101
2133
  lambda { |value|
2102
2134
  puts eval(value)
2103
2135
  exit
2104
2136
  }
2105
2137
  ],
2106
- ['--execute-continue', '-E', "Execute some Ruby code, then run tasks.",
2138
+ ['--execute-continue', '-E',
2139
+ "Execute some Ruby code, then continue with normal task processing.",
2107
2140
  lambda { |value| eval(value) }
2108
2141
  ],
2109
- ['--rakefile', '-f [FILE]', "Use FILE as the rakefile.",
2110
- lambda { |value|
2111
- value ||= ''
2112
- @rakefiles.clear
2113
- @rakefiles << value
2114
- }
2115
- ],
2116
2142
  ['--libdir', '-I LIBDIR', "Include LIBDIR in the search path for required modules.",
2117
2143
  lambda { |value| $:.push(value) }
2118
2144
  ],
2119
- ['--dry-run', '-n', "Do a dry run without executing actions.",
2120
- lambda { |value|
2121
- verbose(true)
2122
- nowrite(true)
2123
- options.dryrun = true
2124
- options.trace = true
2125
- }
2145
+ ['--system', '-G', "Run tasks using system wide (global) rakefiles (usually '~/.rake/*.rake'). Project Rakefiles are ignored.",
2146
+ lambda { |value| options.load_system = true }
2147
+ ],
2148
+ ['--no-system', '-g', "Run tasks using standard project Rakefile search paths, ignoring system wide rakefiles.",
2149
+ lambda { |value| options.ignore_system = true }
2126
2150
  ],
2127
2151
  ['--nosearch', '-N', "Do not search parent directories for the Rakefile.",
2128
2152
  lambda { |value| options.nosearch = true }
@@ -2133,6 +2157,17 @@ module Rake
2133
2157
  ['--quiet', '-q', "Do not log messages to standard output.",
2134
2158
  lambda { |value| verbose(false) }
2135
2159
  ],
2160
+ ['--rakefile', '-f [FILE]', "Use FILE as the rakefile.",
2161
+ lambda { |value|
2162
+ value ||= ''
2163
+ @rakefiles.clear
2164
+ @rakefiles << value
2165
+ }
2166
+ ],
2167
+ ['--rakelibdir', '--rakelib', '-R RAKELIBDIR',
2168
+ "Auto-import any .rake files in RAKELIBDIR. (default is 'rakelib')",
2169
+ lambda { |value| options.rakelib = value.split(':') }
2170
+ ],
2136
2171
  ['--require', '-r MODULE', "Require MODULE before executing rakefile.",
2137
2172
  lambda { |value|
2138
2173
  begin
@@ -2146,10 +2181,7 @@ module Rake
2146
2181
  end
2147
2182
  }
2148
2183
  ],
2149
- ['--rakelibdir', '--rakelib', '-R RAKELIBDIR', "Auto-import any .rake files in RAKELIBDIR. (default is 'rakelib')",
2150
- lambda { |value| options.rakelib = value.split(':') }
2151
- ],
2152
- ['--rules', "Trace the rules resolution",
2184
+ ['--rules', "Trace the rules resolution.",
2153
2185
  lambda { |value| options.trace_rules = true }
2154
2186
  ],
2155
2187
  ['--silent', '-s', "Like --quiet, but also suppresses the 'in directory' announcement.",
@@ -2217,7 +2249,7 @@ module Rake
2217
2249
  end
2218
2250
 
2219
2251
  # Similar to the regular Ruby +require+ command, but will check
2220
- # for .rake files in addition to .rb files.
2252
+ # for *.rake files in addition to *.rb files.
2221
2253
  def rake_require(file_name, paths=$LOAD_PATH, loaded=$")
2222
2254
  return false if loaded.include?(file_name)
2223
2255
  paths.each do |path|
@@ -2234,22 +2266,60 @@ module Rake
2234
2266
 
2235
2267
  def raw_load_rakefile # :nodoc:
2236
2268
  here = Dir.pwd
2237
- while ! have_rakefile
2238
- Dir.chdir("..")
2239
- if Dir.pwd == here || options.nosearch
2240
- fail "No Rakefile found (looking for: #{@rakefiles.join(', ')})"
2269
+ if (options.load_system || ! have_project_rakefile) && ! options.ignore_system && have_system_rakefiles
2270
+ Dir["#{system_dir}/*.rake"].each do |name|
2271
+ add_import name
2272
+ end
2273
+ 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
2241
2280
  end
2242
- here = Dir.pwd
2243
2281
  end
2244
2282
  puts "(in #{Dir.pwd})" unless options.silent
2245
2283
  $rakefile = @rakefile
2246
- load File.expand_path(@rakefile) if @rakefile != ''
2284
+ load File.expand_path(@rakefile) if @rakefile && @rakefile != ''
2247
2285
  options.rakelib.each do |rlib|
2248
2286
  Dir["#{rlib}/*.rake"].each do |name| add_import name end
2249
2287
  end
2250
2288
  load_imports
2251
2289
  end
2252
2290
 
2291
+ def have_system_rakefiles
2292
+ Dir[File.join(system_dir, '*.rake')].size > 0
2293
+ end
2294
+
2295
+ # The directory path containing the system wide rakefiles.
2296
+ def system_dir
2297
+ if ENV['RAKE_SYSTEM']
2298
+ ENV['RAKE_SYSTEM']
2299
+ elsif windows?
2300
+ win32_system_dir
2301
+ else
2302
+ standard_system_dir
2303
+ end
2304
+ end
2305
+
2306
+ # The standard directory containing system wide rake files.
2307
+ def standard_system_dir #:nodoc:
2308
+ File.join(File.expand_path('~'), '.rake')
2309
+ end
2310
+ private :standard_system_dir
2311
+
2312
+ # The standard directory containing system wide rake files on Win
2313
+ # 32 systems.
2314
+ def win32_system_dir #:nodoc:
2315
+ unless File.exists?(win32home = File.join(ENV['APPDATA'], 'Rake'))
2316
+ raise Win32HomeError, "# Unable to determine home path environment variable."
2317
+ else
2318
+ win32home
2319
+ end
2320
+ end
2321
+ private :win32_system_dir
2322
+
2253
2323
  # Collect the list of tasks on the command line. If no tasks are
2254
2324
  # given, return a list containing only the default task.
2255
2325
  # Environmental assignments are processed at this time as well.
data/test/data/sample.mf CHANGED
@@ -8,3 +8,5 @@ b7
8
8
  a : a5 a6 a7
9
9
  c: c1
10
10
  d: d1 d2 \
11
+
12
+ e f : e1 f1
data/test/functional.rb CHANGED
@@ -6,7 +6,7 @@ begin
6
6
  require 'session'
7
7
  rescue LoadError
8
8
  puts "UNABLE TO RUN FUNCTIONAL TESTS"
9
- puts "No Session Found"
9
+ puts "No Session Found (gem install session)"
10
10
  end
11
11
 
12
12
  if defined?(Session)
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require 'rubygems'
3
4
  require 'test/unit'
4
5
  require 'fileutils'
5
6
  require 'session'
@@ -154,7 +155,7 @@ class FunctionalTest < Test::Unit::TestCase
154
155
  assert_match(/^TEST1$/, @out)
155
156
  end
156
157
 
157
- def test_dot_rake_files_can_be_laoded_with_dash_r
158
+ def test_dot_rake_files_can_be_loaded_with_dash_r
158
159
  rake "-I test/data/rakelib -rtest2 -f"
159
160
  assert_match(/^TEST2$/, @out)
160
161
  end
@@ -41,7 +41,56 @@ class TestApplication < Test::Unit::TestCase
41
41
  def test_display_tasks_with_long_comments
42
42
  ENV['RAKE_COLUMNS'] = '80'
43
43
  @app.options.show_task_pattern = //
44
- @app.last_description = "12345678901234567890123456789012345678901234567890123456789012345678901234567890"
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
51
+ end
52
+
53
+ 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
65
+ end
66
+
67
+ def test_display_tasks_with_very_long_task_name_to_a_non_tty_shows_name_and_comment
68
+ @app.options.show_task_pattern = //
69
+ @app.tty_output = false
70
+ description = "something short"
71
+ task_name = "task name" * 80
72
+ @app.last_description = "something short"
73
+ @app.define_task(Rake::Task, task_name )
74
+ out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end
75
+ # Ensure the entire task name is output and we end up showing no description
76
+ assert_match(/rake #{task_name} # #{description}/, out)
77
+ end
78
+
79
+ def test_display_tasks_with_long_comments_to_a_non_tty_shows_entire_comment
80
+ @app.options.show_task_pattern = //
81
+ @app.tty_output = false
82
+ @app.last_description = "1234567890" * 8
83
+ @app.define_task(Rake::Task, "t")
84
+ out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end
85
+ assert_match(/^rake t/, out)
86
+ assert_match(/# #{@app.last_description}/, out)
87
+ end
88
+
89
+ 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
45
94
  @app.define_task(Rake::Task, "t")
46
95
  out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end
47
96
  assert_match(/^rake t/, out)
@@ -61,13 +110,13 @@ class TestApplication < Test::Unit::TestCase
61
110
  end
62
111
 
63
112
  def test_finding_rakefile
64
- assert @app.instance_eval { have_rakefile }
113
+ assert @app.instance_eval { have_project_rakefile }
65
114
  assert_equal "rakefile", @app.rakefile.downcase
66
115
  end
67
116
 
68
117
  def test_not_finding_rakefile
69
118
  @app.instance_eval { @rakefiles = ['NEVER_FOUND'] }
70
- assert( ! @app.instance_eval do have_rakefile end )
119
+ assert( ! @app.instance_eval do have_project_rakefile end )
71
120
  assert_nil @app.rakefile
72
121
  end
73
122
 
@@ -77,6 +126,7 @@ class TestApplication < Test::Unit::TestCase
77
126
  @app.instance_eval do
78
127
  handle_options
79
128
  options.silent = true
129
+ options.ignore_system = true
80
130
  load_rakefile
81
131
  end
82
132
  assert_equal "rakefile", @app.rakefile.downcase
@@ -100,23 +150,36 @@ class TestApplication < Test::Unit::TestCase
100
150
  end
101
151
 
102
152
  def test_load_rakefile_not_found
103
- original_dir = Dir.pwd
104
- Dir.chdir("/")
105
- @app.instance_eval do
106
- handle_options
107
- options.silent = true
153
+ in_environment("PWD" => "/") do
154
+ @app.instance_eval do
155
+ handle_options
156
+ options.silent = true
157
+ options.ignore_system = true
158
+ end
159
+ ex = assert_raise(RuntimeError) do
160
+ @app.instance_eval do raw_load_rakefile end
161
+ end
162
+ assert_match(/no rakefile found/i, ex.message)
108
163
  end
109
- ex = assert_raise(RuntimeError) do
110
- @app.instance_eval do raw_load_rakefile end
164
+ end
165
+
166
+ def test_load_from_system_rakefile
167
+ in_environment('RAKE_SYSTEM' => 'test') do
168
+ @app.options.rakelib = []
169
+ @app.instance_eval do
170
+ handle_options
171
+ options.silent = true
172
+ options.load_system = true
173
+ load_rakefile
174
+ end
175
+ assert_equal "test", @app.system_dir
176
+ assert_nil @app.rakefile
111
177
  end
112
- assert_match(/no rakefile found/i, ex.message)
113
- ensure
114
- Dir.chdir(original_dir)
115
178
  end
116
179
 
117
180
  def test_not_caring_about_finding_rakefile
118
181
  @app.instance_eval do @rakefiles = [''] end
119
- assert(@app.instance_eval do have_rakefile end)
182
+ assert(@app.instance_eval do have_project_rakefile end)
120
183
  assert_equal '', @app.rakefile
121
184
  end
122
185
 
@@ -219,6 +282,29 @@ class TestApplication < Test::Unit::TestCase
219
282
  ARGV.clear
220
283
  end
221
284
 
285
+ private
286
+
287
+ def set_env(settings)
288
+ result = {}
289
+ settings.each do |k, v|
290
+ result[k] = ENV[k]
291
+ if k == 'PWD'
292
+ Dir.chdir(v)
293
+ else
294
+ ENV[k] = v
295
+ end
296
+ end
297
+ result
298
+ end
299
+
300
+ def in_environment(settings)
301
+ original_dir = Dir.pwd
302
+ original_settings = set_env(settings)
303
+ yield
304
+ ensure
305
+ set_env(original_settings)
306
+ end
307
+
222
308
  end
223
309
 
224
310
 
@@ -230,6 +316,7 @@ class TestApplicationOptions < Test::Unit::TestCase
230
316
  clear_argv
231
317
  RakeFileUtils.verbose_flag = false
232
318
  RakeFileUtils.nowrite_flag = false
319
+ TESTING_REQUIRE.clear
233
320
  end
234
321
 
235
322
  def teardown
@@ -276,6 +363,18 @@ class TestApplicationOptions < Test::Unit::TestCase
276
363
  end
277
364
  end
278
365
 
366
+ def test_system_option
367
+ flags('--system', '-G') do |opts|
368
+ assert opts.load_system
369
+ end
370
+ end
371
+
372
+ def test_no_system_option
373
+ flags('--no-system', '-g') do |opts|
374
+ assert opts.ignore_system
375
+ end
376
+ end
377
+
279
378
  def test_dry_run
280
379
  flags('--dry-run', '-n') do |opts|
281
380
  assert opts.dryrun
@@ -18,6 +18,8 @@ class TestMakefileLoader < Test::Unit::TestCase
18
18
  assert_equal %w(b1 b2 b3 b4 b5 b6 b7).sort, Task['b'].prerequisites.sort
19
19
  assert_equal %w(c1).sort, Task['c'].prerequisites.sort
20
20
  assert_equal %w(d1 d2).sort, Task['d'].prerequisites.sort
21
- assert_equal 4, Task.tasks.size
21
+ assert_equal %w(e1 f1).sort, Task['e'].prerequisites.sort
22
+ assert_equal %w(e1 f1).sort, Task['f'].prerequisites.sort
23
+ assert_equal 6, Task.tasks.size
22
24
  end
23
25
  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.1.6
4
+ version: 0.8.1.7
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-09 21:00:00 -07:00
12
+ date: 2008-08-23 21:00:00 -07:00
13
13
  default_executable: rake
14
14
  dependencies: []
15
15
 
@@ -39,10 +39,10 @@ extra_rdoc_files:
39
39
  - doc/release_notes/rake-0.7.2.rdoc
40
40
  - doc/release_notes/rake-0.7.3.rdoc
41
41
  - doc/release_notes/rake-0.8.0.rdoc
42
+ - doc/release_notes/rake-0.8.2.rdoc
42
43
  files:
43
44
  - install.rb
44
45
  - CHANGES
45
- - CVSROOT
46
46
  - MIT-LICENSE
47
47
  - Rakefile
48
48
  - README
@@ -138,6 +138,7 @@ files:
138
138
  - doc/release_notes/rake-0.7.2.rdoc
139
139
  - doc/release_notes/rake-0.7.3.rdoc
140
140
  - doc/release_notes/rake-0.8.0.rdoc
141
+ - doc/release_notes/rake-0.8.2.rdoc
141
142
  has_rdoc: true
142
143
  homepage: http://rake.rubyforge.org
143
144
  post_install_message: