reap 4.3.2 → 4.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. data/ANN +6 -1
  2. data/ProjectInfo +9 -7
  3. data/README +44 -13
  4. data/data/reap/setup-3.4.1/COPYING +515 -0
  5. data/data/reap/setup-3.4.1/ChangeLog +732 -0
  6. data/data/reap/setup-3.4.1/Makefile +56 -0
  7. data/data/reap/setup-3.4.1/NEWS.en +155 -0
  8. data/data/reap/setup-3.4.1/NEWS.ja +152 -0
  9. data/data/reap/setup-3.4.1/README.en +30 -0
  10. data/data/reap/setup-3.4.1/README.ja +34 -0
  11. data/data/reap/setup-3.4.1/TODO +14 -0
  12. data/data/reap/setup-3.4.1/Template.README.en +41 -0
  13. data/data/reap/setup-3.4.1/Template.README.ja +46 -0
  14. data/data/reap/setup-3.4.1/Usage_en.txt +231 -0
  15. data/data/reap/setup-3.4.1/Usage_ja.txt +250 -0
  16. data/data/reap/setup-3.4.1/doc.en/hookapi.html +91 -0
  17. data/data/reap/setup-3.4.1/doc.en/index.html +28 -0
  18. data/data/reap/setup-3.4.1/doc.en/metaconfapi.html +79 -0
  19. data/data/reap/setup-3.4.1/doc.en/news.html +189 -0
  20. data/data/reap/setup-3.4.1/doc.en/usage.html +297 -0
  21. data/data/reap/setup-3.4.1/doc.ja/hookapi.html +84 -0
  22. data/data/reap/setup-3.4.1/doc.ja/index.html +28 -0
  23. data/data/reap/setup-3.4.1/doc.ja/metaconfapi.html +80 -0
  24. data/data/reap/setup-3.4.1/doc.ja/news.html +186 -0
  25. data/data/reap/setup-3.4.1/doc.ja/usage.html +319 -0
  26. data/data/reap/setup-3.4.1/sample/add-task.rb +15 -0
  27. data/data/reap/setup-3.4.1/setup.rb +1585 -0
  28. data/data/reap/setup-3.4.1/test/test_installer.rb +136 -0
  29. data/lib/reap/{lint.rb → bin/lint.rb} +0 -0
  30. data/lib/reap/bin/reap.rb +3 -2
  31. data/lib/reap/projectinfo.rb +4 -0
  32. data/lib/reap/task.rb +84 -74
  33. data/lib/reap/task/announce.rb +137 -91
  34. data/lib/reap/task/fileperm.rb +26 -9
  35. data/lib/reap/task/info.rb +19 -3
  36. data/lib/reap/task/install.rb +9 -7
  37. data/lib/reap/task/noop.rb +3 -5
  38. data/lib/reap/task/package.rb +247 -105
  39. data/lib/reap/task/publish.rb +40 -14
  40. data/lib/reap/task/rdoc.rb +53 -27
  41. data/lib/reap/task/release.rb +275 -73
  42. data/lib/reap/task/scaffold.rb +14 -6
  43. data/lib/reap/task/test.rb +67 -48
  44. data/lib/reap/task/testext.rb +38 -11
  45. data/lib/reap/vendor/http-access2.rb +1590 -0
  46. data/lib/reap/vendor/http-access2/cookie.rb +538 -0
  47. data/lib/reap/vendor/http-access2/http.rb +542 -0
  48. data/{lib/reap → note}/interface/interface.rb +0 -0
  49. data/{lib/reap → note}/interface/rubyforge.rb +0 -0
  50. data/note/package.rb.0 +394 -0
  51. metadata +43 -8
  52. data/lib/reap/reap.rb +0 -0
@@ -2,40 +2,66 @@
2
2
 
3
3
  require 'reap/task'
4
4
 
5
+ # ___ _ _ _ _ _____ _
6
+ # | _ \_ _| |__| (_)__| |_ |_ _|_ _ __| |__
7
+ # | _/ || | '_ \ | (_-< ' \ | |/ _` (_-< / /
8
+ # |_| \_,_|_.__/_|_/__/_||_| |_|\__,_/__/_\_\
5
9
  #
6
- # Publish Task
7
- #
10
+
11
+ # = Publish Task
12
+
8
13
  class Reap::Publish < Reap::Task
9
14
 
10
15
  section_required true
11
16
 
12
17
  task_desc "Publish documents to the web."
13
18
 
14
- attr_accessor :host, :type, :dir, :project, :username
15
- attr_accessor :exclude # not using yet
19
+ task_help %{
20
+
21
+ reap publish
22
+
23
+ Publish documents to hosting service.
24
+ Currently only supports web publishing to Rubyforge.
25
+ Working on generalizing this more in future.
26
+
27
+ dir Directory of files to publish.
28
+ exclude Files not to include from directory.
29
+ project Project name.
30
+ username Username for host.
31
+
32
+ }
33
+
34
+ #attr_accessor :host, :type, :dir, :project, :username
35
+ #attr_accessor :exclude # not using yet
36
+
37
+ task_attr :pub
38
+
39
+ # Setup the publishing task.
16
40
 
17
41
  def init
18
- @type ||= 'www'
19
- @host ||= 'rubyforge.org'
20
- @project ||= master['rubyforge']['project'] || master['name']
21
- @username ||= master['rubyforge']['username']
22
- @exclude ||= []
42
+ pub.type ||= 'www'
43
+ pub.host ||= 'rubyforge.org'
44
+ pub.project ||= master.rubyforge.project || master.name
45
+ pub.username ||= master.rubyforge.username
46
+ pub.exclude ||= []
23
47
  end
24
48
 
49
+ # Run the publishing task.
50
+
25
51
  def run
26
52
  cmd = ''; skip = false
27
53
 
28
- case @host
54
+ case pub.host
29
55
  when 'rubyforge', 'rubyforge.org'
30
- case @type
56
+ case pub.type
31
57
  when 'www', 'web'
32
- cmd = %{scp -r #{@dir}/* #{@username}@rubyforge.org:/var/www/gforge-projects/#{@project}/}
58
+ cmd = %{scp -r #{pub.dir}/* #{pub.username}@rubyforge.org:/var/www/gforge-projects/#{pub.project}/}
33
59
  else
34
- puts %{Unrecognized publishing kind '#{@type}' for host '#{@host}'. Skipped.}
60
+ puts %{Unrecognized publishing kind '#{pub.type}' for host '#{pub.host}'. Skipped.}
35
61
  skip = true
36
62
  end
37
63
  else
38
- puts %{Unrecognized publishing host '#{@host}'. Skipped.}
64
+ puts %{Unrecognized publishing host '#{pub.host}'. Skipped.}
39
65
  skip = true
40
66
  end
41
67
 
@@ -1,46 +1,72 @@
1
1
 
2
2
  require 'reap/task'
3
3
 
4
+ # ___ _ _____ _
5
+ # | _ \__| |___ __ |_ _|_ _ __| |__
6
+ # | / _` / _ \/ _| | |/ _` (_-< / /
7
+ # |_|_\__,_\___/\__| |_|\__,_/__/_\_\
4
8
  #
5
- # RDoc Task
6
- #
9
+
10
+ # = RDoc Task
11
+
7
12
  class Reap::RDoc < Reap::Task
8
13
 
14
+ MUST_EXCLUDE = [ 'InstalledFiles', 'CVS/**/*' ]
15
+
9
16
  task_desc "Generate RDocs."
10
17
 
11
- attr_accessor :dir, :main, :title, :template,
12
- :include, :exclude, :options
18
+ task_help %{
19
+
20
+ reap rdoc
21
+
22
+ Generate RDoc doumentation.
23
+
24
+ dir Directory to store documentation [doc].
25
+ main File to use as main page of RDocs.
26
+ title Project title to use in RDocs.
27
+ template Which RDoc template to use.
28
+ include Files to include in RDocs.
29
+ exclude Files to exclude from those.
30
+ options Pass-thru extra options to RDoc command.
31
+
32
+ }
33
+
34
+ task_attr :doc
35
+
36
+ # Setup documentation task.
13
37
 
14
38
  def init
15
- @dir ||= 'doc'
16
- @main ||= 'README'
17
- @title ||= master["title"]
18
- @template ||= 'html' # 'jamis'
19
- @include ||= [ 'A-Z*', 'lib/**/*', 'ext/**/*' ]
20
- @exclude ||= [ 'demo/**/*', 'example/**/*', 'sample/**/*' ]
21
- @options ||= ['--merge', '--all']
39
+ doc.dir ||= 'doc'
40
+ doc.main ||= 'README'
41
+ doc.title ||= master.title
42
+ doc.template ||= 'html' # 'jamis'
43
+ doc.include ||= [ 'A-Z*', 'lib/**/*', 'ext/**/*' ]
44
+ doc.exclude ||= [ 'demo/**/*', 'example/**/*', 'sample/**/*' ]
45
+ doc.options ||= ['--merge', '--all']
22
46
  end
23
47
 
48
+ # Run the Ruby documentation task.
49
+
24
50
  def run
25
- must_exclude = [ 'InstalledFiles', 'CVS/**/*' ]
51
+ #must_exclude = [ 'InstalledFiles', 'CVS/**/*' ]
26
52
 
27
- if !File.exists?(@main) or File.directory?(@main)
28
- warn "Specified RDoc Main file #{@main} not found. Ignored."
29
- @main = nil
53
+ if !File.exists?(doc.main) or File.directory?(doc.main)
54
+ warn "WARNING! Specified RDoc Main file #{doc.main} not found."
55
+ doc.main = nil
30
56
  end
31
57
 
32
- rdoc_dir = File.expand_path(@dir)
58
+ rdoc_dir = File.expand_path(doc.dir)
33
59
 
34
- if FileTest.directory?(@dir)
35
- print "Directory '#{@dir}' already exists. Clobber? [y/N] "
60
+ if FileTest.directory?(doc.dir)
61
+ print "Directory '#{doc.dir}' already exists. Clobber? [y/N] "
36
62
  until inp = $stdin.gets[0,1] ; sleep 1 ; end ; puts
37
63
  if (inp || 'y').downcase == 'y'
38
64
  puts "Removing old directory '#{rdoc_dir}'..."
39
65
  #FileUtils.mkdir_p(".trash") unless FileTest.directory?(".trash")
40
- #trashdir = ".trash/#{File.basename(@dir)}"
66
+ #trashdir = ".trash/#{File.basename(doc.dir)}"
41
67
  #FileUtils.rm_r(trashdir) if FileTest.exists?(trashdir)
42
- #FileUtils.mv(@dir, trashdir)
43
- FileUtils.rm_r(@dir) unless $PRETEND
68
+ #FileUtils.mv(doc.dir, trashdir)
69
+ FileUtils.rm_r(doc.dir) unless $PRETEND
44
70
  else
45
71
  puts "Reap rdoc task canceled."
46
72
  return nil
@@ -50,13 +76,13 @@ class Reap::RDoc < Reap::Task
50
76
  rdoc_target = "#{rdoc_dir}/index.html"
51
77
 
52
78
  exc = []
53
- (@exclude + must_exclude).each{ |e|
79
+ (doc.exclude + MUST_EXCLUDE).each{ |e|
54
80
  exc << e
55
81
  exc |= Dir.glob(e+'/**/*')
56
82
  }
57
83
 
58
84
  inc = Dir.glob('[A-Z]*')
59
- @include.each{ |i| inc |= Dir.glob(i) }
85
+ doc.include.each{ |i| inc |= Dir.glob(i) }
60
86
  inc -= exc
61
87
 
62
88
  inc = inc.select{ |f| File.file?(f) }
@@ -66,10 +92,10 @@ class Reap::RDoc < Reap::Task
66
92
 
67
93
  # build options string
68
94
  build = []
69
- build += @options
70
- build << "--main '#{@main}'" if @main
71
- build << "--title '#{@title}'" if @title
72
- build << "-T '#{@template}'" if @template
95
+ build += doc.options
96
+ build << "--main '#{doc.main}'" if doc.main
97
+ build << "--title '#{doc.title}'" if doc.title
98
+ build << "-T '#{doc.template}'" if doc.template
73
99
  rdoc_opts = build.join(' ')
74
100
 
75
101
  # do it!
@@ -1,14 +1,17 @@
1
- require 'reap/task'
2
-
3
1
  require "enumerator"
4
- require "http-access2"
5
2
 
3
+ require 'reap/task'
4
+ require "reap/vendor/http-access2"
6
5
 
7
- #
8
- # Release Task
6
+ # ___ _ _____ _
7
+ # | _ \___| |___ __ _ ___ ___ |_ _|_ _ __| |__
8
+ # | / -_) / -_) _` (_-</ -_) | |/ _` (_-< / /
9
+ # |_|_\___|_\___\__,_/__/\___| |_|\__,_/__/_\_\
9
10
  #
10
11
 
11
- # This Rake task releases files to RubyForge and other GForge instaces
12
+ # = Release Task
13
+ #
14
+ # This task releases files to RubyForge and other GForge instaces
12
15
  # or SourceForge clones. In its most simple usage it looks like:
13
16
  #
14
17
  # project = MetaProject::Project::XForge::RubyForge.new('xforge')
@@ -63,63 +66,135 @@ require "http-access2"
63
66
 
64
67
  class Reap::Release < Reap::Task
65
68
 
69
+ section_required true
70
+
66
71
  task_desc "Release distribution files."
67
72
 
68
- section_required true
73
+ task_help %{
74
+
75
+ reap release
76
+
77
+ Release distribution to Rubyforge, or other
78
+ GForge based service.
69
79
 
70
- attr_accessor :project, :version
71
- attr_accessor :host, :username, :password
72
- attr_accessor :package, :packageid, :groupid, :private, :processor
73
- attr_accessor :name, :changes, :notes, :changelog, :notelog
74
- attr_accessor :cookiejar
80
+ host URL of host service
81
+ username Username of host service
82
+ project Project name at host
83
+ package Package name
84
+ groupid Group id number
85
+ architecture Architecture (Any, i386, PPC, etc.)
86
+ release Release name
87
+ private Private release?
88
+ changelog Change log file
89
+ notelog Release notes file
90
+ dir Distribution directory
91
+ exclude Distribution types to exclude
92
+
93
+ }
94
+
95
+ task_attr :rel
96
+
97
+ #attr_accessor :project, :version
98
+ #attr_accessor :host, :username, :password
99
+ #attr_accessor :package, :packageid, :groupid, :private, :processor
100
+ #attr_accessor :name, :changes, :notes, :changelog, :notelog
101
+ #attr_accessor :cookiejar
75
102
 
76
103
  def init
77
- @project ||= master['rubyforge']['project'] || master['name']
78
- @version ||= master['version'] || master['date']
104
+ #rel.version ||= master.date
105
+
106
+ rel.host ||= 'rubyforge.org'
107
+ rel.host.chomp!('/')
79
108
 
80
- @host ||= 'rubyforge.org'
81
- @username ||= master['rubyforge']['username']
82
- @password ||= master['rubyforge']['password']
109
+ rel.username ||= master.rubyforge.username
110
+ #rel.password ||= master.rubyforge.password
83
111
 
84
- @package ||= master['rubyforge']['package']
85
- @packageid ||= master['rubyforge']['packageid']
86
- @groupid ||= master['rubyforge']['groupid']
87
- @private ||= false
88
- @processor ||= 'Any'
112
+ rel.project ||= master.rubyforge.project || master.name
113
+ rel.package ||= master.rubyforge.package
114
+ #rel.packageid ||= master.rubyforge.packageid
115
+ rel.groupid ||= master.rubyforge.groupid
116
+ rel.private ||= false
117
+ rel.processor ||= 'Any'
89
118
 
90
- #@files ||= section['files']
91
- @name ||= master['version'] || master['date']
92
- @date ||= master['date'] || Time::now.strftime('%Y-%m-%d %H:%M')
119
+ rel.date ||= Time::now.strftime('%Y-%m-%d %H:%M')
93
120
 
94
- @cookiejar ||= File::join(File::expand_path("~"), ".rubyforge.cookie_jar")
121
+ rel.exclude ||= []
122
+ rel.exclude << 'tar.gz' if rel.exclude.include?( 'tgz' )
123
+ rel.exclude << 'tgz' if rel.exclude.include?( 'tar.gz' )
124
+ rel.exclude << 'tar.bz2' if rel.exclude.include?( 'tbz' )
125
+ rel.exclude << 'tbz' if rel.exclude.include?( 'tar.bz2' )
126
+
127
+ rel.cookie_jar ||= File::join(File::expand_path("~"), ".rubyforge.cookie_jar")
128
+
129
+ # Do not inherit
130
+ rel.dir = section.dir || master.project.dir
131
+ rel.release = section.release || master.version || rel.date
95
132
  end
96
133
 
97
- # run task
134
+ # Run release task.
98
135
 
99
136
  def run
100
- abort "missing field -- package" unless @package
101
- abort "missing field -- packageid" unless @packageid
102
- abort "missing field -- groupid" unless @groupid
137
+
138
+ abort "missing field -- package" unless rel.package
139
+ #abort "missing field -- packageid" unless rel.packageid
140
+ abort "missing field -- groupid" unless rel.groupid
103
141
  # add more...
104
142
 
105
- case @host
106
- when 'rubyforge', 'rubyforge.org'
107
- else
108
- puts %{Unrecognized release host '#{@host}'. Skipped.}
109
- skip = true
110
- end
143
+ # case rel.host
144
+ # when 'rubyforge', 'rubyforge.org'
145
+ # else
146
+ # puts %{Unrecognized release host '#{rel.host}'. Skipped.}
147
+ # skip = true
148
+ # end
149
+
150
+ puts "Reap is preparing release ..."
151
+
152
+ rtypes = [ 'tgz', 'tbz', 'tar.gz', 'tar.bz2', 'deb', 'gem', 'ebuild' ]
153
+ rtypes -= rel.exclude
154
+ rtypes = rtypes.collect { |rt| Regexp.escape( rt ) }
155
+ re_rtypes = Regexp.new( '[.](' << rtypes.join('|') << ')$' )
156
+
157
+ dir = File.join( rel.dir, "#{rel.name}-#{rel.version}" )
158
+ files = Dir.entries(dir).select { |f|
159
+ f =~ re_rtypes or f == 'PKGBUILD'
160
+ }
161
+ files = files.collect { |f| File.join( rel.dir, f ) }
162
+
163
+ if files.empty?
164
+ puts "No files to release at #{dir}."
165
+ exit -1
166
+ end
167
+
168
+ # ask for password
169
+ print "Password for #{rel.username}: "
170
+ until passwd = $stdin.gets.strip ; sleep 1 ; end
171
+ @password = passwd
172
+
173
+ login {
174
+
175
+ unless package?
176
+ exit 0
177
+ create_package
178
+ end
179
+
180
+ if release?
181
+ exit 0
182
+ files.each do |f|
183
+ remove_file( f ) if file?( f )
184
+ add_file( f )
185
+ end
186
+ else
187
+ exit 0
188
+ add_release( files.unshift )
189
+ files.each { |f| add_file( f ) }
190
+ end
191
+
192
+ }
111
193
 
112
- unless skip
113
- puts "Reap is preparing release ..."
114
- @password = get_password
115
- login
116
- #create_package (doesn't fit)
117
- add_release( @file.unshift )
118
- @files.each { |f| add_file( f ) }
119
- add_release
120
- end
121
194
  end
122
195
 
196
+ private
197
+
123
198
  FILETYPES = {
124
199
  ".deb" => 1000,
125
200
  ".rpm" => 2000,
@@ -160,60 +235,117 @@ class Reap::Release < Reap::Task
160
235
  "Other" => 9999,
161
236
  }
162
237
 
163
-
164
238
  # login
165
239
 
166
- def login
240
+ def login( &block )
241
+ # login
167
242
  page = "/account/login.php"
168
243
  method = "post_content"
169
244
  form = {
170
- "return_to" => "",
171
- "form_loginname" => @username,
172
- "form_pw" => @password,
173
- "login" => "Login"
245
+ "return_to" => "",
246
+ "form_loginname" => rel.username,
247
+ "form_pw" => @password,
248
+ "login" => "Login"
174
249
  }
175
250
  http_transaction( page, method, form )
251
+
252
+ # do whatever
253
+ block.call
254
+
255
+ # logout
256
+ page = "/account/logout.php"
257
+ method = "" #"post_content"
258
+ form = {}
259
+ http_transaction( page, method, form )
176
260
  end
177
261
 
178
- # create a new package ( should be another task )
262
+ # Package exists?
263
+
264
+ def package?
265
+ page = "/frs/"
266
+ method = "post_content"
267
+ form = {
268
+ "group_id" => rel.groupid
269
+ }
270
+ scrape = http_transaction( page, method, form )
271
+
272
+ restr = ''
273
+ restr << Regexp.escape( rel.package )
274
+ restr << '\s*'
275
+ restr << Regexp.escape( %{<a href="/frs/monitor.php?filemodule_id=} )
276
+ restr << '(\d+)'
277
+ restr << Regexp.escape( %{&group_id=#{rel.groupid}} )
278
+ re = Regexp.new( restr )
279
+
280
+ md = re.match( scrape )
281
+ if md
282
+ rel.packageid = md[1]
283
+ end
284
+ end
285
+
286
+ # Create a new package.
179
287
 
180
288
  def create_package
181
289
  page = "/frs/admin/index.php"
182
290
  method = "post_content"
183
291
  form = {
184
- "group_id" => @groupid,
185
- "package_name" => @package,
292
+ "group_id" => rel.groupid,
293
+ "package_name" => rel.package,
186
294
  "func" => "add_package",
187
- "is_public" => (@private ? 0 : 1),
188
- "submit" => "Create This Package",
295
+ "is_public" => (rel.private ? 0 : 1),
296
+ "submit" => "Create This Package"
189
297
  }
190
298
  http_transaction( page, method, form )
191
299
  end
192
300
 
193
- # add a new release
301
+ # Release exits?
302
+
303
+ def release?
304
+ page = "/frs/admin/showreleases.php"
305
+ method = "post_content"
306
+ form = {
307
+ "package_id" => rel.packageid,
308
+ "group_id" => rel.groupid
309
+ }
310
+ scrape = http_transaction( page, method, form )
311
+
312
+ restr = ''
313
+ restr << Regexp.escape( %{"editrelease.php?group_id=#{rel.groupid}} )
314
+ restr << Regexp.escape( %{&amp;package_id=#{rel.packageid}} )
315
+ restr << Regexp.escape( %{&amp;release_id=} )
316
+ restr << '(\d+)'
317
+ restr << Regexp.escape( %{">#{rel.release}} )
318
+ re = Regexp.new( restr )
319
+
320
+ md = re.match( scrape )
321
+ if md
322
+ rel.releaseid = md[1]
323
+ end
324
+ end
325
+
326
+ # Add a new release.
194
327
 
195
328
  def add_release( userfile )
196
329
  page = "/frs/admin/qrs.php"
197
330
  method = "post_content"
198
331
 
199
- type_id = @type || userfile[%r|\.[^\./]+$|]
332
+ type_id = rel.type || userfile[%r|\.[^\./]+$|]
200
333
  type_id = FILETYPES[type_id]
201
-
202
- proc_id = PROCESSORS[@processor]
334
+ proc_id = PROCESSORS[rel.processor]
203
335
 
204
336
  # how to use these?
205
- notes = @notes ? @notes : ( @notelog ? open(@notelog) : nil )
206
- changes = @changes ? @changes : ( @changelog ? open(@changelog) : nil )
337
+ notes = rel.notes ? rel.notes : ( rel.notelog ? open(rel.notelog) : nil )
338
+ changes = rel.changes ? rel.changes : ( rel.changelog ? open(rel.changelog) : nil )
207
339
 
208
- userfile = open(userfile)
340
+ userfile = open(rel.userfile)
209
341
 
210
342
  preformatted = '1'
211
343
 
212
344
  form = {
213
- "group_id" => @groupid,
214
- "package_id" => @packageid,
215
- "release_name" => @name,
216
- "release_date" => @date,
345
+ "group_id" => rel.groupid,
346
+ "package_id" => rel.packageid,
347
+ "release_name" => rel.name,
348
+ "release_date" => rel.date,
217
349
  "type_id" => type_id,
218
350
  "processor_id" => proc_id,
219
351
  "preformatted" => preformatted,
@@ -227,12 +359,77 @@ class Reap::Release < Reap::Task
227
359
  http_transaction( page, method, form, extheader )
228
360
  end
229
361
 
230
- # add file to release
362
+ # Does file exist?
363
+
364
+ # Note this is a little bit fragile.
365
+ # If two releases have the same exact file name in them
366
+ # there could be a problem --that's probably not likely,
367
+ # maybe even impossible, but as of yet, I can't yet rule it out.
368
+
369
+ def file?( file )
370
+ page = "/frs/"
371
+ method = "post_content"
372
+ form = {
373
+ "group_id" => rel.groupid
374
+ }
375
+ scrape = http_transaction( page, method, form )
376
+
377
+ restr = ''
378
+ restr << Regexp.escape( rel.package )
379
+ restr << '\s*'
380
+ restr << Regexp.escape( %{<a href="/frs/download.php/} )
381
+ restr << '(\d+)'
382
+ restr << Regexp.escape( %{/#{file}} )
383
+ re = Regexp.new( restr )
384
+
385
+ md = re.match( scrape )
386
+ if md
387
+ rel.fileid = md[1]
388
+ end
389
+ end
390
+
391
+ # Remove file from release.
392
+
393
+ def remove_file( file )
394
+ page="/frs/admin/editrelease.php"
395
+ method = "post_content"
396
+ form = {
397
+ "group_id" => rel.groupid,
398
+ "package_id" => rel.packageid,
399
+ "release_id" => rel.releaseid,
400
+ "file_id" => rel.fileid,
401
+ "step3" => "Delete File",
402
+ "im_sure" => '1',
403
+ "submit" => "Delete File "
404
+ }
405
+
406
+ http_transaction( page, method, form )
407
+ end
408
+
409
+ # Add file to release.
231
410
 
232
411
  def add_file( userfile )
412
+ page = '/frs/admin/editrelease.php'
413
+ method = "post_content"
233
414
 
234
- # to do
415
+ type_id = rel.type || userfile[%r|\.[^\./]+$|]
416
+ type_id = FILETYPES[type_id]
417
+ proc_id = PROCESSORS[rel.processor]
418
+
419
+ userfile = open( userfile )
235
420
 
421
+ form = {
422
+ "group_id" => rel.groupid,
423
+ "package_id" => rel.packageid,
424
+ "release_id" => rel.releaseid,
425
+ "step2" => '1',
426
+ "userfile" => userfile,
427
+ "type_id" => type_id,
428
+ "processor_id" => proc_id,
429
+ "submit" => "Add This File"
430
+ }
431
+
432
+ http_transaction( page, method, form ) #, extheader )
236
433
  end
237
434
 
238
435
  # http transaction
@@ -240,21 +437,25 @@ class Reap::Release < Reap::Task
240
437
  def http_transaction( page, method, form, extheader={} )
241
438
  client = HTTPAccess2::Client::new ENV['HTTP_PROXY']
242
439
  client.debug_dev = STDERR if ENV['DEBUG']
243
- client.set_cookie_store cookie_jar
440
+ client.set_cookie_store( rel.cookie_jar )
244
441
  # fixes http-access2 bug
245
442
  client.redirect_uri_callback = lambda do |res|
246
443
  page = res.header['location'].first
247
- page = page =~ %r/http/ ? page : "#{ config['uri'] }/#{ page }"
444
+ page = page =~ %r/http/ ? page : "http://#{ rel.host }/#{ page }"
248
445
  page
249
446
  end
250
- response = client.send "#{ method }", "#{ config['uri'] }/#{ page }", form, extheader
447
+ page.sub!(/^\//, '')
448
+ uri = "http://#{ rel.host }/#{ page }"
449
+ response = client.send method, uri, form, extheader
251
450
  client.save_cookie_store
451
+ return response
252
452
  end
253
453
 
454
+ end
254
455
 
255
456
  # fixes http-access2 bug
256
457
  BEGIN {
257
- require "http-access2"
458
+ require "reap/vendor/http-access2"
258
459
  module WebAgent::CookieUtils
259
460
  def domain_match(host, domain)
260
461
  case domain
@@ -271,3 +472,4 @@ BEGIN {
271
472
  end
272
473
  end
273
474
  }
475
+