drake 0.8.7.0.2.4 → 0.9.0.0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (132) hide show
  1. data/.gemtest +0 -0
  2. data/CHANGES +77 -9
  3. data/{CHANGES.drake → CHANGES-drake} +6 -2
  4. data/MIT-LICENSE +2 -0
  5. data/{README → README.rdoc} +30 -18
  6. data/Rakefile +144 -130
  7. data/Rakefile-drake +67 -0
  8. data/TODO +1 -1
  9. data/bin/drake +2 -0
  10. data/doc/command_line_usage.rdoc +25 -11
  11. data/doc/glossary.rdoc +2 -2
  12. data/doc/jamis.rb +2 -2
  13. data/doc/parallel.rdoc +37 -29
  14. data/doc/proto_rake.rdoc +22 -22
  15. data/doc/rake.1.gz +0 -0
  16. data/doc/rakefile.rdoc +56 -33
  17. data/doc/rational.rdoc +6 -6
  18. data/doc/release_notes/rake-0.4.15.rdoc +1 -1
  19. data/doc/release_notes/rake-0.5.0.rdoc +1 -1
  20. data/doc/release_notes/rake-0.7.0.rdoc +1 -1
  21. data/doc/release_notes/rake-0.7.2.rdoc +3 -3
  22. data/doc/release_notes/rake-0.7.3.rdoc +2 -2
  23. data/doc/release_notes/rake-0.8.0.rdoc +1 -1
  24. data/doc/release_notes/rake-0.8.2.rdoc +3 -3
  25. data/doc/release_notes/rake-0.8.3.rdoc +2 -2
  26. data/doc/release_notes/rake-0.8.4.rdoc +1 -1
  27. data/doc/release_notes/rake-0.8.5.rdoc +1 -1
  28. data/doc/release_notes/rake-0.8.6.rdoc +1 -1
  29. data/doc/release_notes/rake-0.8.7.rdoc +1 -1
  30. data/doc/release_notes/rake-0.9.0.rdoc +112 -0
  31. data/install.rb +14 -12
  32. data/lib/rake.rb +31 -2527
  33. data/lib/rake/alt_system.rb +7 -6
  34. data/lib/rake/application.rb +626 -0
  35. data/lib/rake/classic_namespace.rb +1 -0
  36. data/lib/rake/clean.rb +2 -4
  37. data/lib/rake/cloneable.rb +25 -0
  38. data/lib/rake/contrib/compositepublisher.rb +2 -5
  39. data/lib/rake/contrib/ftptools.rb +5 -8
  40. data/lib/rake/contrib/publisher.rb +2 -8
  41. data/lib/rake/contrib/rubyforgepublisher.rb +2 -4
  42. data/lib/rake/contrib/sshpublisher.rb +4 -6
  43. data/lib/rake/contrib/sys.rb +7 -25
  44. data/lib/rake/default_loader.rb +10 -0
  45. data/lib/rake/dsl.rb +2 -0
  46. data/lib/rake/dsl_definition.rb +143 -0
  47. data/lib/rake/early_time.rb +18 -0
  48. data/lib/rake/ext/core.rb +27 -0
  49. data/lib/rake/ext/module.rb +39 -0
  50. data/lib/rake/ext/string.rb +167 -0
  51. data/lib/rake/ext/time.rb +14 -0
  52. data/lib/rake/file_creation_task.rb +24 -0
  53. data/lib/rake/file_list.rb +403 -0
  54. data/lib/rake/file_task.rb +47 -0
  55. data/lib/rake/file_utils.rb +112 -0
  56. data/lib/rake/file_utils_ext.rb +142 -0
  57. data/lib/rake/gempackagetask.rb +6 -90
  58. data/lib/rake/invocation_chain.rb +51 -0
  59. data/lib/rake/invocation_exception_mixin.rb +16 -0
  60. data/lib/rake/loaders/makefile.rb +13 -15
  61. data/lib/rake/multi_task.rb +16 -0
  62. data/lib/rake/name_space.rb +25 -0
  63. data/lib/rake/packagetask.rb +13 -12
  64. data/lib/rake/parallel.rb +17 -28
  65. data/lib/rake/pathmap.rb +1 -0
  66. data/lib/rake/pseudo_status.rb +24 -0
  67. data/lib/rake/rake_module.rb +29 -0
  68. data/lib/rake/rake_test_loader.rb +10 -2
  69. data/lib/rake/rdoctask.rb +211 -190
  70. data/lib/rake/ruby182_test_unit_fix.rb +9 -7
  71. data/lib/rake/rule_recursion_overflow_error.rb +20 -0
  72. data/lib/rake/runtest.rb +4 -6
  73. data/lib/rake/task.rb +351 -0
  74. data/lib/rake/task_argument_error.rb +7 -0
  75. data/lib/rake/task_arguments.rb +74 -0
  76. data/lib/rake/task_manager.rb +307 -0
  77. data/lib/rake/tasklib.rb +1 -2
  78. data/lib/rake/testtask.rb +57 -27
  79. data/lib/rake/version.rb +13 -0
  80. data/lib/rake/win32.rb +4 -4
  81. data/test/contrib/test_sys.rb +8 -31
  82. data/test/data/access/Rakefile +33 -0
  83. data/test/data/comments/Rakefile +18 -0
  84. data/test/data/default/Rakefile +1 -1
  85. data/test/data/deprecated_import/Rakefile +1 -0
  86. data/test/data/dryrun/Rakefile +1 -1
  87. data/test/data/file_creation_task/Rakefile +1 -1
  88. data/test/data/namespace/Rakefile +9 -0
  89. data/test/data/rakelib/test1.rb +1 -0
  90. data/test/data/verbose/Rakefile +34 -0
  91. data/test/{filecreation.rb → file_creation.rb} +11 -7
  92. data/test/functional/functional_test.rb +25 -0
  93. data/test/{session_functional.rb → functional/session_based_tests.rb} +141 -23
  94. data/test/in_environment.rb +7 -5
  95. data/test/{test_application.rb → lib/application_test.rb} +331 -143
  96. data/test/{test_clean.rb → lib/clean_test.rb} +1 -0
  97. data/test/{test_definitions.rb → lib/definitions_test.rb} +4 -4
  98. data/test/lib/dsl_test.rb +52 -0
  99. data/test/{test_earlytime.rb → lib/earlytime_test.rb} +1 -2
  100. data/test/{test_extension.rb → lib/extension_test.rb} +2 -2
  101. data/test/{test_file_creation_task.rb → lib/file_creation_task_test.rb} +1 -1
  102. data/test/{test_file_task.rb → lib/file_task_test.rb} +9 -5
  103. data/test/{test_filelist.rb → lib/filelist_test.rb} +38 -24
  104. data/test/{test_fileutils.rb → lib/fileutils_test.rb} +27 -22
  105. data/test/{test_ftp.rb → lib/ftp_test.rb} +0 -0
  106. data/test/{test_invocation_chain.rb → lib/invocation_chain_test.rb} +0 -0
  107. data/test/{test_makefile_loader.rb → lib/makefile_loader_test.rb} +0 -0
  108. data/test/{test_multitask.rb → lib/multitask_test.rb} +3 -2
  109. data/test/{test_namespace.rb → lib/namespace_test.rb} +0 -0
  110. data/test/lib/package_task_test.rb +82 -0
  111. data/test/{test_parallel.rb → lib/parallel_test.rb} +5 -5
  112. data/test/{test_pathmap.rb → lib/pathmap_test.rb} +3 -2
  113. data/test/{test_pseudo_status.rb → lib/pseudo_status_test.rb} +0 -0
  114. data/test/{test_rake.rb → lib/rake_test.rb} +1 -1
  115. data/test/{test_rdoc_task.rb → lib/rdoc_task_test.rb} +19 -23
  116. data/test/{test_require.rb → lib/require_test.rb} +8 -2
  117. data/test/{test_rules.rb → lib/rules_test.rb} +4 -5
  118. data/test/{test_task_arguments.rb → lib/task_arguments_test.rb} +5 -5
  119. data/test/{test_task_manager.rb → lib/task_manager_test.rb} +15 -5
  120. data/test/{test_tasks.rb → lib/task_test.rb} +91 -28
  121. data/test/{test_tasklib.rb → lib/tasklib_test.rb} +0 -0
  122. data/test/{test_test_task.rb → lib/test_task_test.rb} +3 -3
  123. data/test/lib/testtask_test.rb +49 -0
  124. data/test/{test_top_level_functions.rb → lib/top_level_functions_test.rb} +5 -3
  125. data/test/{test_win32.rb → lib/win32_test.rb} +19 -0
  126. data/test/rake_test_setup.rb +6 -10
  127. data/test/ruby_version_test.rb +3 -0
  128. data/test/test_helper.rb +19 -0
  129. metadata +108 -66
  130. data/Rakefile.drake +0 -73
  131. data/test/functional.rb +0 -15
  132. data/test/test_package_task.rb +0 -118
@@ -0,0 +1,47 @@
1
+ require 'rake/task.rb'
2
+ require 'rake/early_time'
3
+
4
+ module Rake
5
+ # #########################################################################
6
+ # A FileTask is a task that includes time based dependencies. If any of a
7
+ # FileTask's prerequisites have a timestamp that is later than the file
8
+ # represented by this task, then the file must be rebuilt (using the
9
+ # supplied actions).
10
+ #
11
+ class FileTask < Task
12
+
13
+ # Is this file task needed? Yes if it doesn't exist, or if its time stamp
14
+ # is out of date.
15
+ def needed?
16
+ ! File.exist?(name) || out_of_date?(timestamp)
17
+ end
18
+
19
+ # Time stamp for file task.
20
+ def timestamp
21
+ if File.exist?(name)
22
+ File.mtime(name.to_s)
23
+ else
24
+ Rake::EARLY
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ # Are there any prerequisites with a later time than the given time stamp?
31
+ def out_of_date?(stamp)
32
+ @prerequisites.any? { |n| application[n, @scope].timestamp > stamp}
33
+ end
34
+
35
+ # ----------------------------------------------------------------
36
+ # Task class methods.
37
+ #
38
+ class << self
39
+ # Apply the scope to the task name according to the rules for this kind
40
+ # of task. File based tasks ignore the scope when creating the name.
41
+ def scope_name(scope, task_name)
42
+ task_name
43
+ end
44
+ end
45
+ end
46
+ end
47
+
@@ -0,0 +1,112 @@
1
+ require 'rbconfig'
2
+ require 'fileutils'
3
+
4
+ # ###########################################################################
5
+ # This a FileUtils extension that defines several additional commands to be
6
+ # added to the FileUtils utility functions.
7
+ #
8
+ module FileUtils
9
+ # Path to the currently running Ruby program
10
+ RUBY = File.join(
11
+ RbConfig::CONFIG['bindir'],
12
+ RbConfig::CONFIG['ruby_install_name'] + RbConfig::CONFIG['EXEEXT']).
13
+ sub(/.*\s.*/m, '"\&"')
14
+
15
+ OPT_TABLE['sh'] = %w(noop verbose)
16
+ OPT_TABLE['ruby'] = %w(noop verbose)
17
+
18
+ # Run the system command +cmd+. If multiple arguments are given the command
19
+ # is not run with the shell (same semantics as Kernel::exec and
20
+ # Kernel::system).
21
+ #
22
+ # Example:
23
+ # sh %{ls -ltr}
24
+ #
25
+ # sh 'ls', 'file with spaces'
26
+ #
27
+ # # check exit status after command runs
28
+ # sh %{grep pattern file} do |ok, res|
29
+ # if ! ok
30
+ # puts "pattern not found (status = #{res.exitstatus})"
31
+ # end
32
+ # end
33
+ #
34
+ def sh(*cmd, &block)
35
+ options = (Hash === cmd.last) ? cmd.pop : {}
36
+ shell_runner = block_given? ? block : create_shell_runner(cmd)
37
+ set_verbose_option(options)
38
+ options[:noop] ||= Rake::FileUtilsExt.nowrite_flag
39
+ Rake.rake_check_options options, :noop, :verbose
40
+ Rake.rake_output_message cmd.join(" ") if options[:verbose]
41
+ unless options[:noop]
42
+ res = rake_system(*cmd)
43
+ status = $?
44
+ status = PseudoStatus.new(1) if !res && status.nil?
45
+ shell_runner.call(res, status)
46
+ end
47
+ end
48
+
49
+ def create_shell_runner(cmd)
50
+ show_command = cmd.join(" ")
51
+ show_command = show_command[0,42] + "..." unless $trace
52
+ lambda { |ok, status|
53
+ ok or fail "Command failed with status (#{status.exitstatus}): [#{show_command}]"
54
+ }
55
+ end
56
+ private :create_shell_runner
57
+
58
+ def set_verbose_option(options)
59
+ if options[:verbose].nil?
60
+ options[:verbose] = Rake::FileUtilsExt.verbose_flag.nil? || Rake::FileUtilsExt.verbose_flag
61
+ end
62
+ end
63
+ private :set_verbose_option
64
+
65
+ def rake_system(*cmd)
66
+ Rake::AltSystem.system(*cmd)
67
+ end
68
+ private :rake_system
69
+
70
+ # Run a Ruby interpreter with the given arguments.
71
+ #
72
+ # Example:
73
+ # ruby %{-pe '$_.upcase!' <README}
74
+ #
75
+ def ruby(*args,&block)
76
+ options = (Hash === args.last) ? args.pop : {}
77
+ if args.length > 1 then
78
+ sh(*([RUBY] + args + [options]), &block)
79
+ else
80
+ sh("#{RUBY} #{args.first}", options, &block)
81
+ end
82
+ end
83
+
84
+ LN_SUPPORTED = [true]
85
+
86
+ # Attempt to do a normal file link, but fall back to a copy if the link
87
+ # fails.
88
+ def safe_ln(*args)
89
+ unless LN_SUPPORTED[0]
90
+ cp(*args)
91
+ else
92
+ begin
93
+ ln(*args)
94
+ rescue StandardError, NotImplementedError
95
+ LN_SUPPORTED[0] = false
96
+ cp(*args)
97
+ end
98
+ end
99
+ end
100
+
101
+ # Split a file path into individual directory names.
102
+ #
103
+ # Example:
104
+ # split_all("a/b/c") => ['a', 'b', 'c']
105
+ #
106
+ def split_all(path)
107
+ head, tail = File.split(path)
108
+ return [tail] if head == '.' || tail == '/'
109
+ return [head, tail] if head == '/'
110
+ return split_all(head) + [tail]
111
+ end
112
+ end
@@ -0,0 +1,142 @@
1
+ require 'rake/file_utils'
2
+
3
+ module Rake
4
+ #
5
+ # FileUtilsExt provides a custom version of the FileUtils methods
6
+ # that respond to the <tt>verbose</tt> and <tt>nowrite</tt>
7
+ # commands.
8
+ #
9
+ module FileUtilsExt
10
+ include FileUtils
11
+
12
+ class << self
13
+ attr_accessor :verbose_flag, :nowrite_flag
14
+ end
15
+ FileUtilsExt.verbose_flag = nil
16
+ FileUtilsExt.nowrite_flag = false
17
+
18
+ $fileutils_verbose = true
19
+ $fileutils_nowrite = false
20
+
21
+ FileUtils::OPT_TABLE.each do |name, opts|
22
+ default_options = []
23
+ if opts.include?(:verbose) || opts.include?("verbose")
24
+ default_options << ':verbose => FileUtilsExt.verbose_flag'
25
+ end
26
+ if opts.include?(:noop) || opts.include?("noop")
27
+ default_options << ':noop => FileUtilsExt.nowrite_flag'
28
+ end
29
+
30
+ next if default_options.empty?
31
+ module_eval(<<-EOS, __FILE__, __LINE__ + 1)
32
+ def #{name}( *args, &block )
33
+ super(
34
+ *rake_merge_option(args,
35
+ #{default_options.join(', ')}
36
+ ), &block)
37
+ end
38
+ EOS
39
+ end
40
+
41
+ # Get/set the verbose flag controlling output from the FileUtils
42
+ # utilities. If verbose is true, then the utility method is
43
+ # echoed to standard output.
44
+ #
45
+ # Examples:
46
+ # verbose # return the current value of the
47
+ # # verbose flag
48
+ # verbose(v) # set the verbose flag to _v_.
49
+ # verbose(v) { code } # Execute code with the verbose flag set
50
+ # # temporarily to _v_. Return to the
51
+ # # original value when code is done.
52
+ def verbose(value=nil)
53
+ oldvalue = FileUtilsExt.verbose_flag
54
+ FileUtilsExt.verbose_flag = value unless value.nil?
55
+ if block_given?
56
+ begin
57
+ yield
58
+ ensure
59
+ FileUtilsExt.verbose_flag = oldvalue
60
+ end
61
+ end
62
+ FileUtilsExt.verbose_flag
63
+ end
64
+
65
+ # Get/set the nowrite flag controlling output from the FileUtils
66
+ # utilities. If verbose is true, then the utility method is
67
+ # echoed to standard output.
68
+ #
69
+ # Examples:
70
+ # nowrite # return the current value of the
71
+ # # nowrite flag
72
+ # nowrite(v) # set the nowrite flag to _v_.
73
+ # nowrite(v) { code } # Execute code with the nowrite flag set
74
+ # # temporarily to _v_. Return to the
75
+ # # original value when code is done.
76
+ def nowrite(value=nil)
77
+ oldvalue = FileUtilsExt.nowrite_flag
78
+ FileUtilsExt.nowrite_flag = value unless value.nil?
79
+ if block_given?
80
+ begin
81
+ yield
82
+ ensure
83
+ FileUtilsExt.nowrite_flag = oldvalue
84
+ end
85
+ end
86
+ oldvalue
87
+ end
88
+
89
+ # Use this function to prevent potentially destructive ruby code
90
+ # from running when the :nowrite flag is set.
91
+ #
92
+ # Example:
93
+ #
94
+ # when_writing("Building Project") do
95
+ # project.build
96
+ # end
97
+ #
98
+ # The following code will build the project under normal
99
+ # conditions. If the nowrite(true) flag is set, then the example
100
+ # will print:
101
+ #
102
+ # DRYRUN: Building Project
103
+ #
104
+ # instead of actually building the project.
105
+ #
106
+ def when_writing(msg=nil)
107
+ if FileUtilsExt.nowrite_flag
108
+ $stderr.puts "DRYRUN: #{msg}" if msg
109
+ else
110
+ yield
111
+ end
112
+ end
113
+
114
+ # Merge the given options with the default values.
115
+ def rake_merge_option(args, defaults)
116
+ if Hash === args.last
117
+ defaults.update(args.last)
118
+ args.pop
119
+ end
120
+ args.push defaults
121
+ args
122
+ end
123
+
124
+ # Send the message to the default rake output (which is $stderr).
125
+ def rake_output_message(message)
126
+ $stderr.puts(message)
127
+ end
128
+
129
+ # Check that the options do not contain options not listed in
130
+ # +optdecl+. An ArgumentError exception is thrown if non-declared
131
+ # options are found.
132
+ def rake_check_options(options, *optdecl)
133
+ h = options.dup
134
+ optdecl.each do |name|
135
+ h.delete name
136
+ end
137
+ raise ArgumentError, "no such option: #{h.keys.join(' ')}" unless h.empty?
138
+ end
139
+
140
+ extend self
141
+ end
142
+ end
@@ -1,97 +1,13 @@
1
- #!/usr/bin/env ruby
1
+ # rake/gempackagetask is deprecated in favor of rubygems/package_task
2
2
 
3
- # Define a package task library to aid in the definition of GEM
4
- # packages.
3
+ warn 'rake/gempackagetask is deprecated. Use rubygems/package_task instead'
5
4
 
6
5
  require 'rubygems'
6
+ require 'rubygems/package_task'
7
+
7
8
  require 'rake'
8
- require 'rake/packagetask'
9
- require 'rubygems/user_interaction'
10
- require 'rubygems/builder'
11
9
 
12
10
  module Rake
13
-
14
- # Create a package based upon a Gem spec. Gem packages, as well as
15
- # zip files and tar/gzipped packages can be produced by this task.
16
- #
17
- # In addition to the Rake targets generated by PackageTask, a
18
- # GemPackageTask will also generate the following tasks:
19
- #
20
- # [<b>"<em>package_dir</em>/<em>name</em>-<em>version</em>.gem"</b>]
21
- # Create a Ruby GEM package with the given name and version.
22
- #
23
- # Example using a Ruby GEM spec:
24
- #
25
- # require 'rubygems'
26
- #
27
- # spec = Gem::Specification.new do |s|
28
- # s.platform = Gem::Platform::RUBY
29
- # s.summary = "Ruby based make-like utility."
30
- # s.name = 'rake'
31
- # s.version = PKG_VERSION
32
- # s.requirements << 'none'
33
- # s.require_path = 'lib'
34
- # s.autorequire = 'rake'
35
- # s.files = PKG_FILES
36
- # s.description = <<EOF
37
- # Rake is a Make-like program implemented in Ruby. Tasks
38
- # and dependencies are specified in standard Ruby syntax.
39
- # EOF
40
- # end
41
- #
42
- # Rake::GemPackageTask.new(spec) do |pkg|
43
- # pkg.need_zip = true
44
- # pkg.need_tar = true
45
- # end
46
- #
47
- class GemPackageTask < PackageTask
48
- # Ruby GEM spec containing the metadata for this package. The
49
- # name, version and package_files are automatically determined
50
- # from the GEM spec and don't need to be explicitly provided.
51
- attr_accessor :gem_spec
52
-
53
- # Create a GEM Package task library. Automatically define the gem
54
- # if a block is given. If no block is supplied, then +define+
55
- # needs to be called to define the task.
56
- def initialize(gem_spec)
57
- init(gem_spec)
58
- yield self if block_given?
59
- define if block_given?
60
- end
61
-
62
- # Initialization tasks without the "yield self" or define
63
- # operations.
64
- def init(gem)
65
- super(gem.name, gem.version)
66
- @gem_spec = gem
67
- @package_files += gem_spec.files if gem_spec.files
68
- end
69
-
70
- # Create the Rake tasks and actions specified by this
71
- # GemPackageTask. (+define+ is automatically called if a block is
72
- # given to +new+).
73
- def define
74
- super
75
- task :package => [:gem]
76
- desc "Build the gem file #{gem_file}"
77
- task :gem => ["#{package_dir}/#{gem_file}"]
78
- file "#{package_dir}/#{gem_file}" => [package_dir] + @gem_spec.files do
79
- when_writing("Creating GEM") {
80
- Gem::Builder.new(gem_spec).build
81
- verbose(true) {
82
- mv gem_file, "#{package_dir}/#{gem_file}"
83
- }
84
- }
85
- end
86
- end
87
-
88
- def gem_file
89
- if @gem_spec.platform == Gem::Platform::RUBY
90
- "#{package_name}.gem"
91
- else
92
- "#{package_name}-#{@gem_spec.platform}.gem"
93
- end
94
- end
95
-
96
- end
11
+ GemPackageTask = Gem::PackageTask
97
12
  end
13
+
@@ -0,0 +1,51 @@
1
+ module Rake
2
+
3
+ ####################################################################
4
+ # InvocationChain tracks the chain of task invocations to detect
5
+ # circular dependencies.
6
+ class InvocationChain
7
+ def initialize(value, tail)
8
+ @value = value
9
+ @tail = tail
10
+ end
11
+
12
+ def member?(obj)
13
+ @value == obj || @tail.member?(obj)
14
+ end
15
+
16
+ def append(value)
17
+ if member?(value)
18
+ fail RuntimeError, "Circular dependency detected: #{to_s} => #{value}"
19
+ end
20
+ self.class.new(value, self)
21
+ end
22
+
23
+ def to_s
24
+ "#{prefix}#{@value}"
25
+ end
26
+
27
+ def self.append(value, chain)
28
+ chain.append(value)
29
+ end
30
+
31
+ private
32
+
33
+ def prefix
34
+ "#{@tail.to_s} => "
35
+ end
36
+
37
+ class EmptyInvocationChain
38
+ def member?(obj)
39
+ false
40
+ end
41
+ def append(value)
42
+ InvocationChain.new(value, self)
43
+ end
44
+ def to_s
45
+ "TOP"
46
+ end
47
+ end
48
+
49
+ EMPTY = EmptyInvocationChain.new
50
+ end
51
+ end