rubyforge 0.4.4 → 0.4.5
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -0
- data/Rakefile +19 -10
- data/lib/http-access2.rb +9 -9
- data/lib/http-access2/cookie.rb +2 -3
- data/lib/rubyforge.rb +37 -20
- data/test/test_rubyforge.rb +65 -0
- metadata +47 -37
data/History.txt
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
== Version History:
|
2
2
|
|
3
|
+
=== 0.4.5 / 2008-03-11:
|
4
|
+
|
5
|
+
* Update for Ruby 1.9.0.
|
6
|
+
* Updated History, Rakefile, and Readme for new hoe abilities.
|
7
|
+
* Added config backup/restore rake tasks (for testing).
|
8
|
+
|
3
9
|
=== 0.4.4 / 2007-08-13:
|
4
10
|
|
5
11
|
* New type_id values will merge with extant data. (self-repairing data is Good)
|
data/Rakefile
CHANGED
@@ -11,18 +11,27 @@ end
|
|
11
11
|
Object.send :remove_const, :RubyForge if defined? RubyForge
|
12
12
|
require './lib/rubyforge.rb'
|
13
13
|
|
14
|
-
Hoe.new("rubyforge", RubyForge::VERSION) do |
|
15
|
-
|
16
|
-
|
17
|
-
p.author = ['Ara T Howard', 'Ryan Davis', 'Eric Hodel']
|
18
|
-
p.need_tar = false
|
14
|
+
Hoe.new("rubyforge", RubyForge::VERSION) do |rubyforge|
|
15
|
+
rubyforge.rubyforge_name = "codeforpeople"
|
16
|
+
rubyforge.need_tar = false
|
19
17
|
|
20
|
-
|
21
|
-
|
18
|
+
rubyforge.developer('Ryan Davis', 'ryand-ruby@zenspider.com')
|
19
|
+
rubyforge.developer('Eric Hodel', 'drbrain@segment7.net')
|
20
|
+
rubyforge.developer('Ara T Howard', 'ara.t.howard@gmail.com')
|
21
|
+
end
|
22
|
+
|
23
|
+
task :backup do
|
24
|
+
Dir.chdir File.expand_path("~/.rubyforge") do
|
25
|
+
cp "user-config.yml", "user-config.yml.bak"
|
26
|
+
cp "auto-config.yml", "auto-config.yml.bak"
|
27
|
+
end
|
28
|
+
end
|
22
29
|
|
23
|
-
|
24
|
-
|
25
|
-
|
30
|
+
task :restore do
|
31
|
+
Dir.chdir File.expand_path("~/.rubyforge") do
|
32
|
+
cp "user-config.yml.bak", "user-config.yml"
|
33
|
+
cp "auto-config.yml.bak", "auto-config.yml"
|
34
|
+
end
|
26
35
|
end
|
27
36
|
|
28
37
|
# vim:syntax=ruby
|
data/lib/http-access2.rb
CHANGED
@@ -235,14 +235,14 @@ class Client
|
|
235
235
|
# Get a_sring of message-body of response.
|
236
236
|
#
|
237
237
|
def get_content(uri, query = nil, extheader = {}, &block)
|
238
|
-
retry_connect(uri, query) do |
|
239
|
-
get(
|
238
|
+
retry_connect(uri, query) do |_uri, _query|
|
239
|
+
get(_uri, _query, extheader, &block)
|
240
240
|
end
|
241
241
|
end
|
242
242
|
|
243
243
|
def post_content(uri, body = nil, extheader = {}, &block)
|
244
|
-
retry_connect(uri, nil) do |
|
245
|
-
post(
|
244
|
+
retry_connect(uri, nil) do |_uri, query|
|
245
|
+
post(_uri, body, extheader, &block)
|
246
246
|
end
|
247
247
|
end
|
248
248
|
|
@@ -435,9 +435,9 @@ private
|
|
435
435
|
@debug_dev << "\n\n= Response\n\n" if @debug_dev
|
436
436
|
do_get_header(req, res, sess)
|
437
437
|
conn.push(res)
|
438
|
-
sess.get_data() do |
|
439
|
-
block.call(
|
440
|
-
content <<
|
438
|
+
sess.get_data() do |s|
|
439
|
+
block.call(s) if block
|
440
|
+
content << s
|
441
441
|
end
|
442
442
|
@session_manager.keep(sess) unless sess.closed?
|
443
443
|
end
|
@@ -455,8 +455,8 @@ private
|
|
455
455
|
@debug_dev << "\n\n= Response\n\n" if @debug_dev
|
456
456
|
do_get_header(req, res, sess)
|
457
457
|
conn.push(res)
|
458
|
-
sess.get_data() do |
|
459
|
-
pipew.syswrite(
|
458
|
+
sess.get_data() do |s|
|
459
|
+
pipew.syswrite(s)
|
460
460
|
end
|
461
461
|
pipew.close
|
462
462
|
@session_manager.keep(sess) unless sess.closed?
|
data/lib/http-access2/cookie.rb
CHANGED
@@ -51,8 +51,7 @@ class WebAgent
|
|
51
51
|
class Cookie
|
52
52
|
include CookieUtils
|
53
53
|
|
54
|
-
require '
|
55
|
-
include ParseDate
|
54
|
+
require 'time'
|
56
55
|
|
57
56
|
attr_accessor :name, :value
|
58
57
|
attr_accessor :domain, :path
|
@@ -182,7 +181,7 @@ class WebAgent
|
|
182
181
|
@domain = value
|
183
182
|
when 'expires'
|
184
183
|
begin
|
185
|
-
@expires = Time.
|
184
|
+
@expires = Time.parse(value).gmtime
|
186
185
|
rescue ArgumentError
|
187
186
|
@expires = nil
|
188
187
|
end
|
data/lib/rubyforge.rb
CHANGED
@@ -26,7 +26,7 @@ end
|
|
26
26
|
class RubyForge
|
27
27
|
|
28
28
|
# :stopdoc:
|
29
|
-
VERSION = '0.4.
|
29
|
+
VERSION = '0.4.5'
|
30
30
|
HOME = ENV["HOME"] || ENV["HOMEPATH"] || File::expand_path("~")
|
31
31
|
RUBYFORGE_D = File::join HOME, ".rubyforge"
|
32
32
|
CONFIG_F = File::join RUBYFORGE_D, "user-config.yml"
|
@@ -35,8 +35,6 @@ class RubyForge
|
|
35
35
|
# We must use __FILE__ instead of DATA because this is now a library
|
36
36
|
# and DATA is relative to $0, not __FILE__.
|
37
37
|
CONFIG = File.read(__FILE__).split(/__END__/).last.gsub(/#\{(.*)\}/) { eval $1 }
|
38
|
-
|
39
|
-
attr_reader :client if $TESTING
|
40
38
|
# :startdoc:
|
41
39
|
|
42
40
|
attr_reader :userconfig, :autoconfig
|
@@ -48,6 +46,9 @@ class RubyForge
|
|
48
46
|
@autoconfig_path = File.join(dir, file.sub(/^user/, 'auto'))
|
49
47
|
@autoconfig = test(?e, @autoconfig_path) ? YAML.load_file(@autoconfig_path) : YAML.load(CONFIG)["rubyforge"]
|
50
48
|
|
49
|
+
@autoconfig["type_ids"] = YAML.load(CONFIG)['rubyforge']['type_ids']
|
50
|
+
|
51
|
+
@client = nil
|
51
52
|
@uri = URI.parse @userconfig['uri']
|
52
53
|
|
53
54
|
raise "no <username>" unless @userconfig["username"]
|
@@ -74,13 +75,15 @@ class RubyForge
|
|
74
75
|
def scrape_config
|
75
76
|
username = @userconfig['username']
|
76
77
|
|
77
|
-
%w(group package release).each do |type|
|
78
|
+
%w(group package processor release).each do |type|
|
78
79
|
@autoconfig["#{type}_ids"].clear
|
79
80
|
end
|
80
81
|
|
81
82
|
puts "Getting #{username}"
|
82
83
|
html = URI.parse("http://rubyforge.org/users/#{username}/index.html").read
|
84
|
+
|
83
85
|
projects = html.scan(%r%/projects/([^/]+)/%).flatten
|
86
|
+
|
84
87
|
puts "Fetching #{projects.size} projects"
|
85
88
|
projects.each do |project|
|
86
89
|
next if project == "support"
|
@@ -92,6 +95,7 @@ class RubyForge
|
|
92
95
|
data = {
|
93
96
|
"group_ids" => {},
|
94
97
|
"package_ids" => {},
|
98
|
+
"processor_ids" => Hash.new { |h,k| h[k] = {} },
|
95
99
|
"release_ids" => Hash.new { |h,k| h[k] = {} },
|
96
100
|
}
|
97
101
|
|
@@ -119,6 +123,21 @@ class RubyForge
|
|
119
123
|
end
|
120
124
|
end
|
121
125
|
|
126
|
+
if not data['release_ids'][package].empty? and
|
127
|
+
@autoconfig['processor_ids'].empty? then
|
128
|
+
puts "Fetching processor ids"
|
129
|
+
|
130
|
+
login
|
131
|
+
|
132
|
+
html = client.get_content "http://rubyforge.org/frs/admin/qrs.php?package=&group_id=#{group_id}"
|
133
|
+
|
134
|
+
html =~ /<select name="processor_id">(.*?)<\/select>/m
|
135
|
+
processors = $1
|
136
|
+
processors.scan(/<option value="(\d{4})">([^<]+)/) do
|
137
|
+
data["processor_ids"][$2] = $1.to_i
|
138
|
+
end if processors
|
139
|
+
end
|
140
|
+
|
122
141
|
data.each do |key, val|
|
123
142
|
@autoconfig[key].merge! val
|
124
143
|
end
|
@@ -326,18 +345,24 @@ class RubyForge
|
|
326
345
|
run page, form, 'content-type' => boundary
|
327
346
|
end
|
328
347
|
|
329
|
-
def
|
330
|
-
client
|
331
|
-
|
332
|
-
client
|
333
|
-
client.
|
348
|
+
def client
|
349
|
+
return @client if @client
|
350
|
+
|
351
|
+
@client = HTTPAccess2::Client::new ENV["HTTP_PROXY"]
|
352
|
+
@client.debug_dev = STDERR if ENV["RUBYFORGE_DEBUG"] || ENV["DEBUG"] || $DEBUG
|
353
|
+
@client.set_cookie_store @userconfig["cookie_jar"]
|
354
|
+
@client.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
334
355
|
|
335
356
|
# HACK to fix http-access2 redirect bug/feature
|
336
|
-
client.redirect_uri_callback = lambda do |res|
|
357
|
+
@client.redirect_uri_callback = lambda do |res|
|
337
358
|
page = res.header['location'].first
|
338
359
|
page =~ %r/http/ ? page : @uri + page
|
339
360
|
end
|
340
361
|
|
362
|
+
@client
|
363
|
+
end
|
364
|
+
|
365
|
+
def run(page, form, extheader={}) # :nodoc:
|
341
366
|
uri = @uri + page
|
342
367
|
if $DEBUG then
|
343
368
|
puts "client.post_content #{uri.inspect}, #{form.inspect}, #{extheader.inspect}"
|
@@ -345,8 +370,6 @@ class RubyForge
|
|
345
370
|
|
346
371
|
response = client.post_content uri, form, extheader
|
347
372
|
|
348
|
-
@client = client if $TESTING
|
349
|
-
|
350
373
|
client.save_cookie_store
|
351
374
|
|
352
375
|
if $DEBUG then
|
@@ -436,16 +459,10 @@ __END__
|
|
436
459
|
.gem : 1400
|
437
460
|
.pgp : 8150
|
438
461
|
.sig : 8150
|
462
|
+
.pem : 1500
|
463
|
+
|
439
464
|
#
|
440
465
|
# map processor names to rubyforge ids
|
441
466
|
#
|
442
467
|
processor_ids :
|
443
|
-
i386 : 1000
|
444
|
-
IA64 : 6000
|
445
|
-
Alpha : 7000
|
446
|
-
Any : 8000
|
447
|
-
PPC : 2000
|
448
|
-
MIPS : 3000
|
449
|
-
Sparc : 4000
|
450
|
-
UltraSparc : 5000
|
451
468
|
Other : 9999
|
data/test/test_rubyforge.rb
CHANGED
@@ -27,6 +27,29 @@ class HTTPAccess2::Client
|
|
27
27
|
@url, @form, @headers = url, form, headers
|
28
28
|
FakeRubyForge::HTML
|
29
29
|
end
|
30
|
+
|
31
|
+
def self.data
|
32
|
+
@data ||= []
|
33
|
+
end
|
34
|
+
|
35
|
+
alias old_get_content get_content
|
36
|
+
|
37
|
+
def get_content(*args)
|
38
|
+
self.class.data.shift or raise "no more data"
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
class URI::HTTP
|
44
|
+
|
45
|
+
def self.data
|
46
|
+
@data ||= []
|
47
|
+
end
|
48
|
+
|
49
|
+
def read
|
50
|
+
self.class.data.shift or raise "no more data"
|
51
|
+
end
|
52
|
+
|
30
53
|
end
|
31
54
|
|
32
55
|
class TestRubyForge < Test::Unit::TestCase
|
@@ -240,6 +263,48 @@ class TestRubyForge < Test::Unit::TestCase
|
|
240
263
|
assert_equal extheader, client.headers
|
241
264
|
end
|
242
265
|
|
266
|
+
def test_scrape_project
|
267
|
+
orig_stdout = $stdout
|
268
|
+
orig_stderr = $stderr
|
269
|
+
$stdout = StringIO.new
|
270
|
+
$stderr = StringIO.new
|
271
|
+
util_new RubyForge
|
272
|
+
@rubyforge.autoconfig.each { |k,v| v.clear }
|
273
|
+
|
274
|
+
URI::HTTP.data << "<a href='/tracker/?group_id=1513'>Tracker</a>"
|
275
|
+
URI::HTTP.data << <<-EOF
|
276
|
+
<h3>ar_mailer
|
277
|
+
<a href="/frs/monitor.php?filemodule_id=4566&group_id=1513&start=1">
|
278
|
+
<a href="shownotes.php?release_id=13368">1.3.1</a>
|
279
|
+
<a href="shownotes.php?release_id=12185">1.2.0</a></strong>
|
280
|
+
EOF
|
281
|
+
|
282
|
+
HTTPAccess2::Client.data << <<-EOF
|
283
|
+
<select name="processor_id">
|
284
|
+
<option value="100">Must Choose One</option>
|
285
|
+
<option value="1000">i386</option>
|
286
|
+
<option value="1001">i387</option>
|
287
|
+
</select>
|
288
|
+
EOF
|
289
|
+
|
290
|
+
@rubyforge.scrape_project('my_project')
|
291
|
+
|
292
|
+
expected = {
|
293
|
+
"group_ids" => { "my_project" => 1513 },
|
294
|
+
"package_ids" => { "ar_mailer" => 4566 },
|
295
|
+
"processor_ids" => { "i386" => 1000, "i387" => 1001 },
|
296
|
+
"release_ids" => {
|
297
|
+
"ar_mailer" => { "1.2.0" => 12185, "1.3.1" => 13368 }
|
298
|
+
},
|
299
|
+
"type_ids" => {},
|
300
|
+
}
|
301
|
+
|
302
|
+
assert_equal expected, @rubyforge.autoconfig
|
303
|
+
ensure
|
304
|
+
$stdout = orig_stdout
|
305
|
+
$stderr = orig_stderr
|
306
|
+
end
|
307
|
+
|
243
308
|
def util_new(klass)
|
244
309
|
@rubyforge = klass.new
|
245
310
|
@old_autoconfig = @rubyforge.autoconfig.dup
|
metadata
CHANGED
@@ -1,35 +1,33 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.4
|
3
|
-
specification_version: 1
|
4
2
|
name: rubyforge
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.4.
|
7
|
-
date: 2007-08-13 00:00:00 -07:00
|
8
|
-
summary: A script which automates a limited set of rubyforge operations.
|
9
|
-
require_paths:
|
10
|
-
- lib
|
11
|
-
email: ryand-ruby@zenspider.com
|
12
|
-
homepage: http://rubyforge.org/projects/codeforpeople
|
13
|
-
rubyforge_project: codeforpeople
|
14
|
-
description: "A script which automates a limited set of rubyforge operations. * Run 'rubyforge help' for complete usage. * Setup: For first time users AND upgrades to 0.4.0: * rubyforge setup (deletes your username and password, so run sparingly!) * edit ~/.rubyforge/user-config.yml * rubyforge config * For all rubyforge upgrades, run 'rubyforge config' to ensure you have latest. * Don't forget to login! logging in will store a cookie in your .rubyforge directory which expires after a time. always run the login command before any operation that requires authentication, such as uploading a package."
|
15
|
-
autorequire:
|
16
|
-
default_executable:
|
17
|
-
bindir: bin
|
18
|
-
has_rdoc: true
|
19
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">"
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.0.0
|
24
|
-
version:
|
4
|
+
version: 0.4.5
|
25
5
|
platform: ruby
|
26
|
-
signing_key:
|
27
|
-
cert_chain:
|
28
|
-
post_install_message:
|
29
6
|
authors:
|
30
|
-
- Ara T Howard
|
31
7
|
- Ryan Davis
|
32
8
|
- Eric Hodel
|
9
|
+
- Ara T Howard
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
|
14
|
+
date: 2008-03-11 00:00:00 -07:00
|
15
|
+
default_executable:
|
16
|
+
dependencies: []
|
17
|
+
|
18
|
+
description: "A script which automates a limited set of rubyforge operations. * Run 'rubyforge help' for complete usage. * Setup: For first time users AND upgrades to 0.4.0: * rubyforge setup (deletes your username and password, so run sparingly!) * edit ~/.rubyforge/user-config.yml * rubyforge config * For all rubyforge upgrades, run 'rubyforge config' to ensure you have latest. * Don't forget to login! logging in will store a cookie in your .rubyforge directory which expires after a time. always run the login command before any operation that requires authentication, such as uploading a package."
|
19
|
+
email:
|
20
|
+
- ryand-ruby@zenspider.com
|
21
|
+
- drbrain@segment7.net
|
22
|
+
- ara.t.howard@gmail.com
|
23
|
+
executables:
|
24
|
+
- rubyforge
|
25
|
+
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files:
|
28
|
+
- History.txt
|
29
|
+
- Manifest.txt
|
30
|
+
- README.txt
|
33
31
|
files:
|
34
32
|
- History.txt
|
35
33
|
- Manifest.txt
|
@@ -41,20 +39,32 @@ files:
|
|
41
39
|
- lib/http-access2/http.rb
|
42
40
|
- lib/rubyforge.rb
|
43
41
|
- test/test_rubyforge.rb
|
44
|
-
|
45
|
-
|
42
|
+
has_rdoc: true
|
43
|
+
homepage: http://codeforpeople.rubyforge.org/rubyforge/
|
44
|
+
post_install_message:
|
46
45
|
rdoc_options:
|
47
46
|
- --main
|
48
47
|
- README.txt
|
49
|
-
|
50
|
-
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
-
|
55
|
-
|
56
|
-
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: "0"
|
55
|
+
version:
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: "0"
|
61
|
+
version:
|
57
62
|
requirements: []
|
58
63
|
|
59
|
-
|
60
|
-
|
64
|
+
rubyforge_project: codeforpeople
|
65
|
+
rubygems_version: 1.0.1
|
66
|
+
signing_key:
|
67
|
+
specification_version: 2
|
68
|
+
summary: A script which automates a limited set of rubyforge operations
|
69
|
+
test_files:
|
70
|
+
- test/test_rubyforge.rb
|