elliottcable-echoe 3.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. data/CHANGELOG +69 -0
  2. data/LICENSE +184 -0
  3. data/MIT-LICENSE +21 -0
  4. data/Manifest +113 -0
  5. data/README +114 -0
  6. data/Rakefile +15 -0
  7. data/TODO +4 -0
  8. data/echoe.gemspec +37 -0
  9. data/lib/echoe/client.rb +25 -0
  10. data/lib/echoe/extensions.rb +57 -0
  11. data/lib/echoe/platform.rb +36 -0
  12. data/lib/echoe/rubygems.rb +41 -0
  13. data/lib/echoe.rb +717 -0
  14. data/vendor/rake/CHANGES +400 -0
  15. data/vendor/rake/MIT-LICENSE +21 -0
  16. data/vendor/rake/README +285 -0
  17. data/vendor/rake/Rakefile +418 -0
  18. data/vendor/rake/TODO +20 -0
  19. data/vendor/rake/bin/rake +31 -0
  20. data/vendor/rake/doc/example/Rakefile1 +38 -0
  21. data/vendor/rake/doc/example/Rakefile2 +35 -0
  22. data/vendor/rake/doc/example/a.c +6 -0
  23. data/vendor/rake/doc/example/b.c +6 -0
  24. data/vendor/rake/doc/example/main.c +11 -0
  25. data/vendor/rake/doc/glossary.rdoc +51 -0
  26. data/vendor/rake/doc/jamis.rb +591 -0
  27. data/vendor/rake/doc/proto_rake.rdoc +127 -0
  28. data/vendor/rake/doc/rake.1.gz +0 -0
  29. data/vendor/rake/doc/rakefile.rdoc +534 -0
  30. data/vendor/rake/doc/rational.rdoc +151 -0
  31. data/vendor/rake/doc/release_notes/rake-0.4.14.rdoc +23 -0
  32. data/vendor/rake/doc/release_notes/rake-0.4.15.rdoc +35 -0
  33. data/vendor/rake/doc/release_notes/rake-0.5.0.rdoc +53 -0
  34. data/vendor/rake/doc/release_notes/rake-0.5.3.rdoc +78 -0
  35. data/vendor/rake/doc/release_notes/rake-0.5.4.rdoc +46 -0
  36. data/vendor/rake/doc/release_notes/rake-0.6.0.rdoc +141 -0
  37. data/vendor/rake/doc/release_notes/rake-0.7.0.rdoc +119 -0
  38. data/vendor/rake/doc/release_notes/rake-0.7.1.rdoc +59 -0
  39. data/vendor/rake/doc/release_notes/rake-0.7.2.rdoc +121 -0
  40. data/vendor/rake/doc/release_notes/rake-0.7.3.rdoc +47 -0
  41. data/vendor/rake/doc/release_notes/rake-0.8.0.rdoc +114 -0
  42. data/vendor/rake/doc/release_notes/rake-0.8.2.rdoc +165 -0
  43. data/vendor/rake/doc/release_notes/rake-0.8.3.rdoc +112 -0
  44. data/vendor/rake/install.rb +88 -0
  45. data/vendor/rake/lib/rake/classic_namespace.rb +8 -0
  46. data/vendor/rake/lib/rake/clean.rb +33 -0
  47. data/vendor/rake/lib/rake/contrib/compositepublisher.rb +24 -0
  48. data/vendor/rake/lib/rake/contrib/ftptools.rb +153 -0
  49. data/vendor/rake/lib/rake/contrib/publisher.rb +75 -0
  50. data/vendor/rake/lib/rake/contrib/rubyforgepublisher.rb +18 -0
  51. data/vendor/rake/lib/rake/contrib/sshpublisher.rb +47 -0
  52. data/vendor/rake/lib/rake/contrib/sys.rb +209 -0
  53. data/vendor/rake/lib/rake/gempackagetask.rb +103 -0
  54. data/vendor/rake/lib/rake/loaders/makefile.rb +35 -0
  55. data/vendor/rake/lib/rake/packagetask.rb +185 -0
  56. data/vendor/rake/lib/rake/rake_test_loader.rb +5 -0
  57. data/vendor/rake/lib/rake/rdoctask.rb +147 -0
  58. data/vendor/rake/lib/rake/ruby182_test_unit_fix.rb +23 -0
  59. data/vendor/rake/lib/rake/runtest.rb +23 -0
  60. data/vendor/rake/lib/rake/tasklib.rb +23 -0
  61. data/vendor/rake/lib/rake/testtask.rb +161 -0
  62. data/vendor/rake/lib/rake/win32.rb +54 -0
  63. data/vendor/rake/lib/rake.rb +2468 -0
  64. data/vendor/rake/test/capture_stdout.rb +26 -0
  65. data/vendor/rake/test/check_expansion.rb +5 -0
  66. data/vendor/rake/test/contrib/test_sys.rb +47 -0
  67. data/vendor/rake/test/data/chains/Rakefile +15 -0
  68. data/vendor/rake/test/data/default/Rakefile +19 -0
  69. data/vendor/rake/test/data/dryrun/Rakefile +22 -0
  70. data/vendor/rake/test/data/file_creation_task/Rakefile +33 -0
  71. data/vendor/rake/test/data/imports/Rakefile +19 -0
  72. data/vendor/rake/test/data/imports/deps.mf +1 -0
  73. data/vendor/rake/test/data/multidesc/Rakefile +17 -0
  74. data/vendor/rake/test/data/namespace/Rakefile +57 -0
  75. data/vendor/rake/test/data/rakelib/test1.rb +3 -0
  76. data/vendor/rake/test/data/rbext/rakefile.rb +3 -0
  77. data/vendor/rake/test/data/sample.mf +12 -0
  78. data/vendor/rake/test/data/statusreturn/Rakefile +8 -0
  79. data/vendor/rake/test/data/unittest/Rakefile +1 -0
  80. data/vendor/rake/test/filecreation.rb +32 -0
  81. data/vendor/rake/test/functional.rb +15 -0
  82. data/vendor/rake/test/in_environment.rb +30 -0
  83. data/vendor/rake/test/rake_test_setup.rb +10 -0
  84. data/vendor/rake/test/reqfile.rb +3 -0
  85. data/vendor/rake/test/reqfile2.rb +3 -0
  86. data/vendor/rake/test/session_functional.rb +337 -0
  87. data/vendor/rake/test/shellcommand.rb +3 -0
  88. data/vendor/rake/test/test_application.rb +694 -0
  89. data/vendor/rake/test/test_clean.rb +14 -0
  90. data/vendor/rake/test/test_definitions.rb +82 -0
  91. data/vendor/rake/test/test_earlytime.rb +35 -0
  92. data/vendor/rake/test/test_extension.rb +63 -0
  93. data/vendor/rake/test/test_file_creation_task.rb +62 -0
  94. data/vendor/rake/test/test_file_task.rb +139 -0
  95. data/vendor/rake/test/test_filelist.rb +618 -0
  96. data/vendor/rake/test/test_fileutils.rb +250 -0
  97. data/vendor/rake/test/test_ftp.rb +59 -0
  98. data/vendor/rake/test/test_invocation_chain.rb +75 -0
  99. data/vendor/rake/test/test_makefile_loader.rb +25 -0
  100. data/vendor/rake/test/test_multitask.rb +45 -0
  101. data/vendor/rake/test/test_namespace.rb +36 -0
  102. data/vendor/rake/test/test_package_task.rb +116 -0
  103. data/vendor/rake/test/test_pathmap.rb +209 -0
  104. data/vendor/rake/test/test_rake.rb +41 -0
  105. data/vendor/rake/test/test_require.rb +33 -0
  106. data/vendor/rake/test/test_rules.rb +347 -0
  107. data/vendor/rake/test/test_task_arguments.rb +89 -0
  108. data/vendor/rake/test/test_task_manager.rb +170 -0
  109. data/vendor/rake/test/test_tasklib.rb +12 -0
  110. data/vendor/rake/test/test_tasks.rb +371 -0
  111. data/vendor/rake/test/test_test_task.rb +75 -0
  112. data/vendor/rake/test/test_top_level_functions.rb +84 -0
  113. data/vendor/rake/test/test_win32.rb +57 -0
  114. metadata +195 -0
@@ -0,0 +1,153 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # = Tools for FTP uploading.
4
+ #
5
+ # This file is still under development and is not released for general
6
+ # use.
7
+
8
+ require 'date'
9
+ require 'net/ftp'
10
+
11
+ module Rake # :nodoc:
12
+
13
+ ####################################################################
14
+ # <b>Note:</b> <em> Not released for general use.</em>
15
+ class FtpFile
16
+ attr_reader :name, :size, :owner, :group, :time
17
+
18
+ def self.date
19
+ @date_class ||= Date
20
+ end
21
+
22
+ def self.time
23
+ @time_class ||= Time
24
+ end
25
+
26
+ def initialize(path, entry)
27
+ @path = path
28
+ @mode, line, @owner, @group, size, d1, d2, d3, @name = entry.split(' ')
29
+ @size = size.to_i
30
+ @time = determine_time(d1, d2, d3)
31
+ end
32
+
33
+ def path
34
+ File.join(@path, @name)
35
+ end
36
+
37
+ def directory?
38
+ @mode[0] == ?d
39
+ end
40
+
41
+ def mode
42
+ parse_mode(@mode)
43
+ end
44
+
45
+ def symlink?
46
+ @mode[0] == ?l
47
+ end
48
+
49
+ private # --------------------------------------------------------
50
+
51
+ def parse_mode(m)
52
+ result = 0
53
+ (1..9).each do |i|
54
+ result = 2*result + ((m[i]==?-) ? 0 : 1)
55
+ end
56
+ result
57
+ end
58
+
59
+ def determine_time(d1, d2, d3)
60
+ now = self.class.time.now
61
+ if /:/ =~ d3
62
+ h, m = d3.split(':')
63
+ result = Time.parse("#{d1} #{d2} #{now.year} #{d3}")
64
+ if result > now
65
+ result = Time.parse("#{d1} #{d2} #{now.year-1} #{d3}")
66
+ end
67
+ else
68
+ result = Time.parse("#{d1} #{d2} #{d3}")
69
+ end
70
+ result
71
+ # elements = ParseDate.parsedate("#{d1} #{d2} #{d3}")
72
+ # if elements[0].nil?
73
+ # today = self.class.date.today
74
+ # if elements[1] > today.month
75
+ # elements[0] = today.year - 1
76
+ # else
77
+ # elements[0] = today.year
78
+ # end
79
+ # end
80
+ # elements = elements.collect { |el| el.nil? ? 0 : el }
81
+ # Time.mktime(*elements[0,7])
82
+ end
83
+ end
84
+
85
+ ####################################################################
86
+ # Manage the uploading of files to an FTP account.
87
+ class FtpUploader
88
+
89
+ # Log uploads to standard output when true.
90
+ attr_accessor :verbose
91
+
92
+ class << FtpUploader
93
+ # Create an uploader and pass it to the given block as +up+.
94
+ # When the block is complete, close the uploader.
95
+ def connect(path, host, account, password)
96
+ up = self.new(path, host, account, password)
97
+ begin
98
+ yield(up)
99
+ ensure
100
+ up.close
101
+ end
102
+ end
103
+ end
104
+
105
+ # Create an FTP uploader targetting the directory +path+ on +host+
106
+ # using the given account and password. +path+ will be the root
107
+ # path of the uploader.
108
+ def initialize(path, host, account, password)
109
+ @created = Hash.new
110
+ @path = path
111
+ @ftp = Net::FTP.new(host, account, password)
112
+ makedirs(@path)
113
+ @ftp.chdir(@path)
114
+ end
115
+
116
+ # Create the directory +path+ in the uploader root path.
117
+ def makedirs(path)
118
+ route = []
119
+ File.split(path).each do |dir|
120
+ route << dir
121
+ current_dir = File.join(route)
122
+ if @created[current_dir].nil?
123
+ @created[current_dir] = true
124
+ puts "Creating Directory #{current_dir}" if @verbose
125
+ @ftp.mkdir(current_dir) rescue nil
126
+ end
127
+ end
128
+ end
129
+
130
+ # Upload all files matching +wildcard+ to the uploader's root
131
+ # path.
132
+ def upload_files(wildcard)
133
+ Dir[wildcard].each do |fn|
134
+ upload(fn)
135
+ end
136
+ end
137
+
138
+ # Close the uploader.
139
+ def close
140
+ @ftp.close
141
+ end
142
+
143
+ private # --------------------------------------------------------
144
+
145
+ # Upload a single file to the uploader's root path.
146
+ def upload(file)
147
+ puts "Uploading #{file}" if @verbose
148
+ dir = File.dirname(file)
149
+ makedirs(dir)
150
+ @ftp.putbinaryfile(file, file) unless File.directory?(file)
151
+ end
152
+ end
153
+ end
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Copyright 2003, 2004 by Jim Weirich (jim@weirichhouse.org)
4
+ # All rights reserved.
5
+
6
+ # Permission is granted for use, copying, modification, distribution,
7
+ # and distribution of modified versions of this work as long as the
8
+ # above copyright notice is included.
9
+
10
+ # Configuration information about an upload host system.
11
+ # * name :: Name of host system.
12
+ # * webdir :: Base directory for the web information for the
13
+ # application. The application name (APP) is appended to
14
+ # this directory before using.
15
+ # * pkgdir :: Directory on the host system where packages can be
16
+ # placed.
17
+ HostInfo = Struct.new(:name, :webdir, :pkgdir)
18
+
19
+ # Manage several publishers as a single entity.
20
+ class CompositePublisher
21
+ def initialize
22
+ @publishers = []
23
+ end
24
+
25
+ # Add a publisher to the composite.
26
+ def add(pub)
27
+ @publishers << pub
28
+ end
29
+
30
+ # Upload all the individual publishers.
31
+ def upload
32
+ @publishers.each { |p| p.upload }
33
+ end
34
+ end
35
+
36
+ # Publish an entire directory to an existing remote directory using
37
+ # SSH.
38
+ class SshDirPublisher
39
+ def initialize(host, remote_dir, local_dir)
40
+ @host = host
41
+ @remote_dir = remote_dir
42
+ @local_dir = local_dir
43
+ end
44
+
45
+ def upload
46
+ run %{scp -rq #{@local_dir}/* #{@host}:#{@remote_dir}}
47
+ end
48
+ end
49
+
50
+ # Publish an entire directory to a fresh remote directory using SSH.
51
+ class SshFreshDirPublisher < SshDirPublisher
52
+ def upload
53
+ run %{ssh #{@host} rm -rf #{@remote_dir}} rescue nil
54
+ run %{ssh #{@host} mkdir #{@remote_dir}}
55
+ super
56
+ end
57
+ end
58
+
59
+ # Publish a list of files to an existing remote directory.
60
+ class SshFilePublisher
61
+ # Create a publisher using the give host information.
62
+ def initialize(host, remote_dir, local_dir, *files)
63
+ @host = host
64
+ @remote_dir = remote_dir
65
+ @local_dir = local_dir
66
+ @files = files
67
+ end
68
+
69
+ # Upload the local directory to the remote directory.
70
+ def upload
71
+ @files.each do |fn|
72
+ run %{scp -q #{@local_dir}/#{fn} #{@host}:#{@remote_dir}}
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rake/contrib/sshpublisher'
4
+
5
+ module Rake
6
+
7
+ class RubyForgePublisher < SshDirPublisher
8
+ attr_reader :project, :proj_id, :user
9
+
10
+ def initialize(projname, user)
11
+ super(
12
+ "#{user}@rubyforge.org",
13
+ "/var/www/gforge-projects/#{projname}",
14
+ "html")
15
+ end
16
+ end
17
+
18
+ end
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rake/contrib/compositepublisher'
4
+
5
+ module Rake
6
+
7
+ # Publish an entire directory to an existing remote directory using
8
+ # SSH.
9
+ class SshDirPublisher
10
+ def initialize(host, remote_dir, local_dir)
11
+ @host = host
12
+ @remote_dir = remote_dir
13
+ @local_dir = local_dir
14
+ end
15
+
16
+ def upload
17
+ sh %{scp -rq #{@local_dir}/* #{@host}:#{@remote_dir}}
18
+ end
19
+ end
20
+
21
+ # Publish an entire directory to a fresh remote directory using SSH.
22
+ class SshFreshDirPublisher < SshDirPublisher
23
+ def upload
24
+ sh %{ssh #{@host} rm -rf #{@remote_dir}} rescue nil
25
+ sh %{ssh #{@host} mkdir #{@remote_dir}}
26
+ super
27
+ end
28
+ end
29
+
30
+ # Publish a list of files to an existing remote directory.
31
+ class SshFilePublisher
32
+ # Create a publisher using the give host information.
33
+ def initialize(host, remote_dir, local_dir, *files)
34
+ @host = host
35
+ @remote_dir = remote_dir
36
+ @local_dir = local_dir
37
+ @files = files
38
+ end
39
+
40
+ # Upload the local directory to the remote directory.
41
+ def upload
42
+ @files.each do |fn|
43
+ sh %{scp -q #{@local_dir}/#{fn} #{@host}:#{@remote_dir}}
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,209 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ #--
4
+ # Copyright (c) 2003, 2004 Jim Weirich
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining
7
+ # a copy of this software and associated documentation files (the
8
+ # "Software"), to deal in the Software without restriction, including
9
+ # without limitation the rights to use, copy, modify, merge, publish,
10
+ # distribute, sublicense, and/or sell copies of the Software, and to
11
+ # permit persons to whom the Software is furnished to do so, subject to
12
+ # the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be
15
+ # included in all copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
+ #++
25
+ #
26
+ begin
27
+ require 'ftools'
28
+ rescue LoadError
29
+ end
30
+ require 'rbconfig'
31
+
32
+ ######################################################################
33
+ # Sys provides a number of file manipulation tools for the convenience
34
+ # of writing Rakefiles. All commands in this module will announce
35
+ # their activity on standard output if the $verbose flag is set
36
+ # ($verbose = true is the default). You can control this by globally
37
+ # setting $verbose or by using the +verbose+ and +quiet+ methods.
38
+ #
39
+ # Sys has been deprecated in favor of the FileUtils module available
40
+ # in Ruby 1.8.
41
+ #
42
+ module Sys
43
+ RUBY = Config::CONFIG['ruby_install_name']
44
+
45
+ # Install all the files matching +wildcard+ into the +dest_dir+
46
+ # directory. The permission mode is set to +mode+.
47
+ def install(wildcard, dest_dir, mode)
48
+ Dir[wildcard].each do |fn|
49
+ File.install(fn, dest_dir, mode, $verbose)
50
+ end
51
+ end
52
+
53
+ # Run the system command +cmd+.
54
+ def run(cmd)
55
+ log cmd
56
+ system(cmd) or fail "Command Failed: [#{cmd}]"
57
+ end
58
+
59
+ # Run a Ruby interpreter with the given arguments.
60
+ def ruby(*args)
61
+ run "#{RUBY} #{args.join(' ')}"
62
+ end
63
+
64
+ # Copy a single file from +file_name+ to +dest_file+.
65
+ def copy(file_name, dest_file)
66
+ log "Copying file #{file_name} to #{dest_file}"
67
+ File.copy(file_name, dest_file)
68
+ end
69
+
70
+ # Copy all files matching +wildcard+ into the directory +dest_dir+.
71
+ def copy_files(wildcard, dest_dir)
72
+ for_matching_files(wildcard, dest_dir) { |from, to| copy(from, to) }
73
+ end
74
+
75
+ # Link +file_name+ to +dest_file+.
76
+ def link(file_name, dest_file)
77
+ log "Linking file #{file_name} to #{dest_file}"
78
+ File.link(file_name, dest_file)
79
+ end
80
+
81
+ # Link all files matching +wildcard+ into the directory +dest_dir+.
82
+ def link_files(wildcard, dest_dir)
83
+ for_matching_files(wildcard, dest_dir) { |from, to| link(from, to) }
84
+ end
85
+
86
+ # Symlink +file_name+ to +dest_file+.
87
+ def symlink(file_name, dest_file)
88
+ log "Symlinking file #{file_name} to #{dest_file}"
89
+ File.symlink(file_name, dest_file)
90
+ end
91
+
92
+ # Symlink all files matching +wildcard+ into the directory +dest_dir+.
93
+ def symlink_files(wildcard, dest_dir)
94
+ for_matching_files(wildcard, dest_dir) { |from, to| link(from, to) }
95
+ end
96
+
97
+ # Remove all files matching +wildcard+. If a matching file is a
98
+ # directory, it must be empty to be removed. used +delete_all+ to
99
+ # recursively delete directories.
100
+ def delete(*wildcards)
101
+ wildcards.each do |wildcard|
102
+ Dir[wildcard].each do |fn|
103
+ if File.directory?(fn)
104
+ log "Deleting directory #{fn}"
105
+ Dir.delete(fn)
106
+ else
107
+ log "Deleting file #{fn}"
108
+ File.delete(fn)
109
+ end
110
+ end
111
+ end
112
+ end
113
+
114
+ # Recursively delete all files and directories matching +wildcard+.
115
+ def delete_all(*wildcards)
116
+ wildcards.each do |wildcard|
117
+ Dir[wildcard].each do |fn|
118
+ next if ! File.exist?(fn)
119
+ if File.directory?(fn)
120
+ Dir["#{fn}/*"].each do |subfn|
121
+ next if subfn=='.' || subfn=='..'
122
+ delete_all(subfn)
123
+ end
124
+ log "Deleting directory #{fn}"
125
+ Dir.delete(fn)
126
+ else
127
+ log "Deleting file #{fn}"
128
+ File.delete(fn)
129
+ end
130
+ end
131
+ end
132
+ end
133
+
134
+ # Make the directories given in +dirs+.
135
+ def makedirs(*dirs)
136
+ dirs.each do |fn|
137
+ log "Making directory #{fn}"
138
+ File.makedirs(fn)
139
+ end
140
+ end
141
+
142
+ # Make +dir+ the current working directory for the duration of
143
+ # executing the given block.
144
+ def indir(dir)
145
+ olddir = Dir.pwd
146
+ Dir.chdir(dir)
147
+ yield
148
+ ensure
149
+ Dir.chdir(olddir)
150
+ end
151
+
152
+ # Split a file path into individual directory names.
153
+ #
154
+ # For example:
155
+ # split_all("a/b/c") => ['a', 'b', 'c']
156
+ def split_all(path)
157
+ head, tail = File.split(path)
158
+ return [tail] if head == '.' || tail == '/'
159
+ return [head, tail] if head == '/'
160
+ return split_all(head) + [tail]
161
+ end
162
+
163
+ # Write a message to standard out if $verbose is enabled.
164
+ def log(msg)
165
+ print " " if $trace && $verbose
166
+ puts msg if $verbose
167
+ end
168
+
169
+ # Perform a block with $verbose disabled.
170
+ def quiet(&block)
171
+ with_verbose(false, &block)
172
+ end
173
+
174
+ # Perform a block with $verbose enabled.
175
+ def verbose(&block)
176
+ with_verbose(true, &block)
177
+ end
178
+
179
+ # Perform a block with each file matching a set of wildcards.
180
+ def for_files(*wildcards)
181
+ wildcards.each do |wildcard|
182
+ Dir[wildcard].each do |fn|
183
+ yield(fn)
184
+ end
185
+ end
186
+ end
187
+
188
+ extend(self)
189
+
190
+ private # ----------------------------------------------------------
191
+
192
+ def for_matching_files(wildcard, dest_dir)
193
+ Dir[wildcard].each do |fn|
194
+ dest_file = File.join(dest_dir, fn)
195
+ parent = File.dirname(dest_file)
196
+ makedirs(parent) if ! File.directory?(parent)
197
+ yield(fn, dest_file)
198
+ end
199
+ end
200
+
201
+ def with_verbose(v)
202
+ oldverbose = $verbose
203
+ $verbose = v
204
+ yield
205
+ ensure
206
+ $verbose = oldverbose
207
+ end
208
+
209
+ end
@@ -0,0 +1,103 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Define a package task library to aid in the definition of GEM
4
+ # packages.
5
+
6
+ require 'rubygems'
7
+ require 'rake'
8
+ require 'rake/packagetask'
9
+ require 'rubygems/user_interaction'
10
+ require 'rubygems/builder'
11
+
12
+ begin
13
+ Gem.manage_gems
14
+ rescue NoMethodError => ex
15
+ # Using rubygems prior to 0.6.1
16
+ end
17
+
18
+ module Rake
19
+
20
+ # Create a package based upon a Gem spec. Gem packages, as well as
21
+ # zip files and tar/gzipped packages can be produced by this task.
22
+ #
23
+ # In addition to the Rake targets generated by PackageTask, a
24
+ # GemPackageTask will also generate the following tasks:
25
+ #
26
+ # [<b>"<em>package_dir</em>/<em>name</em>-<em>version</em>.gem"</b>]
27
+ # Create a Ruby GEM package with the given name and version.
28
+ #
29
+ # Example using a Ruby GEM spec:
30
+ #
31
+ # require 'rubygems'
32
+ #
33
+ # spec = Gem::Specification.new do |s|
34
+ # s.platform = Gem::Platform::RUBY
35
+ # s.summary = "Ruby based make-like utility."
36
+ # s.name = 'rake'
37
+ # s.version = PKG_VERSION
38
+ # s.requirements << 'none'
39
+ # s.require_path = 'lib'
40
+ # s.autorequire = 'rake'
41
+ # s.files = PKG_FILES
42
+ # s.description = <<EOF
43
+ # Rake is a Make-like program implemented in Ruby. Tasks
44
+ # and dependencies are specified in standard Ruby syntax.
45
+ # EOF
46
+ # end
47
+ #
48
+ # Rake::GemPackageTask.new(spec) do |pkg|
49
+ # pkg.need_zip = true
50
+ # pkg.need_tar = true
51
+ # end
52
+ #
53
+ class GemPackageTask < PackageTask
54
+ # Ruby GEM spec containing the metadata for this package. The
55
+ # name, version and package_files are automatically determined
56
+ # from the GEM spec and don't need to be explicitly provided.
57
+ attr_accessor :gem_spec
58
+
59
+ # Create a GEM Package task library. Automatically define the gem
60
+ # if a block is given. If no block is supplied, then +define+
61
+ # needs to be called to define the task.
62
+ def initialize(gem_spec)
63
+ init(gem_spec)
64
+ yield self if block_given?
65
+ define if block_given?
66
+ end
67
+
68
+ # Initialization tasks without the "yield self" or define
69
+ # operations.
70
+ def init(gem)
71
+ super(gem.name, gem.version)
72
+ @gem_spec = gem
73
+ @package_files += gem_spec.files if gem_spec.files
74
+ end
75
+
76
+ # Create the Rake tasks and actions specified by this
77
+ # GemPackageTask. (+define+ is automatically called if a block is
78
+ # given to +new+).
79
+ def define
80
+ super
81
+ task :package => [:gem]
82
+ desc "Build the gem file #{gem_file}"
83
+ task :gem => ["#{package_dir}/#{gem_file}"]
84
+ file "#{package_dir}/#{gem_file}" => [package_dir] + @gem_spec.files do
85
+ when_writing("Creating GEM") {
86
+ Gem::Builder.new(gem_spec).build
87
+ verbose(true) {
88
+ mv gem_file, "#{package_dir}/#{gem_file}"
89
+ }
90
+ }
91
+ end
92
+ end
93
+
94
+ def gem_file
95
+ if @gem_spec.platform == Gem::Platform::RUBY
96
+ "#{package_name}.gem"
97
+ else
98
+ "#{package_name}-#{@gem_spec.platform}.gem"
99
+ end
100
+ end
101
+
102
+ end
103
+ end
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ module Rake
4
+
5
+ # Makefile loader to be used with the import file loader.
6
+ class MakefileLoader
7
+
8
+ # Load the makefile dependencies in +fn+.
9
+ def load(fn)
10
+ open(fn) do |mf|
11
+ lines = mf.read
12
+ lines.gsub!(/#[^\n]*\n/m, "")
13
+ lines.gsub!(/\\\n/, ' ')
14
+ lines.split("\n").each do |line|
15
+ process_line(line)
16
+ end
17
+ end
18
+ end
19
+
20
+ private
21
+
22
+ # Process one logical line of makefile data.
23
+ def process_line(line)
24
+ file_tasks, args = line.split(':')
25
+ return if args.nil?
26
+ dependents = args.split
27
+ file_tasks.strip.split.each do |file_task|
28
+ file file_task => dependents
29
+ end
30
+ end
31
+ end
32
+
33
+ # Install the handler
34
+ Rake.application.add_loader('mf', MakefileLoader.new)
35
+ end