rake 0.9.2 → 13.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (170) hide show
  1. checksums.yaml +7 -0
  2. data/CONTRIBUTING.rdoc +43 -0
  3. data/Gemfile +10 -0
  4. data/History.rdoc +2386 -0
  5. data/MIT-LICENSE +1 -1
  6. data/README.rdoc +64 -109
  7. data/Rakefile +22 -386
  8. data/bin/bundle +105 -0
  9. data/bin/console +7 -0
  10. data/bin/rake +20 -23
  11. data/bin/rdoc +29 -0
  12. data/bin/rubocop +29 -0
  13. data/bin/setup +6 -0
  14. data/doc/command_line_usage.rdoc +65 -21
  15. data/doc/glossary.rdoc +40 -49
  16. data/doc/jamis.rb +1 -0
  17. data/doc/rake.1 +156 -0
  18. data/doc/rakefile.rdoc +127 -62
  19. data/exe/rake +27 -0
  20. data/lib/rake.rb +37 -31
  21. data/lib/rake/application.rb +507 -272
  22. data/lib/rake/backtrace.rb +24 -0
  23. data/lib/rake/clean.rb +55 -8
  24. data/lib/rake/cloneable.rb +11 -19
  25. data/lib/rake/cpu_counter.rb +107 -0
  26. data/lib/rake/default_loader.rb +5 -0
  27. data/lib/rake/dsl_definition.rb +74 -46
  28. data/lib/rake/early_time.rb +5 -1
  29. data/lib/rake/ext/core.rb +5 -6
  30. data/lib/rake/ext/string.rb +61 -52
  31. data/lib/rake/file_creation_task.rb +4 -3
  32. data/lib/rake/file_list.rb +81 -49
  33. data/lib/rake/file_task.rb +15 -8
  34. data/lib/rake/file_utils.rb +69 -47
  35. data/lib/rake/file_utils_ext.rb +18 -26
  36. data/lib/rake/invocation_chain.rb +25 -19
  37. data/lib/rake/invocation_exception_mixin.rb +1 -0
  38. data/lib/rake/late_time.rb +18 -0
  39. data/lib/rake/linked_list.rb +112 -0
  40. data/lib/rake/loaders/makefile.rb +23 -9
  41. data/lib/rake/multi_task.rb +4 -6
  42. data/lib/rake/name_space.rb +36 -23
  43. data/lib/rake/packagetask.rb +71 -34
  44. data/lib/rake/phony.rb +16 -0
  45. data/lib/rake/private_reader.rb +21 -0
  46. data/lib/rake/promise.rb +100 -0
  47. data/lib/rake/pseudo_status.rb +8 -2
  48. data/lib/rake/rake_module.rb +41 -3
  49. data/lib/rake/rake_test_loader.rb +21 -7
  50. data/lib/rake/rule_recursion_overflow_error.rb +2 -2
  51. data/lib/rake/scope.rb +43 -0
  52. data/lib/rake/task.rb +186 -79
  53. data/lib/rake/task_argument_error.rb +1 -0
  54. data/lib/rake/task_arguments.rb +50 -15
  55. data/lib/rake/task_manager.rb +89 -65
  56. data/lib/rake/tasklib.rb +2 -12
  57. data/lib/rake/testtask.rb +61 -63
  58. data/lib/rake/thread_history_display.rb +49 -0
  59. data/lib/rake/thread_pool.rb +163 -0
  60. data/lib/rake/trace_output.rb +23 -0
  61. data/lib/rake/version.rb +7 -7
  62. data/lib/rake/win32.rb +14 -18
  63. data/rake.gemspec +43 -0
  64. metadata +82 -221
  65. data/.gemtest +0 -0
  66. data/CHANGES +0 -509
  67. data/RRR +0 -9
  68. data/TODO +0 -20
  69. data/doc/rake.1.gz +0 -0
  70. data/doc/release_notes/rake-0.4.14.rdoc +0 -23
  71. data/doc/release_notes/rake-0.4.15.rdoc +0 -35
  72. data/doc/release_notes/rake-0.5.0.rdoc +0 -53
  73. data/doc/release_notes/rake-0.5.3.rdoc +0 -78
  74. data/doc/release_notes/rake-0.5.4.rdoc +0 -46
  75. data/doc/release_notes/rake-0.6.0.rdoc +0 -141
  76. data/doc/release_notes/rake-0.7.0.rdoc +0 -119
  77. data/doc/release_notes/rake-0.7.1.rdoc +0 -59
  78. data/doc/release_notes/rake-0.7.2.rdoc +0 -121
  79. data/doc/release_notes/rake-0.7.3.rdoc +0 -47
  80. data/doc/release_notes/rake-0.8.0.rdoc +0 -114
  81. data/doc/release_notes/rake-0.8.2.rdoc +0 -165
  82. data/doc/release_notes/rake-0.8.3.rdoc +0 -112
  83. data/doc/release_notes/rake-0.8.4.rdoc +0 -147
  84. data/doc/release_notes/rake-0.8.5.rdoc +0 -53
  85. data/doc/release_notes/rake-0.8.6.rdoc +0 -55
  86. data/doc/release_notes/rake-0.8.7.rdoc +0 -55
  87. data/doc/release_notes/rake-0.9.0.rdoc +0 -112
  88. data/doc/release_notes/rake-0.9.1.rdoc +0 -52
  89. data/doc/release_notes/rake-0.9.2.rdoc +0 -49
  90. data/install.rb +0 -90
  91. data/lib/rake/alt_system.rb +0 -109
  92. data/lib/rake/classic_namespace.rb +0 -9
  93. data/lib/rake/contrib/compositepublisher.rb +0 -21
  94. data/lib/rake/contrib/ftptools.rb +0 -150
  95. data/lib/rake/contrib/publisher.rb +0 -69
  96. data/lib/rake/contrib/rubyforgepublisher.rb +0 -16
  97. data/lib/rake/contrib/sshpublisher.rb +0 -45
  98. data/lib/rake/contrib/sys.rb +0 -191
  99. data/lib/rake/ext/module.rb +0 -39
  100. data/lib/rake/ext/time.rb +0 -14
  101. data/lib/rake/gempackagetask.rb +0 -13
  102. data/lib/rake/pathmap.rb +0 -1
  103. data/lib/rake/rdoctask.rb +0 -230
  104. data/lib/rake/ruby182_test_unit_fix.rb +0 -25
  105. data/lib/rake/runtest.rb +0 -21
  106. data/test/check_expansion.rb +0 -5
  107. data/test/check_no_expansion.rb +0 -5
  108. data/test/data/access/Rakefile +0 -35
  109. data/test/data/chains/Rakefile +0 -15
  110. data/test/data/comments/Rakefile +0 -18
  111. data/test/data/default/Rakefile +0 -17
  112. data/test/data/deprecated_import/Rakefile +0 -1
  113. data/test/data/dryrun/Rakefile +0 -22
  114. data/test/data/extra/Rakefile +0 -1
  115. data/test/data/file_creation_task/Rakefile +0 -31
  116. data/test/data/imports/Rakefile +0 -19
  117. data/test/data/imports/deps.mf +0 -1
  118. data/test/data/multidesc/Rakefile +0 -15
  119. data/test/data/namespace/Rakefile +0 -64
  120. data/test/data/rakelib/test1.rb +0 -4
  121. data/test/data/rbext/rakefile.rb +0 -3
  122. data/test/data/sample.mf +0 -14
  123. data/test/data/statusreturn/Rakefile +0 -6
  124. data/test/data/unittest/Rakefile +0 -1
  125. data/test/data/verbose/Rakefile +0 -34
  126. data/test/file_creation.rb +0 -34
  127. data/test/helper.rb +0 -44
  128. data/test/in_environment.rb +0 -35
  129. data/test/reqfile.rb +0 -3
  130. data/test/reqfile2.rb +0 -3
  131. data/test/shellcommand.rb +0 -3
  132. data/test/test_rake.rb +0 -38
  133. data/test/test_rake_application.rb +0 -364
  134. data/test/test_rake_application_options.rb +0 -382
  135. data/test/test_rake_clean.rb +0 -12
  136. data/test/test_rake_definitions.rb +0 -80
  137. data/test/test_rake_directory_task.rb +0 -55
  138. data/test/test_rake_dsl.rb +0 -73
  139. data/test/test_rake_early_time.rb +0 -31
  140. data/test/test_rake_extension.rb +0 -59
  141. data/test/test_rake_file_creation_task.rb +0 -62
  142. data/test/test_rake_file_list.rb +0 -633
  143. data/test/test_rake_file_list_path_map.rb +0 -8
  144. data/test/test_rake_file_task.rb +0 -104
  145. data/test/test_rake_file_utils.rb +0 -252
  146. data/test/test_rake_ftp_file.rb +0 -59
  147. data/test/test_rake_functional.rb +0 -468
  148. data/test/test_rake_invocation_chain.rb +0 -52
  149. data/test/test_rake_makefile_loader.rb +0 -23
  150. data/test/test_rake_multi_task.rb +0 -51
  151. data/test/test_rake_name_space.rb +0 -43
  152. data/test/test_rake_package_task.rb +0 -78
  153. data/test/test_rake_path_map.rb +0 -157
  154. data/test/test_rake_path_map_explode.rb +0 -31
  155. data/test/test_rake_path_map_partial.rb +0 -18
  156. data/test/test_rake_pseudo_status.rb +0 -20
  157. data/test/test_rake_rdoc_task.rb +0 -81
  158. data/test/test_rake_require.rb +0 -35
  159. data/test/test_rake_rules.rb +0 -346
  160. data/test/test_rake_task.rb +0 -271
  161. data/test/test_rake_task_argument_parsing.rb +0 -116
  162. data/test/test_rake_task_arguments.rb +0 -86
  163. data/test/test_rake_task_lib.rb +0 -9
  164. data/test/test_rake_task_manager.rb +0 -145
  165. data/test/test_rake_task_manager_argument_resolution.rb +0 -36
  166. data/test/test_rake_task_with_arguments.rb +0 -162
  167. data/test/test_rake_test_task.rb +0 -122
  168. data/test/test_rake_top_level_functions.rb +0 -76
  169. data/test/test_rake_win32.rb +0 -83
  170. data/test/test_sys.rb +0 -20
@@ -1,52 +0,0 @@
1
- = Rake 0.9.1 Released
2
-
3
- Rake version 0.9.1 has a number of bug fixes and enhancments (see
4
- below for more details). Additionally, the internals have be slightly
5
- restructured and improved.
6
-
7
- == Changes
8
-
9
- Rake 0.9.1 adds back the global DSL methods, but with deprecation
10
- messages. This allows Rake 0.9.1 to be used with older rakefiles with
11
- warning messages.
12
-
13
- == What is Rake
14
-
15
- Rake is a build tool similar to the make program in many ways. But
16
- instead of cryptic make recipes, Rake uses standard Ruby code to
17
- declare tasks and dependencies. You have the full power of a modern
18
- scripting language built right into your build tool.
19
-
20
- == Availability
21
-
22
- The easiest way to get and install rake is via RubyGems ...
23
-
24
- gem install rake (you may need root/admin privileges)
25
-
26
- Otherwise, you can get it from the more traditional places:
27
-
28
- Home Page:: http://rake.rubyforge.org/
29
- Download:: http://rubyforge.org/project/showfiles.php?group_id=50
30
- GitHub:: git://github.com/jimweirich/rake.git
31
-
32
- == Thanks
33
-
34
- As usual, it was input from users that drove a alot of these changes. The
35
- following people either contributed patches, made suggestions or made
36
- otherwise helpful comments. Thanks to ...
37
-
38
- * James M. Lawrence (quix)
39
- * Roger Pack
40
- * Cezary Baginski
41
- * Sean Scot August Moon
42
- * R.T. Lechow
43
- * Alex Chaffee
44
- * James Tucker
45
- * Matthias Lüdtke
46
- * Santiago Pastorino
47
-
48
- Also, bit thanks to Eric Hodel for assisting with getting this release
49
- out the door (where "assisting" includes, but is not by any means
50
- limited to, "pushing" me to get it done).
51
-
52
- -- Jim Weirich
@@ -1,49 +0,0 @@
1
- = Rake 0.9.2 Released
2
-
3
- Rake version 0.9.2 has a few small fixes. See below for details.
4
-
5
- == Changes
6
-
7
- * Support for Ruby 1.8.6 was fixed.
8
- * Global DSL warnings now honor --no-deprecate
9
-
10
- == What is Rake
11
-
12
- Rake is a build tool similar to the make program in many ways. But
13
- instead of cryptic make recipes, Rake uses standard Ruby code to
14
- declare tasks and dependencies. You have the full power of a modern
15
- scripting language built right into your build tool.
16
-
17
- == Availability
18
-
19
- The easiest way to get and install rake is via RubyGems ...
20
-
21
- gem install rake (you may need root/admin privileges)
22
-
23
- Otherwise, you can get it from the more traditional places:
24
-
25
- Home Page:: http://rake.rubyforge.org/
26
- Download:: http://rubyforge.org/project/showfiles.php?group_id=50
27
- GitHub:: git://github.com/jimweirich/rake.git
28
-
29
- == Thanks
30
-
31
- As usual, it was input from users that drove a alot of these changes. The
32
- following people either contributed patches, made suggestions or made
33
- otherwise helpful comments. Thanks to ...
34
-
35
- * James M. Lawrence (quix)
36
- * Roger Pack
37
- * Cezary Baginski
38
- * Sean Scot August Moon
39
- * R.T. Lechow
40
- * Alex Chaffee
41
- * James Tucker
42
- * Matthias Lüdtke
43
- * Santiago Pastorino
44
-
45
- Also, bit thanks to Eric Hodel for assisting with getting this release
46
- out the door (where "assisting" includes, but is not by any means
47
- limited to, "pushing" me to get it done).
48
-
49
- -- Jim Weirich
data/install.rb DELETED
@@ -1,90 +0,0 @@
1
- require 'rbconfig'
2
- require 'find'
3
- require 'fileutils'
4
-
5
- include RbConfig
6
-
7
- $ruby = CONFIG['ruby_install_name']
8
-
9
- ##
10
- # Install a binary file. We patch in on the way through to
11
- # insert a #! line. If this is a Unix install, we name
12
- # the command (for example) 'rake' and let the shebang line
13
- # handle running it. Under windows, we add a '.rb' extension
14
- # and let file associations to their stuff
15
- #
16
-
17
- def installBIN(from, opfile)
18
-
19
- tmp_dir = nil
20
- for t in [".", "/tmp", "c:/temp", $bindir]
21
- stat = File.stat(t) rescue next
22
- if stat.directory? and stat.writable?
23
- tmp_dir = t
24
- break
25
- end
26
- end
27
-
28
- fail "Cannot find a temporary directory" unless tmp_dir
29
- tmp_file = File.join(tmp_dir, "_tmp")
30
-
31
- File.open(from) do |ip|
32
- File.open(tmp_file, "w") do |op|
33
- ruby = File.join($realbindir, $ruby)
34
- op.puts "#!#{ruby} -w"
35
- op.write ip.read
36
- end
37
- end
38
-
39
- opfile += ".rb" if CONFIG["target_os"] =~ /mswin/i
40
- FileUtils.install(tmp_file, File.join($bindir, opfile),
41
- {:mode => 0755, :verbose => true})
42
- File.unlink(tmp_file)
43
- end
44
-
45
- $sitedir = CONFIG["sitelibdir"]
46
- unless $sitedir
47
- version = CONFIG["MAJOR"]+"."+CONFIG["MINOR"]
48
- $libdir = File.join(CONFIG["libdir"], "ruby", version)
49
- $sitedir = $:.find {|x| x =~ /site_ruby/}
50
- if !$sitedir
51
- $sitedir = File.join($libdir, "site_ruby")
52
- elsif $sitedir !~ Regexp.quote(version)
53
- $sitedir = File.join($sitedir, version)
54
- end
55
- end
56
-
57
- $bindir = CONFIG["bindir"]
58
-
59
- $realbindir = $bindir
60
-
61
- bindir = CONFIG["bindir"]
62
- if (destdir = ENV['DESTDIR'])
63
- $bindir = destdir + $bindir
64
- $sitedir = destdir + $sitedir
65
-
66
- FileUtils.mkdir_p($bindir)
67
- FileUtils.mkdir_p($sitedir)
68
- end
69
-
70
- rake_dest = File.join($sitedir, "rake")
71
- FileUtils.mkdir_p(rake_dest, {:verbose => true})
72
- File.chmod(0755, rake_dest)
73
-
74
- # The library files
75
-
76
- files = Dir.chdir('lib') { Dir['**/*.rb'] }
77
-
78
- for fn in files
79
- fn_dir = File.dirname(fn)
80
- target_dir = File.join($sitedir, fn_dir)
81
- if ! File.exist?(target_dir)
82
- FileUtils.mkdir_p(target_dir)
83
- end
84
- FileUtils.install(File.join('lib', fn), File.join($sitedir, fn),
85
- {:mode => 0644, :verbose => true})
86
- end
87
-
88
- # and the executable
89
-
90
- installBIN("bin/rake", "rake")
@@ -1,109 +0,0 @@
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 = RbConfig::CONFIG["host_os"] =~
33
- %r!(msdos|mswin|djgpp|mingw|[Ww]indows)!
34
-
35
- class << self
36
- def define_module_function(name, &block)
37
- define_method(name, &block)
38
- module_function(name)
39
- end
40
- end
41
-
42
- if WINDOWS and RUBY_VERSION < "1.9.0"
43
- RUNNABLE_EXTS = %w[com exe bat cmd]
44
- RUNNABLE_PATTERN = %r!\.(#{RUNNABLE_EXTS.join('|')})\Z!i
45
-
46
- define_module_function :kernel_system, &Kernel.method(:system)
47
- define_module_function :kernel_backticks, &Kernel.method(:'`')
48
-
49
- module_function
50
-
51
- def repair_command(cmd)
52
- "call " + (
53
- if cmd =~ %r!\A\s*\".*?\"!
54
- # already quoted
55
- cmd
56
- elsif match = cmd.match(%r!\A\s*(\S+)!)
57
- if match[1] =~ %r!/!
58
- # avoid x/y.bat interpretation as x with option /y
59
- %Q!"#{match[1]}"! + match.post_match
60
- else
61
- # a shell command will fail if quoted
62
- cmd
63
- end
64
- else
65
- # empty or whitespace
66
- cmd
67
- end
68
- )
69
- end
70
-
71
- def find_runnable(file)
72
- if file =~ RUNNABLE_PATTERN
73
- file
74
- else
75
- RUNNABLE_EXTS.each { |ext|
76
- if File.exist?(test = "#{file}.#{ext}")
77
- return test
78
- end
79
- }
80
- nil
81
- end
82
- end
83
-
84
- def system(cmd, *args)
85
- repaired = (
86
- if args.empty?
87
- [repair_command(cmd)]
88
- elsif runnable = find_runnable(cmd)
89
- [File.expand_path(runnable), *args]
90
- else
91
- # non-existent file
92
- [cmd, *args]
93
- end
94
- )
95
- kernel_system(*repaired)
96
- end
97
-
98
- def backticks(cmd)
99
- kernel_backticks(repair_command(cmd))
100
- end
101
-
102
- define_module_function :'`', &method(:backticks)
103
- else
104
- # Non-Windows or ruby-1.9+: same as Kernel versions
105
- define_module_function :system, &Kernel.method(:system)
106
- define_module_function :backticks, &Kernel.method(:'`')
107
- define_module_function :'`', &Kernel.method(:'`')
108
- end
109
- end
@@ -1,9 +0,0 @@
1
- # The following classes used to be in the top level namespace.
2
- # Loading this file enables compatibility with older Rakefile that
3
- # referenced Task from the top level.
4
-
5
- warn "WARNING: Classic namespaces are deprecated and will be removed from future versions of Rake."
6
- Task = Rake::Task
7
- FileTask = Rake::FileTask
8
- FileCreationTask = Rake::FileCreationTask
9
- RakeApp = Rake::Application
@@ -1,21 +0,0 @@
1
- module Rake
2
-
3
- # Manage several publishers as a single entity.
4
- class CompositePublisher
5
- def initialize
6
- @publishers = []
7
- end
8
-
9
- # Add a publisher to the composite.
10
- def add(pub)
11
- @publishers << pub
12
- end
13
-
14
- # Upload all the individual publishers.
15
- def upload
16
- @publishers.each { |p| p.upload }
17
- end
18
- end
19
-
20
- end
21
-
@@ -1,150 +0,0 @@
1
- # = Tools for FTP uploading.
2
- #
3
- # This file is still under development and is not released for general
4
- # use.
5
-
6
- require 'date'
7
- require 'net/ftp'
8
-
9
- module Rake # :nodoc:
10
-
11
- ####################################################################
12
- # <b>Note:</b> <em> Not released for general use.</em>
13
- class FtpFile
14
- attr_reader :name, :size, :owner, :group, :time
15
-
16
- def self.date
17
- @date_class ||= Date
18
- end
19
-
20
- def self.time
21
- @time_class ||= Time
22
- end
23
-
24
- def initialize(path, entry)
25
- @path = path
26
- @mode, _, @owner, @group, size, d1, d2, d3, @name = entry.split(' ')
27
- @size = size.to_i
28
- @time = determine_time(d1, d2, d3)
29
- end
30
-
31
- def path
32
- File.join(@path, @name)
33
- end
34
-
35
- def directory?
36
- @mode[0] == ?d
37
- end
38
-
39
- def mode
40
- parse_mode(@mode)
41
- end
42
-
43
- def symlink?
44
- @mode[0] == ?l
45
- end
46
-
47
- private # --------------------------------------------------------
48
-
49
- def parse_mode(m)
50
- result = 0
51
- (1..9).each do |i|
52
- result = 2*result + ((m[i]==?-) ? 0 : 1)
53
- end
54
- result
55
- end
56
-
57
- def determine_time(d1, d2, d3)
58
- now = self.class.time.now
59
- if /:/ =~ d3
60
- result = Time.parse("#{d1} #{d2} #{now.year} #{d3}")
61
- if result > now
62
- result = Time.parse("#{d1} #{d2} #{now.year-1} #{d3}")
63
- end
64
- else
65
- result = Time.parse("#{d1} #{d2} #{d3}")
66
- end
67
- result
68
- # elements = ParseDate.parsedate("#{d1} #{d2} #{d3}")
69
- # if elements[0].nil?
70
- # today = self.class.date.today
71
- # if elements[1] > today.month
72
- # elements[0] = today.year - 1
73
- # else
74
- # elements[0] = today.year
75
- # end
76
- # end
77
- # elements = elements.collect { |el| el.nil? ? 0 : el }
78
- # Time.mktime(*elements[0,7])
79
- end
80
- end
81
-
82
- ####################################################################
83
- # Manage the uploading of files to an FTP account.
84
- class FtpUploader
85
-
86
- # Log uploads to standard output when true.
87
- attr_accessor :verbose
88
-
89
- class << FtpUploader
90
- # Create an uploader and pass it to the given block as +up+.
91
- # When the block is complete, close the uploader.
92
- def connect(path, host, account, password)
93
- up = self.new(path, host, account, password)
94
- begin
95
- yield(up)
96
- ensure
97
- up.close
98
- end
99
- end
100
- end
101
-
102
- # Create an FTP uploader targeting the directory +path+ on +host+
103
- # using the given account and password. +path+ will be the root
104
- # path of the uploader.
105
- def initialize(path, host, account, password)
106
- @created = Hash.new
107
- @path = path
108
- @ftp = Net::FTP.new(host, account, password)
109
- makedirs(@path)
110
- @ftp.chdir(@path)
111
- end
112
-
113
- # Create the directory +path+ in the uploader root path.
114
- def makedirs(path)
115
- route = []
116
- File.split(path).each do |dir|
117
- route << dir
118
- current_dir = File.join(route)
119
- if @created[current_dir].nil?
120
- @created[current_dir] = true
121
- $stderr.puts "Creating Directory #{current_dir}" if @verbose
122
- @ftp.mkdir(current_dir) rescue nil
123
- end
124
- end
125
- end
126
-
127
- # Upload all files matching +wildcard+ to the uploader's root
128
- # path.
129
- def upload_files(wildcard)
130
- Dir[wildcard].each do |fn|
131
- upload(fn)
132
- end
133
- end
134
-
135
- # Close the uploader.
136
- def close
137
- @ftp.close
138
- end
139
-
140
- private # --------------------------------------------------------
141
-
142
- # Upload a single file to the uploader's root path.
143
- def upload(file)
144
- $stderr.puts "Uploading #{file}" if @verbose
145
- dir = File.dirname(file)
146
- makedirs(dir)
147
- @ftp.putbinaryfile(file, file) unless File.directory?(file)
148
- end
149
- end
150
- end