srcforge 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
 
2
2
  This script allows you to easily automate the downloading of
3
3
  the latest version of any sourceforge project (as stored up
4
- to 31/03/2006) from any of sourceforge server by having it
4
+ to 31/12/2006) from any of sourceforge server by having it
5
5
  parse the web pages for the project and extract the latest
6
6
  release.
7
7
  It supports connecting through a proxy if either the
@@ -46,7 +46,7 @@ class SourceForge
46
46
 
47
47
  This script allows you to easily automate the downloading of
48
48
  the latest version of any sourceforge project (as stored up
49
- to 31/03/2006) from any of sourceforge server by having it
49
+ to 31/12/2006) from any of sourceforge server by having it
50
50
  parse the web pages for the project and extract the latest
51
51
  release.
52
52
  It supports connecting through a proxy if either the
@@ -124,7 +124,8 @@ EOH
124
124
  http = @proxy.start(url.host)
125
125
  res = http.request(req)
126
126
  if res.code.to_i != 200
127
- $stderr.puts "Could not open connection to sourceforge. Error code: #{res.code}"
127
+ $stderr.puts "Could not open connection to sourceforge. "
128
+ $stderr.puts "Error code: #{res.code}"
128
129
  $stderr.puts res.message
129
130
  $stderr.puts res.body
130
131
  exit(res.code.to_i)
@@ -151,7 +152,7 @@ EOH
151
152
  p.feed( res.body )
152
153
  xml = p.tree
153
154
 
154
- re = /^http:\/\/prdownloads\.sourceforge\.net\/#{@project}\/([^\?]+)/
155
+ re = /^http:\/\/(pr)?downloads\.sourceforge\.net\/#{@project}\/([^\?]+)/
155
156
 
156
157
  files = []
157
158
  xml.elements.each('//tr/td/a') { |x|
@@ -160,7 +161,7 @@ EOH
160
161
  next if clas != 'show'
161
162
  attr = x.attributes['href']
162
163
  next if attr !~ re
163
- files << $1
164
+ files << $2
164
165
  }
165
166
 
166
167
  return files
@@ -259,6 +260,8 @@ EOH
259
260
  def filter_downloads(filter)
260
261
  checksums = @downloads.grep(/\.#{CHECKSUMS}$/i)
261
262
 
263
+ @downloads -= checksums
264
+
262
265
  filter.each { |re|
263
266
  unless @downloads.grep(re).empty?
264
267
  @downloads.delete_if { |f| f !~ re }
@@ -267,11 +270,15 @@ EOH
267
270
  }
268
271
 
269
272
  @downloads.each { |d|
270
- item = checksums.grep(/^#{d}\.#{CHECKSUMS}$/)
273
+ root = d.sub(/\.\w+$/, '')
274
+ item = ( checksums.grep(/^#{d}\.#{CHECKSUMS}$/) +
275
+ checksums.grep(/^#{root}\.#{CHECKSUMS}$/) )
271
276
  next if item.empty?
272
277
  @checksums << item[0]
273
278
  }
279
+
274
280
  @downloads += @checksums
281
+ @downloads.sort!
275
282
  end
276
283
 
277
284
  #
@@ -386,6 +393,8 @@ EOH
386
393
  end
387
394
 
388
395
  filter_downloads(filter)
396
+ elsif @downloads.size > 1
397
+ filter_downloads([ /(?!#{CHECKSUMS})$/i ])
389
398
  end
390
399
  end
391
400
 
@@ -425,6 +434,8 @@ EOH
425
434
  exit(1)
426
435
  end
427
436
 
437
+ @checksums = @downloads.grep(/\.#{CHECKSUMS}$/i)
438
+
428
439
  start_downloads
429
440
  end
430
441
 
@@ -443,7 +454,7 @@ EOH
443
454
  File.open(c, 'r') { |cm|
444
455
  while not cm.eof?
445
456
  line = cm.readline
446
- checksum, file = line.split(/\s+/)
457
+ checksum, file = line.split(/\s+\*?/)
447
458
  sum = Digest::MD5.new
448
459
  File.open(file, 'rb') { |f|
449
460
  while not f.eof?
@@ -455,6 +466,7 @@ EOH
455
466
  puts "FAILED!!!"
456
467
  else
457
468
  puts "OK"
469
+ File.unlink c
458
470
  end
459
471
  end
460
472
  }
@@ -2,7 +2,7 @@ require "rubygems"
2
2
 
3
3
  spec = Gem::Specification.new do |spec|
4
4
  spec.name = "srcforge"
5
- spec.version = '1.0.1'
5
+ spec.version = '1.0.2'
6
6
  spec.author = "Gonzalo Garramuno"
7
7
  spec.email = 'ggarram@advance.dsl.com.ar'
8
8
  spec.homepage = 'http://www.rubyforge.org/projects/srcforge/'
@@ -12,7 +12,7 @@ spec = Gem::Specification.new do |spec|
12
12
  spec.description = <<-EOF
13
13
  This script allows you to easily automate the downloading of
14
14
  the latest version of any sourceforge project (as stored up
15
- to 31/03/2006) from any of sourceforge server by having it
15
+ to 31/12/2006) from any of sourceforge server by having it
16
16
  parse the web pages for the project and extract the latest
17
17
  release.
18
18
  It supports connecting through a proxy if either the
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.11
2
+ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: srcforge
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.0.1
7
- date: 2006-05-19 00:00:00 -03:00
6
+ version: 1.0.2
7
+ date: 2006-12-20 00:00:00 -03:00
8
8
  summary: Download tool for files at sourceforge.net.
9
9
  require_paths:
10
10
  - lib
11
11
  email: ggarram@advance.dsl.com.ar
12
12
  homepage: http://www.rubyforge.org/projects/srcforge/
13
13
  rubyforge_project: srcforge
14
- description: This script allows you to easily automate the downloading of the latest version of any sourceforge project (as stored up to 31/03/2006) from any of sourceforge server by having it parse the web pages for the project and extract the latest release. It supports connecting through a proxy if either the environment variable HTTP_PROXY or http_proxy is defined. Also, downloads can be resumed like wget, in case the download is abruptly terminated. If .md5 checksums are available, they will also be downloaded and verified using ruby's digest/md5.
14
+ description: This script allows you to easily automate the downloading of the latest version of any sourceforge project (as stored up to 31/12/2006) from any of sourceforge server by having it parse the web pages for the project and extract the latest release. It supports connecting through a proxy if either the environment variable HTTP_PROXY or http_proxy is defined. Also, downloads can be resumed like wget, in case the download is abruptly terminated. If .md5 checksums are available, they will also be downloaded and verified using ruby's digest/md5.
15
15
  autorequire:
16
16
  default_executable:
17
17
  bindir: bin
@@ -25,6 +25,7 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
25
25
  platform: ruby
26
26
  signing_key:
27
27
  cert_chain:
28
+ post_install_message:
28
29
  authors:
29
30
  - Gonzalo Garramuno
30
31
  files: