reap 6.0.0 → 6.0.1

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,85 @@
1
+ # Ruby Treasures 0.4
2
+ # Copyright (C) 2002 Paul Brannan <paul@atdesk.com>
3
+ #
4
+ # You may distribute this software under the same terms as Ruby (see the file
5
+ # COPYING that was distributed with this library).
6
+ #
7
+ # Ruby Treasures 0.2
8
+ # Copyright (C) 2002 Paul Brannan <paul@atdesk.com>
9
+ #
10
+ # You may distribute this software under the same terms as Ruby (see the file
11
+ # COPYING that was distributed with this library).
12
+ #
13
+ # Run this Ruby script to prepare the RubyTreasures distribution for
14
+ # publication.
15
+
16
+ require 'find'
17
+ require 'ftools'
18
+
19
+
20
+ # Add licences to the top of every file and remove unnecessary files
21
+
22
+ license = IO.readlines('LICENSE')
23
+ ruby_license_comment = license.map { |i| i.sub(/^/, '# ') }
24
+ c_license_comment = ["/*\n"] + license.map { |i| i.sub(/^/, ' * ') } + [" */\n"]
25
+
26
+ def rm_rf(dir)
27
+ Dir.foreach(dir) do |f|
28
+ if not f =~ /\.?\.$/ then
29
+ filename = File.join(dir, f)
30
+ if File.directory?(filename) then
31
+ rm_rf(filename)
32
+ else
33
+ puts "Removing file #{filename}"
34
+ File.rm_f(filename)
35
+ end
36
+ end
37
+ end
38
+ puts "Removing directory #{dir}"
39
+ Dir.rmdir(dir)
40
+ end
41
+
42
+ Find.find('.') do |file|
43
+ if File.directory?(file) then
44
+ case file
45
+ when /\/CVS$/
46
+ # Remove CVS directories
47
+ rm_rf(file)
48
+ else
49
+ # Remove empty directories
50
+ entries = Dir.entries(file)
51
+ entries.delete('.')
52
+ entries.delete('..')
53
+ entries.delete('CVS')
54
+ if entries.length == 0 then
55
+ rm_rf(file)
56
+ end
57
+ end
58
+ else
59
+ case file
60
+ when /\.rb$/
61
+ # Add LICENSE to ruby sources
62
+ puts "Adding license to #{file}"
63
+ lines = ruby_license_comment + IO.readlines(file)
64
+ File.open(file, 'w') do |out|
65
+ lines.each do |line|
66
+ out.puts line
67
+ end
68
+ end
69
+ when /\.c$/
70
+ # Add LICENSE to C sources
71
+ puts "Adding license to #{file}"
72
+ lines = c_license_comment + IO.readlines(file)
73
+ File.open(file, 'w') do |out|
74
+ lines.each do |line|
75
+ out.puts line
76
+ end
77
+ end
78
+ when /~$/
79
+ # Remove temporary files
80
+ puts "Removing file #{file}"
81
+ File.rm_f(file)
82
+ end
83
+ end
84
+ end
85
+
@@ -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,247 @@
1
+
2
+ require "enumerator"
3
+ require "http-access2"
4
+
5
+ require 'reap/iface/interface.rb'
6
+
7
+
8
+ class RubyForgeInterface < Interface
9
+
10
+ attr_accessor :username, :password, :cookie_jar
11
+
12
+ def initialize( master, section )
13
+
14
+ @name = master['name']
15
+
16
+ @username = master['rubyforge']['username'] || section['username']
17
+
18
+ @packge_id = section['package_id']
19
+ @lockfile_id = section['lockfile_id']
20
+
21
+ @group_id = section['group_id'] || 1024 # this is codeforpeople. it's just a default...
22
+ @private = section['private'] ? 0 : 1
23
+
24
+ # internal use
25
+ @uri = "http://rubyforge.org"
26
+ @cookie_jar = File::join(File::expand_path("~"), ".rubyforge.cookie_jar")
27
+
28
+ end
29
+
30
+
31
+ # config = {
32
+ # "username" => "username", # this must be your username
33
+ # "password" => "password", # this must be your password
34
+ #
35
+ # "group_id" => 1024, # this is codeforpeople. it's just a default...
36
+ #
37
+ # "package_ids" => { # configure shortcuts for your packages here
38
+ # "traits" => 1241,
39
+ # "lockfile" => 1242,
40
+ # },
41
+ #
42
+ # "uri" => "http://rubyforge.org",
43
+ # "cookie_jar" => File::join(File::expand_path("~"), ".rubyforge.cookie_jar"),
44
+ # }
45
+ #
46
+ # opts =
47
+ # GetoptLong::new(
48
+ # [ "--username" , "-u" , GetoptLong::REQUIRED_ARGUMENT ] ,
49
+ # [ "--password" , "-p" , GetoptLong::REQUIRED_ARGUMENT ] ,
50
+ # [ "--cookie_jar" , "-c" , GetoptLong::REQUIRED_ARGUMENT ]
51
+ # ).enum_for.inject({}){|h,kv| h.update Hash[*kv]}
52
+ #
53
+ # username = opts['username'] || config['username']
54
+ # password = opts['password'] || config['password']
55
+ # cookie_jar = opts["cookie_jar"] || config['cookie_jar']
56
+ #
57
+ # setup
58
+ #
59
+ # mode = ARGV.shift
60
+ # abort "#{ $0 } [login|create_package (package_name)|add_package (package_id release_name release.ext)]" unless mode
61
+
62
+ def setup
63
+
64
+ page, form, method = nil
65
+ extheader = {}
66
+
67
+ case mode
68
+
69
+ when %r/login/
70
+ page = "/account/login.php"
71
+ method = "post_content"
72
+
73
+ form = {
74
+ "return_to" => "",
75
+ "form_loginname" => username,
76
+ "form_pw" => password,
77
+ "login" => "Login"
78
+ }
79
+
80
+ when %r/create_package/
81
+ page = "/frs/admin/index.php"
82
+ method = "post_content"
83
+
84
+ opts =
85
+ GetoptLong::new(
86
+ [ "--group_id" , "-g" , GetoptLong::REQUIRED_ARGUMENT ] ,
87
+ [ "--is_private" , "-P" , GetoptLong::REQUIRED_ARGUMENT ]
88
+ ).enum_for.inject({}){|h,kv| h.update Hash[*kv]}
89
+
90
+ package_name = ARGV.shift
91
+ abort "#{ $0 } package_name" unless package_name
92
+
93
+ group_id = opts["group_id"] || config["group_id"]
94
+ is_public = opts["is_private"] ? 0 : 1
95
+
96
+ form = {
97
+ "group_id" => group_id,
98
+ "package_name" => package_name,
99
+ "func" => "add_package",
100
+ "is_public" => is_public,
101
+ "submit" => "Create This Package",
102
+ }
103
+
104
+ when %r/add_release/
105
+ page = "/frs/admin/qrs.php"
106
+ method = "post_content"
107
+
108
+ opts =
109
+ GetoptLong::new(
110
+ [ "--group_id" , "-g" , GetoptLong::REQUIRED_ARGUMENT ] ,
111
+ [ "--release_date" , "-r" , GetoptLong::REQUIRED_ARGUMENT ] ,
112
+ [ "--type_id" , "-t" , GetoptLong::REQUIRED_ARGUMENT ] ,
113
+ [ "--processor_id" , "-P" , GetoptLong::REQUIRED_ARGUMENT ] ,
114
+ [ "--release_nots" , "-n" , GetoptLong::REQUIRED_ARGUMENT ] ,
115
+ [ "--release_changes" , "-a" , GetoptLong::REQUIRED_ARGUMENT ]
116
+ ).enum_for.inject({}){|h,kv| h.update Hash[*kv]}
117
+
118
+ package_id, release_name, userfile, ignored = ARGV
119
+ abort "#{ $0 } package_name" unless
120
+ package_id and release_name and userfile
121
+
122
+ package_id = config["package_ids"][package_id] unless
123
+ package_id =~ %r/^\d+$/
124
+
125
+ group_id = opts["group_id"] || config["group_id"]
126
+ release_date = opts["release_date"] || Time::now.strftime('%Y-%m-%d %H:%M')
127
+
128
+ type_id = opts['type_id'] || userfile[%r|\.[^\./]+$|]
129
+ type_id = {
130
+ ".deb" => 1000,
131
+ ".rpm" => 2000,
132
+ ".zip" => 3000,
133
+ ".bz2" => 3100,
134
+ ".gz" => 3110,
135
+ ".src.zip" => 5000,
136
+ ".src.bz2" => 5010,
137
+ ".src.gz" => 5020,
138
+ ".src.rpm" => 5100,
139
+ ".src" => 5900,
140
+ ".jpg" => 8000,
141
+ ".txt" => 8100,
142
+ ".text" => 8100,
143
+ ".htm" => 8200,
144
+ ".html" => 8200,
145
+ ".pdf" => 8300,
146
+ ".oth" => 9999,
147
+ ".ebuild" => 1300,
148
+ ".exe" => 1100,
149
+ ".dmg" => 1200,
150
+ ".tar.gz" => 5000,
151
+ ".tgz" => 5000,
152
+ ".gem" => 1400,
153
+ ".pgp" => 8150,
154
+ ".sig" => 8150,
155
+ }[type_id]
156
+
157
+ processor_id = opts['processor_id'] || 'Any'
158
+ processor_id = {
159
+ "i386" => 1000,
160
+ "IA64" => 6000,
161
+ "Alpha" => 7000,
162
+ "Any" => 8000,
163
+ "PPC" => 2000,
164
+ "MIPS" => 3000,
165
+ "Sparc" => 4000,
166
+ "UltraSparc" => 5000,
167
+ "Other" => 9999,
168
+ }[processor_id]
169
+
170
+ release_notes = opts['release_notes'] || nil
171
+ release_notes = open(release_notes) if release_notes
172
+
173
+ release_changes = opts['release_changes'] || nil
174
+ release_changes = open(release_changes) if release_changes
175
+
176
+ userfile = open(userfile)
177
+
178
+ preformatted = '1'
179
+
180
+ form = {
181
+ "group_id" => group_id,
182
+ "package_id" => package_id,
183
+ "release_name" => release_name,
184
+ "release_date" => release_date,
185
+ "type_id" => type_id,
186
+ "processor_id" => processor_id,
187
+ "preformatted" => preformatted,
188
+ "userfile" => userfile,
189
+ "submit" => "Release File"
190
+ }
191
+
192
+ boundary = Array::new(8){ "%2.2d" % rand(42) }.join('__')
193
+ extheader['content-type'] = "multipart/form-data; boundary=___#{ boundary }___"
194
+
195
+ else
196
+ abort "#{ $0 } login create_package add_release"
197
+
198
+ end
199
+ #
200
+ # http transaction
201
+ #
202
+ client = HTTPAccess2::Client::new ENV['HTTP_PROXY']
203
+ client.debug_dev = STDERR if ENV['DEBUG']
204
+
205
+ client.set_cookie_store cookie_jar
206
+
207
+ # fixes http-access2 bug
208
+ client.redirect_uri_callback = lambda do |res|
209
+ page = res.header['location'].first
210
+ page = page =~ %r/http/ ? page : "#{ config['uri'] }/#{ page }"
211
+ page
212
+ end
213
+
214
+ response = client.send "#{ method }", "#{ config['uri'] }/#{ page }", form, extheader
215
+
216
+ client.save_cookie_store
217
+
218
+ # fixes http-access2 bug
219
+ BEGIN {
220
+ require "http-access2"
221
+ module WebAgent::CookieUtils
222
+ def domain_match(host, domain)
223
+ case domain
224
+ when /\d+\.\d+\.\d+\.\d+/
225
+ return (host == domain)
226
+ when '.'
227
+ return true
228
+ when /^\./
229
+ #return tail_match?(domain, host)
230
+ return tail_match?(host, domain)
231
+ else
232
+ return (host == domain)
233
+ end
234
+ end
235
+ end
236
+
237
+ }
238
+
239
+
240
+
241
+
242
+
243
+
244
+ end
245
+
246
+
247
+
@@ -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,46 @@
1
+ #!/usr/bin/ruby
2
+
3
+ DEBUG = false
4
+ URI = "-dtransami@cvs.suby.berlios.de:/cvsroot/suby"
5
+
6
+ cmd = nil
7
+
8
+ case ARGV[0]
9
+ when 'checkout', 'co'
10
+ if ARGV[1] and ARGV[1] != ''
11
+ cmd = %Q{cvs -z3 #{URI} co "#{ARGV[1]}"}
12
+ else
13
+ puts "no module given"
14
+ cmd = nil
15
+ end
16
+ when 'commit'
17
+ if ARGV[1] and ARGV[1] != ''
18
+ cmd = %Q{cvs -z3 #{URI} commit -m "#{ARGV[1]}"}
19
+ else
20
+ puts "no commit message given"
21
+ cmd = nil
22
+ end
23
+ when 'update'
24
+ cmd = %Q{cvs -z3 #{URI} update}
25
+ when 'add'
26
+ if ARGV[1]
27
+ cmd = %Q{cvs -z3 #{URI} add #{ARGV[1..-1].join(' ')}}
28
+ else
29
+ puts "no files given to add"
30
+ cmd = nil
31
+ end
32
+ when 'remove'
33
+ if ARGV[1]
34
+ cmd = %Q{cvs -z3 #{URI} remove #{ARGV[1..-1].join(' ')}}
35
+ else
36
+ puts "no file given to remove"
37
+ cmd = nil
38
+ end
39
+ end
40
+
41
+ if DEBUG
42
+ puts cmd
43
+ elsif cmd
44
+ `#{cmd}`
45
+ end
46
+
data/forge/scaffold.rb ADDED
@@ -0,0 +1,126 @@
1
+ # ___ __ __ _ _ _____ _
2
+ # / __| __ __ _ / _|/ _|___| |__| | |_ _|_ _ __| |__
3
+ # \__ \/ _/ _` | _| _/ _ \ / _` | | |/ _` (_-< / /
4
+ # |___/\__\__,_|_| |_| \___/_\__,_| |_|\__,_/__/_\_\
5
+ #
6
+
7
+ # Current scaffold task just copies a folder. This incomplete
8
+ # version was an idea for dynamically creating the scaffolding
9
+ # instead.
10
+
11
+ #require 'rbconfig'
12
+
13
+
14
+ module Scaffold
15
+ extend self
16
+
17
+ SVNPaths => %w{
18
+ trunk
19
+ branch
20
+ tag
21
+ scrap
22
+ package
23
+ }
24
+
25
+ TrunkPaths = %w{
26
+ bin
27
+ lib
28
+ ext
29
+ conf
30
+ data
31
+ test
32
+ note
33
+ sample
34
+ }
35
+
36
+ TrunkFiles = %w{
37
+ README
38
+ INSTALL
39
+ COPYING
40
+ ProjectInfo
41
+ ChangeLog
42
+ Todo
43
+ RakeFile
44
+ setup.rb
45
+ }
46
+
47
+ def init( scf )
48
+ scf.name ||= 'yourlib.projectdomain.org'
49
+ end
50
+
51
+ def run( scf )
52
+ t = Time.now.strftime("%Y-%m-%d")
53
+ libdir = File.join( 'lib', "#{@name},#{t}" )
54
+
55
+ if @scm
56
+ SCMPaths.each { |d| makedir( d ) }
57
+ Dir.chdir 'trunk'
58
+ end
59
+ TrunkPaths.each { |d| makedir( d ) }
60
+ makedir_with_check( libdir )
61
+ TrunkFiles.each { |f| temlpate( f ) }
62
+ end
63
+
64
+ private
65
+
66
+ # Copy a file from lib/data to the current dir.
67
+
68
+ def template( filename )
69
+ dir = File.join( File.dirname(__FILE__), 'data' )
70
+ #dir = File.join( ::Config::CONFIG['datadir'], DATA_DIR )
71
+ f = File.join( dir, filename )
72
+ unless File.file?( f )
73
+ puts f
74
+ raise "Tempfile is missing."
75
+ end
76
+
77
+ if File.exists?(filename)
78
+ puts "#{filename} already exists."
79
+ return
80
+ end
81
+ # copy tmpf to Reapfile
82
+ FileUtils.cp( f, filename )
83
+ #puts "#{filename} created. You'll need to fill it out."
84
+ end
85
+
86
+ # Make a directory as long as it doesn't already exist.
87
+
88
+ def makedir( dir )
89
+ FileUtils.makedir_p( dir ) unless File.directory?( dir )
90
+ end
91
+
92
+ end
93
+
94
+
95
+
96
+ =begin
97
+ def scaffold
98
+ require 'reap/scaffold'
99
+ name =
100
+ domain =
101
+ Scaffold.go( name, domain )
102
+ end
103
+
104
+ def template( file_name = ProjectInfo )
105
+ #dir = File.dirname(File.dirname(__FILE__))
106
+ dir = File.join( ::Config::CONFIG['datadir'], DATA_DIR )
107
+
108
+ tmpf = File.join( dir, 'template.yaml' )
109
+ unless File.file?( tmpf )
110
+ puts tmpf
111
+ raise "Tempfile is missing."
112
+ end
113
+
114
+ if File.directory?(filename)
115
+ puts "#{filename} a directory. Cannot comply."
116
+ return
117
+ elsif File.file?(filename)
118
+ puts "#{filename} already exists."
119
+ return
120
+ end
121
+ # copy tmpf to Reapfile
122
+ FileUtils.cp( tmpf, filename )
123
+ puts "#{filename} created. You'll need to fill it out."
124
+ end
125
+ =end
126
+
@@ -0,0 +1,6 @@
1
+ I was playing with making Reaps forked tester
2
+ and the rubytest comment tester part of Test::Unit.
3
+ The code in this directory is the result of that
4
+ playing. It's didn't work out so well so I gave-up
5
+ on it. Just trash this code eventually. I left it here
6
+ just in case anyone might want to think about the idea.