rubyforge 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rubyforge.rb +41 -7
- data/test/test_rubyforge.rb +44 -1
- metadata +2 -2
data/lib/rubyforge.rb
CHANGED
@@ -25,7 +25,7 @@ end
|
|
25
25
|
class RubyForge
|
26
26
|
|
27
27
|
# :stopdoc:
|
28
|
-
VERSION = "0.
|
28
|
+
VERSION = "0.3.0"
|
29
29
|
HOME = ENV["HOME"] || ENV["HOMEPATH"] || File::expand_path("~")
|
30
30
|
RUBYFORGE_D = File::join HOME, ".rubyforge"
|
31
31
|
CONFIG_F = File::join RUBYFORGE_D, "config.yml"
|
@@ -96,7 +96,7 @@ class RubyForge
|
|
96
96
|
package = nil
|
97
97
|
html.scan(/<h3>\w+|release_id=\d+">[^>]+|filemodule_id=\d+/).each do |s|
|
98
98
|
case s
|
99
|
-
when /<h3>(\w+)/ then
|
99
|
+
when /<h3>([\w-]+)/ then
|
100
100
|
package = $1
|
101
101
|
when /release_id=(\d+)">([^<]+)/ then
|
102
102
|
data["release_ids"][package][$2] = $1.to_i
|
@@ -126,6 +126,24 @@ class RubyForge
|
|
126
126
|
run page, form
|
127
127
|
end
|
128
128
|
|
129
|
+
##
|
130
|
+
# Posts news item to +group_id+ (can be name) with +subject+ and +body+
|
131
|
+
|
132
|
+
def post_news(group_id, subject, body)
|
133
|
+
page = "/news/submit.php"
|
134
|
+
group_id = lookup "group", group_id
|
135
|
+
|
136
|
+
form = {
|
137
|
+
"group_id" => group_id,
|
138
|
+
"post_changes" => "y",
|
139
|
+
"summary" => subject,
|
140
|
+
"details" => body,
|
141
|
+
"submit" => "Submit",
|
142
|
+
}
|
143
|
+
|
144
|
+
run page, form
|
145
|
+
end
|
146
|
+
|
129
147
|
def delete_package(group_id, package_id)
|
130
148
|
page = "/frs/admin/index.php"
|
131
149
|
|
@@ -144,8 +162,8 @@ class RubyForge
|
|
144
162
|
run page, form
|
145
163
|
end
|
146
164
|
|
147
|
-
def add_release(group_id, package_id, release_name,
|
148
|
-
|
165
|
+
def add_release(group_id, package_id, release_name, *files)
|
166
|
+
userfile = files.shift
|
149
167
|
page = "/frs/admin/qrs.php"
|
150
168
|
|
151
169
|
group_id = lookup "group", group_id
|
@@ -190,9 +208,25 @@ class RubyForge
|
|
190
208
|
boundary = "multipart/form-data; boundary=___#{ boundary }___"
|
191
209
|
|
192
210
|
html = run(page, form, 'content-type' => boundary)
|
193
|
-
html[/release_id=\d+/][/\d+/].to_i
|
211
|
+
release_id = html[/release_id=\d+/][/\d+/].to_i
|
212
|
+
puts "RELEASE ID = #{release_id}" if $DEBUG
|
213
|
+
|
214
|
+
files.each do |file|
|
215
|
+
add_file(group_id, package_id, release_id, file)
|
216
|
+
end
|
217
|
+
|
218
|
+
release_id
|
194
219
|
end
|
195
220
|
|
221
|
+
##
|
222
|
+
# add a file to an existing release under the specified group_id,
|
223
|
+
# package_id, and release_id
|
224
|
+
#
|
225
|
+
# example :
|
226
|
+
# add_file("codeforpeople.com", "traits", "0.8.0", "traits-0.8.0.gem")
|
227
|
+
# add_file("codeforpeople.com", "traits", "0.8.0", "traits-0.8.0.tgz")
|
228
|
+
# add_file(1024, 1242, "0.8.0", "traits-0.8.0.gem")
|
229
|
+
|
196
230
|
def add_file(group_name, package_name, release_name, userfile)
|
197
231
|
page = '/frs/admin/editrelease.php'
|
198
232
|
type_id = @config["type_id"]
|
@@ -225,7 +259,7 @@ class RubyForge
|
|
225
259
|
run page, form, 'content-type' => boundary
|
226
260
|
end
|
227
261
|
|
228
|
-
def run(page, form, extheader={})
|
262
|
+
def run(page, form, extheader={}) # :nodoc:
|
229
263
|
client = HTTPAccess2::Client::new ENV["HTTP_PROXY"]
|
230
264
|
client.debug_dev = STDERR if ENV["RUBYFORGE_DEBUG"] || ENV["DEBUG"]
|
231
265
|
client.set_cookie_store @config["cookie_jar"]
|
@@ -257,7 +291,7 @@ class RubyForge
|
|
257
291
|
return response
|
258
292
|
end
|
259
293
|
|
260
|
-
def lookup(type, val)
|
294
|
+
def lookup(type, val) # :nodoc:
|
261
295
|
unless Fixnum === val then
|
262
296
|
key = val.to_s
|
263
297
|
val = @config["rubyforge"]["#{type}_ids"][key]
|
data/test/test_rubyforge.rb
CHANGED
@@ -6,9 +6,11 @@ require 'rubyforge'
|
|
6
6
|
class FakeRubyForge < RubyForge
|
7
7
|
HTML = "blah blah <form action=\"/frs/admin/editrelease.php?group_id=440&release_id=6948&package_id=491\" method=\"post\"> blah blah"
|
8
8
|
|
9
|
-
attr_accessor :page, :form, :extheader
|
9
|
+
attr_accessor :page, :form, :extheader, :requests
|
10
10
|
def run(page, form, extheader={})
|
11
11
|
@page, @form, @extheader = page, form, extheader
|
12
|
+
@requests ||= []
|
13
|
+
@requests << { :url => page, :form => form, :headers => extheader }
|
12
14
|
HTML
|
13
15
|
end
|
14
16
|
end
|
@@ -119,6 +121,47 @@ class TestRubyForge < Test::Unit::TestCase
|
|
119
121
|
util_add_release
|
120
122
|
end
|
121
123
|
|
124
|
+
def test_add_release_multiple
|
125
|
+
@rubyforge.add_release(42, 666, '1.2.3', __FILE__, __FILE__) # dunno if that'll work
|
126
|
+
add_release = ({ :url=>"/frs/admin/qrs.php",
|
127
|
+
:form=>{"processor_id"=>8000,
|
128
|
+
"submit"=>"Release File",
|
129
|
+
"preformatted"=>0,
|
130
|
+
"release_changes"=>nil,
|
131
|
+
"type_id"=>9999,
|
132
|
+
"group_id"=>42,
|
133
|
+
"release_name"=>"1.2.3",
|
134
|
+
"release_notes"=>nil,
|
135
|
+
"package_id"=>666,
|
136
|
+
"release_date"=>"today"},
|
137
|
+
:headers=> {"content-type" => "multipart/form-data; boundary=___00__03__03__39__09__19__21__36___"}})
|
138
|
+
add_file = ({ :url => '/frs/admin/editrelease.php?group_id=42&release_id=6948&package_id=666',
|
139
|
+
:form => { "step2" => 1,
|
140
|
+
"type_id" => 9999,
|
141
|
+
"processor_id" => 8000,
|
142
|
+
"submit" => "Add This File"},
|
143
|
+
:headers => {"content-type"=> "multipart/form-data; boundary=___23__06__24__24__12__01__38__39___"}})
|
144
|
+
expected = [add_release, add_file]
|
145
|
+
|
146
|
+
result = @rubyforge.requests
|
147
|
+
result.each do |r|
|
148
|
+
r[:form].delete "userfile"
|
149
|
+
end
|
150
|
+
|
151
|
+
assert_equal expected, result
|
152
|
+
end
|
153
|
+
|
154
|
+
def test_post_news
|
155
|
+
@rubyforge.post_news("seattlerb", "my summary", "my news")
|
156
|
+
|
157
|
+
util_run("/news/submit.php",
|
158
|
+
"group_id" => 1513,
|
159
|
+
"post_changes" => "y",
|
160
|
+
"details" => "my news",
|
161
|
+
"summary" => "my summary",
|
162
|
+
"submit" => "Submit")
|
163
|
+
end
|
164
|
+
|
122
165
|
def test_add_release_package_name
|
123
166
|
@rubyforge.config["rubyforge"]["package_ids"]["woot_pkg"] = 666
|
124
167
|
@rubyforge.add_release(42, "woot_pkg", '1.2.3', __FILE__)
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: rubyforge
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2006-
|
6
|
+
version: 0.3.0
|
7
|
+
date: 2006-10-03 00:00:00 -07:00
|
8
8
|
summary: A simplistic script which automates a limited set of rubyforge operations
|
9
9
|
require_paths:
|
10
10
|
- lib
|