rake 10.1.1 → 10.2.0

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.

Potentially problematic release.


This version of rake might be problematic. Click here for more details.

Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +2 -0
  4. data/.rubocop.yml +27 -0
  5. data/.togglerc +7 -0
  6. data/Gemfile +5 -0
  7. data/{CHANGES → History.rdoc} +84 -54
  8. data/Manifest.txt +161 -0
  9. data/README.rdoc +9 -10
  10. data/Rakefile +34 -337
  11. data/doc/command_line_usage.rdoc +16 -10
  12. data/doc/rake.1.gz +0 -0
  13. data/doc/rakefile.rdoc +72 -36
  14. data/doc/release_notes/rake-0.5.3.rdoc +1 -1
  15. data/doc/release_notes/rake-0.5.4.rdoc +1 -1
  16. data/doc/release_notes/rake-0.8.6.rdoc +1 -19
  17. data/doc/release_notes/rake-0.9.2.2.rdoc +2 -2
  18. data/doc/release_notes/rake-0.9.4.rdoc +0 -50
  19. data/doc/release_notes/rake-0.9.5.rdoc +0 -59
  20. data/doc/release_notes/rake-0.9.6.rdoc +0 -63
  21. data/doc/release_notes/rake-10.0.1.rdoc +2 -131
  22. data/doc/release_notes/rake-10.0.2.rdoc +2 -140
  23. data/doc/release_notes/rake-10.1.0.rdoc +2 -2
  24. data/lib/rake.rb +6 -1
  25. data/lib/rake/alt_system.rb +5 -3
  26. data/lib/rake/application.rb +102 -60
  27. data/lib/rake/backtrace.rb +1 -1
  28. data/lib/rake/cloneable.rb +3 -3
  29. data/lib/rake/contrib/.document +0 -0
  30. data/lib/rake/contrib/ftptools.rb +3 -5
  31. data/lib/rake/contrib/publisher.rb +12 -4
  32. data/lib/rake/contrib/rubyforgepublisher.rb +3 -1
  33. data/lib/rake/contrib/sshpublisher.rb +13 -2
  34. data/lib/rake/contrib/sys.rb +2 -0
  35. data/lib/rake/cpu_counter.rb +104 -0
  36. data/lib/rake/default_loader.rb +4 -0
  37. data/lib/rake/dsl_definition.rb +58 -17
  38. data/lib/rake/early_time.rb +4 -1
  39. data/lib/rake/ext/core.rb +2 -5
  40. data/lib/rake/ext/module.rb +1 -0
  41. data/lib/rake/ext/string.rb +35 -28
  42. data/lib/rake/ext/time.rb +1 -1
  43. data/lib/rake/file_list.rb +7 -9
  44. data/lib/rake/file_task.rb +1 -1
  45. data/lib/rake/gempackagetask.rb +3 -1
  46. data/lib/rake/invocation_chain.rb +0 -1
  47. data/lib/rake/linked_list.rb +1 -1
  48. data/lib/rake/packagetask.rb +19 -7
  49. data/lib/rake/pathmap.rb +2 -0
  50. data/lib/rake/pseudo_status.rb +2 -2
  51. data/lib/rake/rake_module.rb +6 -5
  52. data/lib/rake/rdoctask.rb +2 -0
  53. data/lib/rake/ruby182_test_unit_fix.rb +2 -0
  54. data/lib/rake/runtest.rb +6 -1
  55. data/lib/rake/scope.rb +1 -1
  56. data/lib/rake/task.rb +14 -9
  57. data/lib/rake/task_arguments.rb +19 -10
  58. data/lib/rake/task_manager.rb +20 -8
  59. data/lib/rake/tasklib.rb +2 -0
  60. data/lib/rake/testtask.rb +20 -9
  61. data/lib/rake/thread_pool.rb +13 -10
  62. data/lib/rake/trace_output.rb +1 -1
  63. data/lib/rake/version.rb +0 -2
  64. data/lib/rake/win32.rb +1 -1
  65. data/rakelib/publish.rake +20 -0
  66. data/rakelib/test_times.rake +25 -0
  67. data/test/helper.rb +6 -7
  68. data/test/support/rakefile_definitions.rb +34 -0
  69. data/test/test_rake_application.rb +89 -31
  70. data/test/test_rake_application_options.rb +13 -4
  71. data/test/test_rake_backtrace.rb +6 -2
  72. data/test/test_rake_clean.rb +3 -3
  73. data/test/test_rake_cpu_counter.rb +42 -0
  74. data/test/test_rake_file_task.rb +10 -0
  75. data/test/test_rake_functional.rb +17 -1
  76. data/test/test_rake_path_map.rb +2 -2
  77. data/test/test_rake_rules.rb +26 -0
  78. data/test/test_rake_task.rb +16 -0
  79. data/test/test_rake_task_argument_parsing.rb +6 -0
  80. data/test/test_rake_task_arguments.rb +6 -0
  81. data/test/test_rake_task_manager.rb +20 -0
  82. data/test/test_rake_test_task.rb +23 -1
  83. metadata +196 -72
  84. metadata.gz.sig +0 -0
  85. data/TODO +0 -21
  86. data/install.rb +0 -80
@@ -1,5 +1,5 @@
1
1
  module Rake
2
- module Backtrace
2
+ module Backtrace # :nodoc: all
3
3
  SYS_KEYS = RbConfig::CONFIG.keys.grep(/(prefix|libdir)/)
4
4
  SYS_PATHS = RbConfig::CONFIG.values_at(*SYS_KEYS).uniq +
5
5
  [ File.join(File.dirname(__FILE__), "..") ]
@@ -1,8 +1,8 @@
1
1
  module Rake
2
- # ##########################################################################
2
+ ##
3
3
  # Mixin for creating easily cloned objects.
4
- #
5
- module Cloneable
4
+
5
+ module Cloneable # :nodoc:
6
6
  # The hook that invoked by 'clone' and 'dup' methods.
7
7
  def initialize_copy(source)
8
8
  super
File without changes
@@ -9,9 +9,7 @@ require 'rake/file_list'
9
9
 
10
10
  module Rake # :nodoc:
11
11
 
12
- ####################################################################
13
- # <b>Note:</b> <em> Not released for general use.</em>
14
- class FtpFile
12
+ class FtpFile # :nodoc: all
15
13
  attr_reader :name, :size, :owner, :group, :time
16
14
 
17
15
  def self.date
@@ -68,9 +66,9 @@ module Rake # :nodoc:
68
66
  end
69
67
  end
70
68
 
71
- ####################################################################
69
+ ##
72
70
  # Manage the uploading of files to an FTP account.
73
- class FtpUploader
71
+ class FtpUploader # :nodoc:
74
72
 
75
73
  # Log uploads to standard output when true.
76
74
  attr_accessor :verbose
@@ -14,8 +14,10 @@ HostInfo = Struct.new(:name, :webdir, :pkgdir)
14
14
 
15
15
  # :startdoc:
16
16
 
17
+ # TODO: Move to contrib/sshpublisher
18
+ #--
17
19
  # Manage several publishers as a single entity.
18
- class CompositePublisher
20
+ class CompositePublisher # :nodoc:
19
21
  def initialize
20
22
  @publishers = []
21
23
  end
@@ -31,9 +33,11 @@ class CompositePublisher
31
33
  end
32
34
  end
33
35
 
36
+ # TODO: Remove in Rake 11, duplicated
37
+ #--
34
38
  # Publish an entire directory to an existing remote directory using
35
39
  # SSH.
36
- class SshDirPublisher
40
+ class SshDirPublisher # :nodoc: all
37
41
  def initialize(host, remote_dir, local_dir)
38
42
  @host = host
39
43
  @remote_dir = remote_dir
@@ -45,8 +49,10 @@ class SshDirPublisher
45
49
  end
46
50
  end
47
51
 
52
+ # TODO: Remove in Rake 11, duplicated
53
+ #--
48
54
  # Publish an entire directory to a fresh remote directory using SSH.
49
- class SshFreshDirPublisher < SshDirPublisher
55
+ class SshFreshDirPublisher < SshDirPublisher # :nodoc: all
50
56
  def upload
51
57
  run %{ssh #{@host} rm -rf #{@remote_dir}} rescue nil
52
58
  run %{ssh #{@host} mkdir #{@remote_dir}}
@@ -54,8 +60,10 @@ class SshFreshDirPublisher < SshDirPublisher
54
60
  end
55
61
  end
56
62
 
63
+ # TODO: Remove in Rake 11, duplicated
64
+ #--
57
65
  # Publish a list of files to an existing remote directory.
58
- class SshFilePublisher
66
+ class SshFilePublisher # :nodoc: all
59
67
  # Create a publisher using the give host information.
60
68
  def initialize(host, remote_dir, local_dir, *files)
61
69
  @host = host
@@ -1,8 +1,10 @@
1
+ # TODO: Remove in Rake 11
2
+
1
3
  require 'rake/contrib/sshpublisher'
2
4
 
3
5
  module Rake
4
6
 
5
- class RubyForgePublisher < SshDirPublisher
7
+ class RubyForgePublisher < SshDirPublisher # :nodoc: all
6
8
  attr_reader :project, :proj_id, :user
7
9
 
8
10
  def initialize(projname, user)
@@ -8,12 +8,17 @@ module Rake
8
8
  class SshDirPublisher
9
9
  include Rake::DSL
10
10
 
11
+ # Creates an SSH publisher which will scp all files in +local_dir+ to
12
+ # +remote_dir+ on +host+
13
+
11
14
  def initialize(host, remote_dir, local_dir)
12
15
  @host = host
13
16
  @remote_dir = remote_dir
14
17
  @local_dir = local_dir
15
18
  end
16
19
 
20
+ # Uploads the files
21
+
17
22
  def upload
18
23
  sh %{scp -rq #{@local_dir}/* #{@host}:#{@remote_dir}}
19
24
  end
@@ -21,6 +26,9 @@ module Rake
21
26
 
22
27
  # Publish an entire directory to a fresh remote directory using SSH.
23
28
  class SshFreshDirPublisher < SshDirPublisher
29
+
30
+ # Uploads the files after removing the existing remote directory.
31
+
24
32
  def upload
25
33
  sh %{ssh #{@host} rm -rf #{@remote_dir}} rescue nil
26
34
  sh %{ssh #{@host} mkdir #{@remote_dir}}
@@ -32,7 +40,9 @@ module Rake
32
40
  class SshFilePublisher
33
41
  include Rake::DSL
34
42
 
35
- # Create a publisher using the give host information.
43
+ # Creates an SSH publisher which will scp all +files+ in +local_dir+ to
44
+ # +remote_dir+ on +host+.
45
+
36
46
  def initialize(host, remote_dir, local_dir, *files)
37
47
  @host = host
38
48
  @remote_dir = remote_dir
@@ -40,7 +50,8 @@ module Rake
40
50
  @files = files
41
51
  end
42
52
 
43
- # Upload the local directory to the remote directory.
53
+ # Uploads the files
54
+
44
55
  def upload
45
56
  @files.each do |fn|
46
57
  sh %{scp -q #{@local_dir}/#{fn} #{@host}:#{@remote_dir}}
@@ -1,2 +1,4 @@
1
+ # TODO: Remove in Rake 11
2
+
1
3
  fail "ERROR: 'rake/contrib/sys' is obsolete and no longer supported. " +
2
4
  "Use 'FileUtils' instead."
@@ -0,0 +1,104 @@
1
+ require 'rbconfig'
2
+
3
+ module Rake
4
+
5
+ # Based on a script at:
6
+ # http://stackoverflow.com/questions/891537/ruby-detect-number-of-cpus-installed
7
+ class CpuCounter # :nodoc: all
8
+ def self.count
9
+ new.count_with_default
10
+ end
11
+
12
+ def count_with_default(default=4)
13
+ count || default
14
+ rescue StandardError
15
+ default
16
+ end
17
+
18
+ def count
19
+ if defined?(Java::Java)
20
+ count_via_java_runtime
21
+ else
22
+ case RbConfig::CONFIG['host_os']
23
+ when /darwin9/
24
+ count_via_hwprefs_cpu_count
25
+ when /darwin/
26
+ count_via_hwprefs_thread_count || count_via_sysctl
27
+ when /linux/
28
+ count_via_cpuinfo
29
+ when /freebsd/
30
+ count_via_sysctl
31
+ when /mswin|mingw/
32
+ count_via_win32
33
+ else
34
+ # Try everything
35
+ count_via_win32 ||
36
+ count_via_sysctl ||
37
+ count_via_hwprefs_thread_count ||
38
+ count_via_hwprefs_cpu_count
39
+ end
40
+ end
41
+ end
42
+
43
+ def count_via_java_runtime
44
+ Java::Java.lang.Runtime.getRuntime.availableProcessors
45
+ rescue StandardError
46
+ nil
47
+ end
48
+
49
+ def count_via_win32
50
+ require 'win32ole'
51
+ wmi = WIN32OLE.connect("winmgmts://")
52
+ cpu = wmi.ExecQuery("select NumberOfCores from Win32_Processor") # TODO count hyper-threaded in this
53
+ cpu.to_enum.first.NumberOfCores
54
+ rescue StandardError
55
+ nil
56
+ end
57
+
58
+ def count_via_cpuinfo
59
+ open('/proc/cpuinfo') { |f| f.readlines }.grep(/processor/).size
60
+ rescue StandardError
61
+ nil
62
+ end
63
+
64
+ def count_via_hwprefs_thread_count
65
+ run 'hwprefs', 'thread_count'
66
+ end
67
+
68
+ def count_via_hwprefs_cpu_count
69
+ run 'hwprefs', 'cpu_count'
70
+ end
71
+
72
+ def count_via_sysctl
73
+ run 'sysctl', '-n', 'hw.ncpu'
74
+ end
75
+
76
+ def run(command, *args)
77
+ cmd = resolve_command(command)
78
+ if cmd
79
+ IO.popen [cmd, *args] do |io|
80
+ io.read.to_i
81
+ end
82
+ else
83
+ nil
84
+ end
85
+ end
86
+
87
+ def resolve_command(command)
88
+ look_for_command("/usr/sbin", command) ||
89
+ look_for_command("/sbin", command) ||
90
+ in_path_command(command)
91
+ end
92
+
93
+ def look_for_command(dir, command)
94
+ path = File.join(dir, command)
95
+ File.exist?(path) ? path : nil
96
+ end
97
+
98
+ def in_path_command(command)
99
+ IO.popen ['which', command] do |io|
100
+ io.eof? ? nil : command
101
+ end
102
+ end
103
+ end
104
+ end
@@ -2,6 +2,10 @@ module Rake
2
2
 
3
3
  # Default Rakefile loader used by +import+.
4
4
  class DefaultLoader
5
+
6
+ ##
7
+ # Loads a rakefile into the current application from +fn+
8
+
5
9
  def load(fn)
6
10
  Rake.load_rakefile(File.expand_path(fn))
7
11
  end
@@ -6,6 +6,9 @@ module Rake
6
6
  ##
7
7
  # DSL is a module that provides #task, #desc, #namespace, etc. Use this
8
8
  # when you'd like to use rake outside the top level scope.
9
+ #
10
+ # For a Rakefile you run from the comamnd line this module is automatically
11
+ # included.
9
12
 
10
13
  module DSL
11
14
 
@@ -21,14 +24,45 @@ module Rake
21
24
 
22
25
  private
23
26
 
24
- # Declare a basic task.
27
+ # :call-seq:
28
+ # task task_name
29
+ # task task_name: dependencies
30
+ # task task_name, arguments => dependencies
31
+ # task task_name, argument[, argument ...], :needs: dependencies
25
32
  #
26
- # Example:
27
- # task :clobber => [:clean] do
33
+ # Declare a basic task. The +task_name+ is always the first argument. If
34
+ # the task name contains a ":" it is defined in that namespace.
35
+ #
36
+ # The +dependencies+ may be a single task name or an Array of task names.
37
+ # The +argument+ (a single name) or +arguments+ (an Array of names) define
38
+ # the arguments provided to the task.
39
+ #
40
+ # The task, argument and dependency names may be either symbols or
41
+ # strings.
42
+ #
43
+ # A task with a single dependency:
44
+ #
45
+ # task clobber: %w[clean] do
28
46
  # rm_rf "html"
29
47
  # end
30
48
  #
31
- def task(*args, &block)
49
+ # A task with an argument and a dependency:
50
+ #
51
+ # task :package, [:version] => :test do |t, args|
52
+ # # ...
53
+ # end
54
+ #
55
+ # To invoke this task from the command line:
56
+ #
57
+ # $ rake package[1.2.3]
58
+ #
59
+ # Alternate definition:
60
+ #
61
+ # task :package, :version, needs: :test do |t, args|
62
+ # # ...
63
+ # end
64
+ #
65
+ def task(*args, &block) # :doc:
32
66
  Rake::Task.define_task(*args, &block)
33
67
  end
34
68
 
@@ -45,7 +79,7 @@ module Rake
45
79
  # end
46
80
  # end
47
81
  #
48
- def file(*args, &block)
82
+ def file(*args, &block) # :doc:
49
83
  Rake::FileTask.define_task(*args, &block)
50
84
  end
51
85
 
@@ -61,7 +95,7 @@ module Rake
61
95
  # Example:
62
96
  # directory "testdata/doc"
63
97
  #
64
- def directory(*args, &block)
98
+ def directory(*args, &block) # :doc:
65
99
  result = file_create(*args, &block)
66
100
  dir, _ = *Rake.application.resolve_args(args)
67
101
  Rake.each_dir_parent(dir) do |d|
@@ -78,9 +112,9 @@ module Rake
78
112
  # about it)
79
113
  #
80
114
  # Example:
81
- # multitask :deploy => [:deploy_gem, :deploy_rdoc]
115
+ # multitask deploy: %w[deploy_gem deploy_rdoc]
82
116
  #
83
- def multitask(*args, &block)
117
+ def multitask(*args, &block) # :doc:
84
118
  Rake::MultiTask.define_task(*args, &block)
85
119
  end
86
120
 
@@ -88,14 +122,22 @@ module Rake
88
122
  # block. Returns a NameSpace object that can be used to lookup
89
123
  # tasks defined in the namespace.
90
124
  #
91
- # E.g.
125
+ # Example:
92
126
  #
93
127
  # ns = namespace "nested" do
128
+ # # the "nested:run" task
94
129
  # task :run
95
130
  # end
96
131
  # task_run = ns[:run] # find :run in the given namespace.
97
132
  #
98
- def namespace(name=nil, &block)
133
+ # Tasks can also be defined in a namespace by using a ":" in the task
134
+ # name:
135
+ #
136
+ # task "nested:test" do
137
+ # # ...
138
+ # end
139
+ #
140
+ def namespace(name=nil, &block) # :doc:
99
141
  name = name.to_s if name.kind_of?(Symbol)
100
142
  name = name.to_str if name.respond_to?(:to_str)
101
143
  unless name.kind_of?(String) || name.nil?
@@ -111,20 +153,19 @@ module Rake
111
153
  # sh %{cc -o #{t.name} #{t.source}}
112
154
  # end
113
155
  #
114
- def rule(*args, &block)
156
+ def rule(*args, &block) # :doc:
115
157
  Rake::Task.create_rule(*args, &block)
116
158
  end
117
159
 
118
- # Describe the next rake task.
119
- # Duplicate descriptions are discarded.
160
+ # Describes the next rake task. Duplicate descriptions are discarded.
120
161
  #
121
162
  # Example:
122
163
  # desc "Run the Unit Tests"
123
- # task :test => [:build]
124
- # runtests
164
+ # task test: [:build]
165
+ # # ... run tests
125
166
  # end
126
167
  #
127
- def desc(description)
168
+ def desc(description) # :doc:
128
169
  Rake.application.last_description = description
129
170
  end
130
171
 
@@ -142,7 +183,7 @@ module Rake
142
183
  # Example:
143
184
  # import ".depend", "my_rules"
144
185
  #
145
- def import(*fns)
186
+ def import(*fns) # :doc:
146
187
  fns.each do |fn|
147
188
  Rake.application.add_import(fn)
148
189
  end
@@ -5,11 +5,14 @@ module Rake
5
5
  include Comparable
6
6
  include Singleton
7
7
 
8
+ ##
9
+ # The EarlyTime always comes before +other+!
10
+
8
11
  def <=>(other)
9
12
  -1
10
13
  end
11
14
 
12
- def to_s
15
+ def to_s # :nodoc:
13
16
  "<EARLY TIME>"
14
17
  end
15
18
  end
@@ -1,8 +1,5 @@
1
- ######################################################################
2
- # Core extension library
3
- #
4
1
  class Module
5
- # Check for an existing method in the current class before extending. IF
2
+ # Check for an existing method in the current class before extending. If
6
3
  # the method already exists, then a warning is printed and the extension is
7
4
  # not added. Otherwise the block is yielded and any definitions in the
8
5
  # block will take effect.
@@ -17,7 +14,7 @@ class Module
17
14
  # end
18
15
  # end
19
16
  #
20
- def rake_extension(method)
17
+ def rake_extension(method) # :nodoc:
21
18
  if method_defined?(method)
22
19
  $stderr.puts "WARNING: Possible conflict with Rake extension: " +
23
20
  "#{self}##{method} already exists"