jimweirich-rake 0.8.1.5
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.
- data/CHANGES +364 -0
- data/MIT-LICENSE +21 -0
- data/README +242 -0
- data/Rakefile +413 -0
- data/TODO +20 -0
- data/bin/rake +31 -0
- data/doc/example/Rakefile1 +38 -0
- data/doc/example/Rakefile2 +35 -0
- data/doc/example/a.c +6 -0
- data/doc/example/b.c +6 -0
- data/doc/example/main.c +11 -0
- data/doc/glossary.rdoc +51 -0
- data/doc/jamis.rb +591 -0
- data/doc/proto_rake.rdoc +127 -0
- data/doc/rake.1.gz +0 -0
- data/doc/rakefile.rdoc +411 -0
- data/doc/rational.rdoc +151 -0
- data/doc/release_notes/rake-0.4.14.rdoc +23 -0
- data/doc/release_notes/rake-0.4.15.rdoc +35 -0
- data/doc/release_notes/rake-0.5.0.rdoc +53 -0
- data/doc/release_notes/rake-0.5.3.rdoc +78 -0
- data/doc/release_notes/rake-0.5.4.rdoc +46 -0
- data/doc/release_notes/rake-0.6.0.rdoc +141 -0
- data/doc/release_notes/rake-0.7.0.rdoc +119 -0
- data/doc/release_notes/rake-0.7.1.rdoc +59 -0
- data/doc/release_notes/rake-0.7.2.rdoc +121 -0
- data/doc/release_notes/rake-0.7.3.rdoc +47 -0
- data/doc/release_notes/rake-0.8.0.rdoc +114 -0
- data/install.rb +88 -0
- data/lib/rake/classic_namespace.rb +8 -0
- data/lib/rake/clean.rb +33 -0
- data/lib/rake/contrib/compositepublisher.rb +24 -0
- data/lib/rake/contrib/ftptools.rb +153 -0
- data/lib/rake/contrib/publisher.rb +75 -0
- data/lib/rake/contrib/rubyforgepublisher.rb +18 -0
- data/lib/rake/contrib/sshpublisher.rb +47 -0
- data/lib/rake/contrib/sys.rb +209 -0
- data/lib/rake/gempackagetask.rb +103 -0
- data/lib/rake/loaders/makefile.rb +40 -0
- data/lib/rake/packagetask.rb +184 -0
- data/lib/rake/rake_test_loader.rb +5 -0
- data/lib/rake/rdoctask.rb +147 -0
- data/lib/rake/ruby182_test_unit_fix.rb +23 -0
- data/lib/rake/runtest.rb +23 -0
- data/lib/rake/tasklib.rb +18 -0
- data/lib/rake/testtask.rb +161 -0
- data/lib/rake.rb +2312 -0
- data/test/capture_stdout.rb +26 -0
- data/test/contrib/testsys.rb +47 -0
- data/test/data/chains/Rakefile +15 -0
- data/test/data/default/Rakefile +19 -0
- data/test/data/dryrun/Rakefile +22 -0
- data/test/data/file_creation_task/Rakefile +30 -0
- data/test/data/imports/Rakefile +19 -0
- data/test/data/imports/deps.mf +1 -0
- data/test/data/multidesc/Rakefile +17 -0
- data/test/data/namespace/Rakefile +57 -0
- data/test/data/rakelib/test1.rb +3 -0
- data/test/data/rbext/rakefile.rb +3 -0
- data/test/data/sample.mf +9 -0
- data/test/data/statusreturn/Rakefile +8 -0
- data/test/data/unittest/Rakefile +1 -0
- data/test/filecreation.rb +32 -0
- data/test/functional.rb +15 -0
- data/test/rake_test_setup.rb +5 -0
- data/test/reqfile.rb +3 -0
- data/test/reqfile2.rb +3 -0
- data/test/session_functional.rb +267 -0
- data/test/shellcommand.rb +3 -0
- data/test/test_application.rb +504 -0
- data/test/test_clean.rb +14 -0
- data/test/test_definitions.rb +82 -0
- data/test/test_earlytime.rb +35 -0
- data/test/test_extension.rb +63 -0
- data/test/test_file_creation_task.rb +62 -0
- data/test/test_file_task.rb +139 -0
- data/test/test_filelist.rb +618 -0
- data/test/test_fileutils.rb +239 -0
- data/test/test_ftp.rb +59 -0
- data/test/test_invocation_chain.rb +75 -0
- data/test/test_makefile_loader.rb +23 -0
- data/test/test_multitask.rb +45 -0
- data/test/test_namespace.rb +36 -0
- data/test/test_package_task.rb +116 -0
- data/test/test_pathmap.rb +209 -0
- data/test/test_rake.rb +34 -0
- data/test/test_require.rb +33 -0
- data/test/test_rules.rb +347 -0
- data/test/test_task_arguments.rb +76 -0
- data/test/test_task_manager.rb +148 -0
- data/test/test_tasks.rb +372 -0
- data/test/test_test_task.rb +75 -0
- data/test/test_top_level_functions.rb +84 -0
- metadata +173 -0
@@ -0,0 +1,114 @@
|
|
1
|
+
= Rake 0.8.0/0.8.1 Released
|
2
|
+
|
3
|
+
Rake version 0.8.0 is a new release of rake that includes serveral new
|
4
|
+
features.
|
5
|
+
|
6
|
+
== Changes
|
7
|
+
|
8
|
+
=== New Features in Version 0.8.0
|
9
|
+
|
10
|
+
* Tasks can now receive command line parameters. See the examples
|
11
|
+
below for more details.
|
12
|
+
|
13
|
+
* Comments are limited to 80 columns on output, but full comments can
|
14
|
+
be seen by using the -D parameter. (feature suggested by Jamis
|
15
|
+
Buck).
|
16
|
+
|
17
|
+
* Explicit exit(n) calls will now set the exit status to n. (patch
|
18
|
+
provided by Stephen Touset).
|
19
|
+
|
20
|
+
* Rake is now compatible with Ruby 1.9.
|
21
|
+
|
22
|
+
Version 0.8.1 is a minor update that includes additional Ruby 1.9
|
23
|
+
compatibility fixes.
|
24
|
+
|
25
|
+
== What is Rake
|
26
|
+
|
27
|
+
Rake is a build tool similar to the make program in many ways. But
|
28
|
+
instead of cryptic make recipes, Rake uses standard Ruby code to
|
29
|
+
declare tasks and dependencies. You have the full power of a modern
|
30
|
+
scripting language built right into your build tool.
|
31
|
+
|
32
|
+
== Availability
|
33
|
+
|
34
|
+
The easiest way to get and install rake is via RubyGems ...
|
35
|
+
|
36
|
+
gem install rake (you may need root/admin privileges)
|
37
|
+
|
38
|
+
Otherwise, you can get it from the more traditional places:
|
39
|
+
|
40
|
+
Home Page:: http://rake.rubyforge.org/
|
41
|
+
Download:: http://rubyforge.org/project/showfiles.php?group_id=50
|
42
|
+
|
43
|
+
== Task Argument Examples
|
44
|
+
|
45
|
+
Prior to version 0.8.0, rake was only able to handle command line
|
46
|
+
arguments of the form NAME=VALUE that were passed into Rake via the
|
47
|
+
ENV hash. Many folks had asked for some kind of simple command line
|
48
|
+
arguments, perhaps using "--" to separate regular task names from
|
49
|
+
argument values on the command line. The problem is that there was no
|
50
|
+
easy way to associate positional arguments on the command line with
|
51
|
+
different tasks. Suppose both tasks :a and :b expect a command line
|
52
|
+
argument: does the first value go with :a? What if :b is run first?
|
53
|
+
Should it then get the first command line argument.
|
54
|
+
|
55
|
+
Rake 0.8.0 solves this problem by explicitly passing values directly
|
56
|
+
to the tasks that need them. For example, if I had a release task
|
57
|
+
that required a version number, I could say:
|
58
|
+
|
59
|
+
rake release[0.8.0]
|
60
|
+
|
61
|
+
And the string "0.8.0" will be passed to the :release task. Multiple
|
62
|
+
arguments can be passed by separating them with a comma, for example:
|
63
|
+
|
64
|
+
rake name[john,doe]
|
65
|
+
|
66
|
+
Just a few words of caution. The rake task name and its arguments
|
67
|
+
need to be a single command line argument to rake. This generally
|
68
|
+
means no spaces. If spaces are needed, then the entire rake +
|
69
|
+
argument string should be quoted. Something like this:
|
70
|
+
|
71
|
+
rake "name[billy bob, smith]"
|
72
|
+
|
73
|
+
(Quoting rules vary between operating systems and shells, so make sure
|
74
|
+
you consult the proper docs for your OS/shell).
|
75
|
+
|
76
|
+
=== Tasks that Expect Parameters
|
77
|
+
|
78
|
+
Parameters are only given to tasks that are setup to expect them. In
|
79
|
+
order to handle named parameters, the task declaration syntax for
|
80
|
+
tasks has been extended slightly.
|
81
|
+
|
82
|
+
For example, a task that needs a first name and last name might be
|
83
|
+
declared as:
|
84
|
+
|
85
|
+
task :name, :first_name, :last_name
|
86
|
+
|
87
|
+
The first argument is still the name of the task (:name in this case).
|
88
|
+
The next to argumements are the names of the parameters expected by
|
89
|
+
:name (:first_name and :last_name in the example).
|
90
|
+
|
91
|
+
To access the values of the paramters, the block defining the task
|
92
|
+
behaviour can now accept a second parameter:
|
93
|
+
|
94
|
+
task :name, :first_name, :last_name do |t, args|
|
95
|
+
puts "First name is #{args.first_name}"
|
96
|
+
puts "Last name is #{args.last_name}"
|
97
|
+
end
|
98
|
+
|
99
|
+
The first argument of the block "t" is always bound to the current
|
100
|
+
task object. The second argument "args" is an open-struct like object
|
101
|
+
that allows access to the task arguments. Extra command line
|
102
|
+
arguments to a task are ignored. Missing command line arguments are
|
103
|
+
given the nil value.
|
104
|
+
|
105
|
+
== Thanks
|
106
|
+
|
107
|
+
As usual, it was input from users that drove a alot of these changes. The
|
108
|
+
following people either contributed patches, made suggestions or made
|
109
|
+
otherwise helpful comments. Thanks to ...
|
110
|
+
|
111
|
+
* Jamis Buck (for comment formatting suggestions)
|
112
|
+
* Stephen Touset (for exit status patch).
|
113
|
+
|
114
|
+
-- Jim Weirich
|
data/install.rb
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'rbconfig'
|
2
|
+
require 'find'
|
3
|
+
require 'ftools'
|
4
|
+
|
5
|
+
include Config
|
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
|
+
File::install(tmp_file, File.join($bindir, opfile), 0755, true)
|
41
|
+
File::unlink(tmp_file)
|
42
|
+
end
|
43
|
+
|
44
|
+
$sitedir = CONFIG["sitelibdir"]
|
45
|
+
unless $sitedir
|
46
|
+
version = CONFIG["MAJOR"]+"."+CONFIG["MINOR"]
|
47
|
+
$libdir = File.join(CONFIG["libdir"], "ruby", version)
|
48
|
+
$sitedir = $:.find {|x| x =~ /site_ruby/}
|
49
|
+
if !$sitedir
|
50
|
+
$sitedir = File.join($libdir, "site_ruby")
|
51
|
+
elsif $sitedir !~ Regexp.quote(version)
|
52
|
+
$sitedir = File.join($sitedir, version)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
$bindir = CONFIG["bindir"]
|
57
|
+
|
58
|
+
$realbindir = $bindir
|
59
|
+
|
60
|
+
bindir = CONFIG["bindir"]
|
61
|
+
if (destdir = ENV['DESTDIR'])
|
62
|
+
$bindir = destdir + $bindir
|
63
|
+
$sitedir = destdir + $sitedir
|
64
|
+
|
65
|
+
File::makedirs($bindir)
|
66
|
+
File::makedirs($sitedir)
|
67
|
+
end
|
68
|
+
|
69
|
+
rake_dest = File.join($sitedir, "rake")
|
70
|
+
File::makedirs(rake_dest, true)
|
71
|
+
File::chmod(0755, rake_dest)
|
72
|
+
|
73
|
+
# The library files
|
74
|
+
|
75
|
+
files = Dir.chdir('lib') { Dir['**/*.rb'] }
|
76
|
+
|
77
|
+
for fn in files
|
78
|
+
fn_dir = File.dirname(fn)
|
79
|
+
target_dir = File.join($sitedir, fn_dir)
|
80
|
+
if ! File.exist?(target_dir)
|
81
|
+
File.makedirs(target_dir)
|
82
|
+
end
|
83
|
+
File::install(File.join('lib', fn), File.join($sitedir, fn), 0644, true)
|
84
|
+
end
|
85
|
+
|
86
|
+
# and the executable
|
87
|
+
|
88
|
+
installBIN("bin/rake", "rake")
|
@@ -0,0 +1,8 @@
|
|
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
|
+
Task = Rake::Task
|
6
|
+
FileTask = Rake::FileTask
|
7
|
+
FileCreationTask = Rake::FileCreationTask
|
8
|
+
RakeApp = Rake::Application
|
data/lib/rake/clean.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# The 'rake/clean' file defines two file lists (CLEAN and CLOBBER) and
|
4
|
+
# two rake tasks (:clean and :clobber).
|
5
|
+
#
|
6
|
+
# [:clean] Clean up the project by deleting scratch files and backup
|
7
|
+
# files. Add files to the CLEAN file list to have the :clean
|
8
|
+
# target handle them.
|
9
|
+
#
|
10
|
+
# [:clobber] Clobber all generated and non-source files in a project.
|
11
|
+
# The task depends on :clean, so all the clean files will
|
12
|
+
# be deleted as well as files in the CLOBBER file list.
|
13
|
+
# The intent of this task is to return a project to its
|
14
|
+
# pristine, just unpacked state.
|
15
|
+
|
16
|
+
require 'rake'
|
17
|
+
|
18
|
+
CLEAN = Rake::FileList["**/*~", "**/*.bak", "**/core"]
|
19
|
+
CLEAN.clear_exclude.exclude { |fn|
|
20
|
+
fn.pathmap("%f") == 'core' && File.directory?(fn)
|
21
|
+
}
|
22
|
+
|
23
|
+
desc "Remove any temporary products."
|
24
|
+
task :clean do
|
25
|
+
CLEAN.each { |fn| rm_r fn rescue nil }
|
26
|
+
end
|
27
|
+
|
28
|
+
CLOBBER = Rake::FileList.new
|
29
|
+
|
30
|
+
desc "Remove any generated file."
|
31
|
+
task :clobber => [:clean] do
|
32
|
+
CLOBBER.each { |fn| rm_r fn rescue nil }
|
33
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
module Rake
|
4
|
+
|
5
|
+
# Manage several publishers as a single entity.
|
6
|
+
class CompositePublisher
|
7
|
+
def initialize
|
8
|
+
@publishers = []
|
9
|
+
end
|
10
|
+
|
11
|
+
# Add a publisher to the composite.
|
12
|
+
def add(pub)
|
13
|
+
@publishers << pub
|
14
|
+
end
|
15
|
+
|
16
|
+
# Upload all the individual publishers.
|
17
|
+
def upload
|
18
|
+
@publishers.each { |p| p.upload }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
|
@@ -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
|