fauna-echoe 3.2

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.
@@ -0,0 +1,25 @@
1
+ # Fixes for Rubyforge 1.0.0 client.rb
2
+
3
+ class RubyForge::Client
4
+ def boundary_data_for(boundary, parameters)
5
+ parameters.sort_by {|k,v| k.to_s }.map { |k,v|
6
+ parameter = "--#{boundary}\r\nContent-Disposition: form-data; name=\"" +
7
+ WEBrick::HTTPUtils.escape_form(k.to_s) + "\""
8
+
9
+ if v.respond_to?(:path)
10
+ parameter += "; filename=\"#{File.basename(v.path)}\"\r\n"
11
+ parameter += "Content-Transfer-Encoding: binary\r\n"
12
+ parameter += "Content-Type: text/plain"
13
+ end
14
+ parameter += "\r\n\r\n"
15
+
16
+ if v.respond_to?(:path)
17
+ parameter += v.read
18
+ elsif
19
+ parameter += v.to_s
20
+ end
21
+
22
+ parameter
23
+ }.join("\r\n") + "\r\n--#{boundary}--\r\n"
24
+ end
25
+ end
@@ -0,0 +1,57 @@
1
+
2
+ class String #:nodoc:
3
+ def uncapitalize #:nodoc:
4
+ "#{self[0..0].downcase}#{self[1..-1]}"
5
+ end
6
+ end
7
+
8
+ class ::Rake::SshDirPublisher # :nodoc:
9
+ attr_reader :host, :remote_dir, :local_dir
10
+ end
11
+
12
+ class Echoe
13
+
14
+ def self.silence
15
+ if !ENV['VERBOSE']
16
+ stdout, stderr = $stdout.clone, $stderr.clone
17
+ $stdout.reopen(File.new('/tmp/stdout.echoe', 'w'))
18
+ $stderr.reopen(File.new('/tmp/stderr.echoe', 'w'))
19
+ begin
20
+ yield
21
+ ensure
22
+ $stdout.reopen(stdout)
23
+ $stderr.reopen(stderr)
24
+ end
25
+ else
26
+ yield
27
+ end
28
+ end
29
+
30
+ end
31
+
32
+ # Redefine instead of chain a Rake task
33
+ # http://www.bigbold.com/snippets/posts/show/2032
34
+
35
+ module Rake
36
+ module TaskManager
37
+ def redefine_task(task_class, *args, &block)
38
+ task_name, deps = resolve_args(args)
39
+ task_name = task_class.scope_name(@scope, task_name)
40
+ deps = [deps] unless deps.respond_to?(:to_ary)
41
+ deps = deps.collect {|d| d.to_s }
42
+ task = @tasks[task_name.to_s] = task_class.new(task_name, self)
43
+ task.application = self
44
+ task.send(:add_comment, @last_comment)
45
+ @last_comment = nil
46
+ task.enhance(deps, &block)
47
+ task
48
+ end
49
+ end
50
+ class Task
51
+ class << self
52
+ def redefine_task(*args, &block)
53
+ Rake.application.redefine_task(self, *args, &block)
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,7 @@
1
+
2
+ require 'net/https'
3
+
4
+ # Unbreak Rubyforge 1.0.2 on Ruby1.9
5
+ class Net::HTTP
6
+ alias :use_ssl= :old_use_ssl=
7
+ end
@@ -0,0 +1,38 @@
1
+
2
+ ### Platform check regexes
3
+
4
+ class Echoe
5
+ module Platform
6
+ def self.windows?
7
+ @windows ||= RUBY_PLATFORM =~ /djgpp|(cyg|ms|bcc)win|mingw/
8
+ !@windows.nil?
9
+ end
10
+
11
+ def self.gcc?
12
+ @gcc ||= RUBY_PLATFORM =~ /mingw/
13
+ !@gcc.nil?
14
+ end
15
+
16
+ def self.msvc?
17
+ @msvc ||= RUBY_PLATFORM =~ /mswin/
18
+ !@msvc.nil?
19
+ end
20
+
21
+ def self.java?
22
+ @java ||= RUBY_PLATFORM =~ /java/
23
+ !@java.nil?
24
+ end
25
+
26
+ def self.suffix
27
+ @suffix ||= Gem.default_exec_format[2..-1]
28
+ end
29
+
30
+ def self.rake
31
+ windows? ? "rake#{suffix}.bat" : "rake#{suffix}"
32
+ end
33
+
34
+ def self.make
35
+ msvc? ? 'nmake' : 'make'
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,41 @@
1
+ ### Overrides for cross packaging, which Rubygems 0.9.5 doesn't do
2
+
3
+ module Gem
4
+ class Specification
5
+
6
+ alias :old_validate :validate
7
+
8
+ PLATFORM_CROSS_TARGETS = ["aix", "cygwin", "darwin", "freebsd", "hpux", "java", "linux", "mingw", "mswin", "netbsdelf", "openbsd", "solaris", "_platform", "jruby"]
9
+
10
+ def validate
11
+ begin
12
+ old_validate
13
+ rescue Gem::InvalidSpecificationException
14
+ if platform =~ /(#{PLATFORM_CROSS_TARGETS.join("|")})/i
15
+ true
16
+ else
17
+ raise Gem::InvalidSpecificationException, "Unknown package target \"#{platform}\"."
18
+ end
19
+ end
20
+ end
21
+
22
+ end
23
+ end
24
+
25
+ ### Some runtime Echoe hacks
26
+
27
+ $platform = "ruby" # or Gem::PLATFORM::RUBY maybe
28
+
29
+ def reset_target target #:nodoc:
30
+ $platform = target
31
+ Object.send(:remove_const, "RUBY_PLATFORM")
32
+ Object.send(:const_set, "RUBY_PLATFORM", target)
33
+ end
34
+
35
+ if target = ARGV.detect do |arg|
36
+ # Hack to get the platform set before the Rakefile evaluates
37
+ Gem::Specification::PLATFORM_CROSS_TARGETS.include? arg
38
+ end
39
+ reset_target target
40
+ end
41
+
@@ -0,0 +1,21 @@
1
+ Copyright (c) 2003, 2004 Jim Weirich
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
@@ -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