rake 10.5.0 → 13.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (166) hide show
  1. checksums.yaml +5 -5
  2. data/CONTRIBUTING.rdoc +13 -8
  3. data/Gemfile +10 -0
  4. data/History.rdoc +2015 -288
  5. data/README.rdoc +40 -24
  6. data/Rakefile +25 -65
  7. data/bin/bundle +105 -0
  8. data/bin/console +7 -0
  9. data/bin/rake +20 -24
  10. data/bin/rdoc +29 -0
  11. data/bin/rubocop +29 -0
  12. data/bin/setup +6 -0
  13. data/doc/jamis.rb +1 -0
  14. data/doc/rake.1 +139 -124
  15. data/doc/rakefile.rdoc +2 -4
  16. data/exe/rake +27 -0
  17. data/lib/rake.rb +35 -43
  18. data/lib/rake/application.rb +124 -90
  19. data/lib/rake/backtrace.rb +3 -2
  20. data/lib/rake/clean.rb +7 -5
  21. data/lib/rake/cloneable.rb +1 -0
  22. data/lib/rake/cpu_counter.rb +10 -28
  23. data/lib/rake/default_loader.rb +1 -0
  24. data/lib/rake/dsl_definition.rb +5 -11
  25. data/lib/rake/early_time.rb +1 -0
  26. data/lib/rake/ext/core.rb +1 -0
  27. data/lib/rake/ext/string.rb +22 -21
  28. data/lib/rake/file_creation_task.rb +4 -3
  29. data/lib/rake/file_list.rb +34 -27
  30. data/lib/rake/file_task.rb +12 -4
  31. data/lib/rake/file_utils.rb +38 -32
  32. data/lib/rake/file_utils_ext.rb +8 -18
  33. data/lib/rake/invocation_chain.rb +1 -0
  34. data/lib/rake/invocation_exception_mixin.rb +1 -0
  35. data/lib/rake/late_time.rb +2 -1
  36. data/lib/rake/linked_list.rb +24 -15
  37. data/lib/rake/loaders/makefile.rb +5 -4
  38. data/lib/rake/multi_task.rb +2 -1
  39. data/lib/rake/name_space.rb +1 -1
  40. data/lib/rake/packagetask.rb +40 -17
  41. data/lib/rake/phony.rb +2 -1
  42. data/lib/rake/private_reader.rb +1 -0
  43. data/lib/rake/promise.rb +13 -12
  44. data/lib/rake/pseudo_status.rb +1 -0
  45. data/lib/rake/rake_module.rb +30 -1
  46. data/lib/rake/rake_test_loader.rb +18 -13
  47. data/lib/rake/rule_recursion_overflow_error.rb +2 -2
  48. data/lib/rake/scope.rb +3 -2
  49. data/lib/rake/task.rb +82 -31
  50. data/lib/rake/task_argument_error.rb +1 -0
  51. data/lib/rake/task_arguments.rb +15 -4
  52. data/lib/rake/task_manager.rb +54 -30
  53. data/lib/rake/tasklib.rb +2 -14
  54. data/lib/rake/testtask.rb +37 -61
  55. data/lib/rake/thread_history_display.rb +4 -3
  56. data/lib/rake/thread_pool.rb +16 -17
  57. data/lib/rake/trace_output.rb +2 -1
  58. data/lib/rake/version.rb +4 -1
  59. data/lib/rake/win32.rb +10 -15
  60. data/rake.gemspec +43 -0
  61. metadata +32 -219
  62. data/.autotest +0 -7
  63. data/.rubocop.yml +0 -27
  64. data/.togglerc +0 -7
  65. data/Manifest.txt +0 -166
  66. data/doc/release_notes/rake-0.4.14.rdoc +0 -23
  67. data/doc/release_notes/rake-0.4.15.rdoc +0 -35
  68. data/doc/release_notes/rake-0.5.0.rdoc +0 -53
  69. data/doc/release_notes/rake-0.5.3.rdoc +0 -78
  70. data/doc/release_notes/rake-0.5.4.rdoc +0 -46
  71. data/doc/release_notes/rake-0.6.0.rdoc +0 -141
  72. data/doc/release_notes/rake-0.7.0.rdoc +0 -119
  73. data/doc/release_notes/rake-0.7.1.rdoc +0 -59
  74. data/doc/release_notes/rake-0.7.2.rdoc +0 -121
  75. data/doc/release_notes/rake-0.7.3.rdoc +0 -47
  76. data/doc/release_notes/rake-0.8.0.rdoc +0 -114
  77. data/doc/release_notes/rake-0.8.2.rdoc +0 -165
  78. data/doc/release_notes/rake-0.8.3.rdoc +0 -112
  79. data/doc/release_notes/rake-0.8.4.rdoc +0 -147
  80. data/doc/release_notes/rake-0.8.5.rdoc +0 -53
  81. data/doc/release_notes/rake-0.8.6.rdoc +0 -37
  82. data/doc/release_notes/rake-0.8.7.rdoc +0 -55
  83. data/doc/release_notes/rake-0.9.0.rdoc +0 -112
  84. data/doc/release_notes/rake-0.9.1.rdoc +0 -52
  85. data/doc/release_notes/rake-0.9.2.2.rdoc +0 -55
  86. data/doc/release_notes/rake-0.9.2.rdoc +0 -49
  87. data/doc/release_notes/rake-0.9.3.rdoc +0 -102
  88. data/doc/release_notes/rake-0.9.4.rdoc +0 -60
  89. data/doc/release_notes/rake-0.9.5.rdoc +0 -55
  90. data/doc/release_notes/rake-0.9.6.rdoc +0 -64
  91. data/doc/release_notes/rake-10.0.0.rdoc +0 -178
  92. data/doc/release_notes/rake-10.0.1.rdoc +0 -58
  93. data/doc/release_notes/rake-10.0.2.rdoc +0 -53
  94. data/doc/release_notes/rake-10.0.3.rdoc +0 -191
  95. data/doc/release_notes/rake-10.1.0.rdoc +0 -61
  96. data/lib/rake/alt_system.rb +0 -110
  97. data/lib/rake/contrib/.document +0 -1
  98. data/lib/rake/contrib/compositepublisher.rb +0 -21
  99. data/lib/rake/contrib/ftptools.rb +0 -137
  100. data/lib/rake/contrib/publisher.rb +0 -81
  101. data/lib/rake/contrib/rubyforgepublisher.rb +0 -18
  102. data/lib/rake/contrib/sshpublisher.rb +0 -61
  103. data/lib/rake/contrib/sys.rb +0 -4
  104. data/lib/rake/ext/module.rb +0 -2
  105. data/lib/rake/ext/pathname.rb +0 -25
  106. data/lib/rake/ext/time.rb +0 -18
  107. data/lib/rake/gempackagetask.rb +0 -4
  108. data/lib/rake/pathmap.rb +0 -3
  109. data/lib/rake/rdoctask.rb +0 -4
  110. data/lib/rake/ruby182_test_unit_fix.rb +0 -29
  111. data/lib/rake/runtest.rb +0 -27
  112. data/rakelib/publish.rake +0 -20
  113. data/rakelib/test_times.rake +0 -25
  114. data/test/file_creation.rb +0 -34
  115. data/test/helper.rb +0 -129
  116. data/test/support/rakefile_definitions.rb +0 -478
  117. data/test/support/ruby_runner.rb +0 -34
  118. data/test/test_private_reader.rb +0 -42
  119. data/test/test_rake.rb +0 -40
  120. data/test/test_rake_application.rb +0 -643
  121. data/test/test_rake_application_options.rb +0 -468
  122. data/test/test_rake_backtrace.rb +0 -119
  123. data/test/test_rake_clean.rb +0 -61
  124. data/test/test_rake_cpu_counter.rb +0 -68
  125. data/test/test_rake_definitions.rb +0 -84
  126. data/test/test_rake_directory_task.rb +0 -76
  127. data/test/test_rake_dsl.rb +0 -40
  128. data/test/test_rake_early_time.rb +0 -31
  129. data/test/test_rake_extension.rb +0 -59
  130. data/test/test_rake_file_creation_task.rb +0 -56
  131. data/test/test_rake_file_list.rb +0 -670
  132. data/test/test_rake_file_list_path_map.rb +0 -8
  133. data/test/test_rake_file_task.rb +0 -197
  134. data/test/test_rake_file_utils.rb +0 -314
  135. data/test/test_rake_ftp_file.rb +0 -74
  136. data/test/test_rake_functional.rb +0 -482
  137. data/test/test_rake_invocation_chain.rb +0 -64
  138. data/test/test_rake_late_time.rb +0 -18
  139. data/test/test_rake_linked_list.rb +0 -84
  140. data/test/test_rake_makefile_loader.rb +0 -46
  141. data/test/test_rake_multi_task.rb +0 -64
  142. data/test/test_rake_name_space.rb +0 -57
  143. data/test/test_rake_package_task.rb +0 -79
  144. data/test/test_rake_path_map.rb +0 -168
  145. data/test/test_rake_path_map_explode.rb +0 -34
  146. data/test/test_rake_path_map_partial.rb +0 -18
  147. data/test/test_rake_pathname_extensions.rb +0 -15
  148. data/test/test_rake_pseudo_status.rb +0 -21
  149. data/test/test_rake_rake_test_loader.rb +0 -20
  150. data/test/test_rake_reduce_compat.rb +0 -26
  151. data/test/test_rake_require.rb +0 -40
  152. data/test/test_rake_rules.rb +0 -388
  153. data/test/test_rake_scope.rb +0 -44
  154. data/test/test_rake_task.rb +0 -393
  155. data/test/test_rake_task_argument_parsing.rb +0 -119
  156. data/test/test_rake_task_arguments.rb +0 -127
  157. data/test/test_rake_task_lib.rb +0 -9
  158. data/test/test_rake_task_manager.rb +0 -178
  159. data/test/test_rake_task_manager_argument_resolution.rb +0 -19
  160. data/test/test_rake_task_with_arguments.rb +0 -172
  161. data/test/test_rake_test_task.rb +0 -146
  162. data/test/test_rake_thread_pool.rb +0 -145
  163. data/test/test_rake_top_level_functions.rb +0 -71
  164. data/test/test_rake_win32.rb +0 -72
  165. data/test/test_thread_history_display.rb +0 -101
  166. data/test/test_trace_output.rb +0 -52
@@ -1,191 +0,0 @@
1
- = Rake 10.0.3 Released
2
-
3
- "Jim, when will Rake reach version 1.0?"
4
-
5
- Over the past several years I've been asked that question at
6
- conferences, panels and over twitter. Due to historical reasons (or
7
- maybe just plain laziness) Rake has (incorrectly) been treating the
8
- second digit of the version as the major release number. So in my head
9
- Rake was already at version 9.
10
-
11
- Well, it's time to fix things. This next version of Rake drops old,
12
- crufty, backwards compatibility hacks such as top level constants, DSL
13
- methods defined in Object and numerous other features that are just no
14
- longer desired. It's also time to drop the leading zero from the
15
- version number as well and call this new version of rake what it
16
- really is: Version 10.
17
-
18
- So, welcome to Rake 10.0!
19
-
20
- Rake 10 is actually feature identical to the latest version of Rake 9
21
- (that would be the version spelled 0.9.3), *except* that Rake 10 drops
22
- all the sundry deprecated features that have accumulated over the years.
23
-
24
- If your Rakefile is up to date and current with all the new features
25
- of Rake 10, you are ready to go. If your Rakefile still uses a few
26
- deprecated feeatures, feel free to use Rake 9 (0.9.3) with the same
27
- feature set. Just be aware that future features will be in Rake 10
28
- family line.
29
-
30
- == Changes in Version 10
31
-
32
- As mentioned above, there are no new features in Rake 10. However,
33
- there are a number of features missing:
34
-
35
- * Classic namespaces are now gone. Rake is no longer able to reflect
36
- the options settings in the global variables ($rakefile, $show_tasks,
37
- $show_prereqs, $trace, $dryrun and $silent). The
38
- <tt>--classic-namespace</tt> option is no longer supported.
39
-
40
- * Global constants are no longer supported. This includes
41
- <tt>Task</tt>, <tt>FileTask</tt>, <tt>FileCreationTask</tt> and
42
- <tt>RakeApp</tt>). The constant missing hook to warn about using
43
- global rake constants has been removed.
44
-
45
- * The Rake DSL methods (task, file, directory, etc) are in their own
46
- module (Rake::DSL). The stub versions of these methods (that printed
47
- warnings) in Object have been removed. However, the DSL methods are
48
- added to the top-level <tt>main</tt> object. Since <tt>main</tt> is
49
- not in the inheritance tree, the presence of the DSL methods in main
50
- should be low impact on other libraries.
51
-
52
- If you want to use the Rake DSL commands from your own code, just
53
- include <tt>Rake::DSL</tt> into your own classes and modules.
54
-
55
- * The deprecated syntax for task arguments (the one using
56
- <tt>:needs</tt>) has been removed.
57
-
58
- * The <tt>--reduce-compat</tt> flag has been removed (it's not needed
59
- anymore).
60
-
61
- * The deprecated <tt>rake/sys.rb</tt> library has been removed.
62
-
63
- * The deprecated <tt>rake/rdoctask.rb</tt> library has been removed.
64
- RDoc supplies its own rake task now.
65
-
66
- * The deprecated <tt>rake/gempackagetask.rb</tt> library has been
67
- removed. Gem supplies its own package task now.
68
-
69
- There is one small behavioral change:
70
-
71
- * Non-file tasks now always report the current time as their time
72
- stamp. This is different from the previous behavior where non-file
73
- tasks reported current time only if there were no prerequisites, and
74
- the max prerequisite timestamp otherwise. This lead to inconsistent
75
- and surprising behavior when adding prerequisites to tasks that in
76
- turn were prequisites to file tasks. The new behavior is more
77
- consistent and predictable.
78
-
79
- == Changes (from 0.9.3, 0.9.4, 0.9.5)
80
-
81
- Since Rake 10 includes the changes from the last version of Rake 9,
82
- we'll repeat the changes for versions 0.9.3 through 0.9.5 here.
83
-
84
- === New Features (in 0.9.3)
85
-
86
- * Multitask tasks now use a thread pool. Use -j to limit the number of
87
- available threads.
88
-
89
- * Use -m to turn regular tasks into multitasks (use at your own risk).
90
-
91
- * You can now do "Rake.add_rakelib 'dir'" in your Rakefile to
92
- programatically add rake task libraries.
93
-
94
- * You can specific backtrace suppression patterns (see
95
- --supress-backtrace)
96
-
97
- * Directory tasks can now take prerequisites and actions
98
-
99
- * Use --backtrace to request a full backtrace without the task trace.
100
-
101
- * You can say "--backtrace=stdout" and "--trace=stdout" to route trace
102
- output to standard output rather than standard error.
103
-
104
- * Optional 'phony' target (enable with 'require 'rake/phony'") for
105
- special purpose builds.
106
-
107
- * Task#clear now clears task comments as well as actions and
108
- prerequisites. Task#clear_comment will specifically target comments.
109
-
110
- * The --all option will force -T and -D to consider all the tasks,
111
- with and without descriptions.
112
-
113
- === Bug Fixes (in 0.9.3)
114
-
115
- * Semi-colons in windows rakefile paths now work.
116
-
117
- * Improved Control-C support when invoking multiple test suites.
118
-
119
- * egrep method now reads files in text mode (better support for
120
- Windows)
121
-
122
- * Better deprecation line number reporting.
123
-
124
- * The -W option now works with all tasks, whether they have a
125
- description or not.
126
-
127
- * File globs in rake should not be sorted alphabetically, independent
128
- of file system and platform.
129
-
130
- * Numerous internal improvements.
131
-
132
- * Documentation typos and fixes.
133
-
134
- === Bug Fixes (in 0.9.4)
135
-
136
- * Exit status with failing tests is not correctly set to non-zero.
137
-
138
- * Simplified syntax for phony task (for older versions of RDoc).
139
-
140
- * Stand alone FileList usage gets glob function (without loading in
141
- extra dependencies)
142
-
143
- === Bug Fixes (in 0.9.5)
144
-
145
- * --trace and --backtrace no longer swallow following task names.
146
-
147
- == What is Rake
148
-
149
- Rake is a build tool similar to the make program in many ways. But
150
- instead of cryptic make recipes, Rake uses standard Ruby code to
151
- declare tasks and dependencies. You have the full power of a modern
152
- scripting language built right into your build tool.
153
-
154
- == Availability
155
-
156
- The easiest way to get and install rake is via RubyGems ...
157
-
158
- gem install rake (you may need root/admin privileges)
159
-
160
- Otherwise, you can get it from the more traditional places:
161
-
162
- Home Page:: http://github.com/jimweirich/rake
163
- Download:: http://rubyforge.org/project/showfiles.php?group_id=50
164
- GitHub:: git://github.com/jimweirich/rake.git
165
-
166
- == Thanks
167
-
168
- As usual, it was input from users that drove a lot of these changes. The
169
- following people contributed patches, made suggestions or made
170
- otherwise helpful comments. Thanks to ...
171
-
172
- * Aaron Patterson
173
- * Dylan Smith
174
- * Jo Liss
175
- * Jonas Pfenniger
176
- * Kazuki Tsujimoto
177
- * Michael Bishop
178
- * Michael Elufimov
179
- * NAKAMURA Usaku
180
- * Ryan Davis
181
- * Sam Grönblom
182
- * Sam Phippen
183
- * Sergio Wong
184
- * Tay Ray Chuan
185
- * grosser
186
- * quix
187
-
188
- Also, many thanks to Eric Hodel for assisting with getting this release
189
- out the door.
190
-
191
- -- Jim Weirich
@@ -1,61 +0,0 @@
1
- = Rake 10.1.0 Released
2
-
3
- == Changes in Version 10.1
4
-
5
- === New Features
6
-
7
- * Add support for variable length task argument lists. If more actual
8
- arguments are supplied than named arguments, then the extra
9
- arguments values will be in args.extras.
10
-
11
- * Application name is not displayed in the help banner. (Previously
12
- "rake" was hardcoded, now rake-based applications can display their
13
- own names).
14
-
15
- === Bug Fixes
16
-
17
- Bug fixes include:
18
-
19
- * Fix backtrace suppression issues.
20
-
21
- * Rules now explicit get task arguments passed to them.
22
-
23
- * Rename FileList#exclude? to FileList#exclude_from_list? to avoid
24
- conflict with new Rails method.
25
-
26
- * Clean / Clobber tasks now report failure to remove files.
27
-
28
- * Plus heaps of internal code cleanup.
29
-
30
- == What is Rake
31
-
32
- Rake is a build tool similar to the make program in many ways. But
33
- instead of cryptic make recipes, Rake uses standard Ruby code to
34
- declare tasks and dependencies. You have the full power of a modern
35
- scripting language built right into your build tool.
36
-
37
- == Availability
38
-
39
- The easiest way to get and install rake is via RubyGems ...
40
-
41
- gem install rake (you may need root/admin privileges)
42
-
43
- Otherwise, you can get it from the more from GitHub:
44
-
45
- GitHub:: git://github.com/jimweirich/rake.git
46
-
47
- == Thanks
48
-
49
- As usual, it was input from users that drove a lot of these changes.
50
- The following people contributed patches, made suggestions or made
51
- otherwise helpful comments. Thanks to ...
52
-
53
- * Michael Nikitochkin (general code cleanup)
54
- * Vipul A M (general code cleanup)
55
- * Dennis Bell (variable length task argument lists)
56
- * Jacob Swanner (rules arguments)
57
- * Rafael Rosa Fu (documentation typo)
58
- * Stuart Nelson (install.rb fixes)
59
- * Lee Hambley (application name in help banner)
60
-
61
- -- Jim Weirich
@@ -1,110 +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
- # TODO: Remove in Rake 11
32
-
33
- module Rake::AltSystem # :nodoc: all
34
- WINDOWS = RbConfig::CONFIG["host_os"] =~
35
- %r!(msdos|mswin|djgpp|mingw|[Ww]indows)!
36
-
37
- class << self
38
- def define_module_function(name, &block)
39
- define_method(name, &block)
40
- module_function(name)
41
- end
42
- end
43
-
44
- if WINDOWS && RUBY_VERSION < "1.9.0"
45
- RUNNABLE_EXTS = %w[com exe bat cmd]
46
- RUNNABLE_PATTERN = %r!\.(#{RUNNABLE_EXTS.join('|')})\Z!i
47
-
48
- define_module_function :kernel_system, &Kernel.method(:system)
49
- define_module_function :kernel_backticks, &Kernel.method(:'`')
50
-
51
- module_function
52
-
53
- def repair_command(cmd)
54
- "call " + (
55
- if cmd =~ %r!\A\s*\".*?\"!
56
- # already quoted
57
- cmd
58
- elsif match = cmd.match(%r!\A\s*(\S+)!)
59
- if match[1] =~ %r!/!
60
- # avoid x/y.bat interpretation as x with option /y
61
- %Q!"#{match[1]}"! + match.post_match
62
- else
63
- # a shell command will fail if quoted
64
- cmd
65
- end
66
- else
67
- # empty or whitespace
68
- cmd
69
- end
70
- )
71
- end
72
-
73
- def find_runnable(file)
74
- if file =~ RUNNABLE_PATTERN
75
- file
76
- else
77
- RUNNABLE_EXTS.each { |ext|
78
- test = "#{file}.#{ext}"
79
- return test if File.exist?(test)
80
- }
81
- nil
82
- end
83
- end
84
-
85
- def system(cmd, *args)
86
- repaired = (
87
- if args.empty?
88
- [repair_command(cmd)]
89
- elsif runnable = find_runnable(cmd)
90
- [File.expand_path(runnable), *args]
91
- else
92
- # non-existent file
93
- [cmd, *args]
94
- end
95
- )
96
- kernel_system(*repaired)
97
- end
98
-
99
- def backticks(cmd)
100
- kernel_backticks(repair_command(cmd))
101
- end
102
-
103
- define_module_function :'`', &method(:backticks)
104
- else
105
- # Non-Windows or ruby-1.9+: same as Kernel versions
106
- define_module_function :system, &Kernel.method(:system)
107
- define_module_function :backticks, &Kernel.method(:'`')
108
- define_module_function :'`', &Kernel.method(:'`')
109
- end
110
- end
@@ -1 +0,0 @@
1
-
@@ -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,137 +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
- require 'rake/file_list'
9
-
10
- module Rake # :nodoc:
11
-
12
- class FtpFile # :nodoc: all
13
- attr_reader :name, :size, :owner, :group, :time
14
-
15
- def self.date
16
- @date_class ||= Date
17
- end
18
-
19
- def self.time
20
- @time_class ||= Time
21
- end
22
-
23
- def initialize(path, entry)
24
- @path = path
25
- @mode, _, @owner, @group, size, d1, d2, d3, @name = entry.split(' ')
26
- @size = size.to_i
27
- @time = determine_time(d1, d2, d3)
28
- end
29
-
30
- def path
31
- File.join(@path, @name)
32
- end
33
-
34
- def directory?
35
- @mode[0] == ?d
36
- end
37
-
38
- def mode
39
- parse_mode(@mode)
40
- end
41
-
42
- def symlink?
43
- @mode[0] == ?l
44
- end
45
-
46
- private # --------------------------------------------------------
47
-
48
- def parse_mode(m)
49
- result = 0
50
- (1..9).each do |i|
51
- result = 2 * result + ((m[i] == ?-) ? 0 : 1)
52
- end
53
- result
54
- end
55
-
56
- def determine_time(d1, d2, d3)
57
- now = self.class.time.now
58
- if /:/ !~ d3
59
- result = Time.parse("#{d1} #{d2} #{d3}")
60
- else
61
- result = Time.parse("#{d1} #{d2} #{now.year} #{d3}")
62
- result = Time.parse("#{d1} #{d2} #{now.year - 1} #{d3}") if
63
- result > now
64
- end
65
- result
66
- end
67
- end
68
-
69
- ##
70
- # Manage the uploading of files to an FTP account.
71
- class FtpUploader # :nodoc:
72
-
73
- # Log uploads to standard output when true.
74
- attr_accessor :verbose
75
-
76
- class << FtpUploader
77
- # Create an uploader and pass it to the given block as +up+.
78
- # When the block is complete, close the uploader.
79
- def connect(path, host, account, password)
80
- up = self.new(path, host, account, password)
81
- begin
82
- yield(up)
83
- ensure
84
- up.close
85
- end
86
- end
87
- end
88
-
89
- # Create an FTP uploader targeting the directory +path+ on +host+
90
- # using the given account and password. +path+ will be the root
91
- # path of the uploader.
92
- def initialize(path, host, account, password)
93
- @created = Hash.new
94
- @path = path
95
- @ftp = Net::FTP.new(host, account, password)
96
- makedirs(@path)
97
- @ftp.chdir(@path)
98
- end
99
-
100
- # Create the directory +path+ in the uploader root path.
101
- def makedirs(path)
102
- route = []
103
- File.split(path).each do |dir|
104
- route << dir
105
- current_dir = File.join(route)
106
- if @created[current_dir].nil?
107
- @created[current_dir] = true
108
- $stderr.puts "Creating Directory #{current_dir}" if @verbose
109
- @ftp.mkdir(current_dir) rescue nil
110
- end
111
- end
112
- end
113
-
114
- # Upload all files matching +wildcard+ to the uploader's root
115
- # path.
116
- def upload_files(wildcard)
117
- FileList.glob(wildcard).each do |fn|
118
- upload(fn)
119
- end
120
- end
121
-
122
- # Close the uploader.
123
- def close
124
- @ftp.close
125
- end
126
-
127
- private # --------------------------------------------------------
128
-
129
- # Upload a single file to the uploader's root path.
130
- def upload(file)
131
- $stderr.puts "Uploading #{file}" if @verbose
132
- dir = File.dirname(file)
133
- makedirs(dir)
134
- @ftp.putbinaryfile(file, file) unless File.directory?(file)
135
- end
136
- end
137
- end