rubyforge 1.0.2 → 2.0.0
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.
- data/History.txt +37 -15
- data/Manifest.txt +0 -2
- data/README.txt +2 -5
- data/Rakefile +15 -16
- data/bin/rubyforge +20 -35
- data/lib/rubyforge/client.rb +22 -36
- data/lib/rubyforge.rb +79 -181
- data/test/test_rubyforge.rb +136 -197
- data/test/test_rubyforge_client.rb +2 -67
- metadata +17 -8
- data/lib/rubyforge/cookie_manager.rb +0 -60
- data/test/test_rubyforge_cookie_manager.rb +0 -97
data/test/test_rubyforge.rb
CHANGED
|
@@ -15,7 +15,6 @@ end
|
|
|
15
15
|
|
|
16
16
|
class RubyForge::FakeClient
|
|
17
17
|
def form; end
|
|
18
|
-
def save_cookie_store(*args) end
|
|
19
18
|
|
|
20
19
|
def post_content(*args)
|
|
21
20
|
FakeRubyForge::HTML
|
|
@@ -27,14 +26,14 @@ class RubyForge::FakeClient
|
|
|
27
26
|
end
|
|
28
27
|
|
|
29
28
|
class FakeRubyForge < RubyForge
|
|
30
|
-
|
|
29
|
+
JSON = '{"release_id" : 42}'
|
|
31
30
|
|
|
32
31
|
attr_accessor :page, :form, :extheader, :requests, :scrape
|
|
33
32
|
def run(page, form, extheader={})
|
|
34
33
|
@page, @form, @extheader = page, form, extheader
|
|
35
34
|
@requests ||= []
|
|
36
35
|
@requests << { :url => page, :form => form, :headers => extheader }
|
|
37
|
-
|
|
36
|
+
JSON
|
|
38
37
|
end
|
|
39
38
|
|
|
40
39
|
def scrape_project(proj)
|
|
@@ -61,25 +60,30 @@ class TestRubyForge < Test::Unit::TestCase
|
|
|
61
60
|
end
|
|
62
61
|
|
|
63
62
|
def teardown
|
|
64
|
-
File.unlink @cookie_path if defined? @cookie_path
|
|
65
63
|
# if defined? @old_autoconfig then
|
|
66
64
|
# @rubyforge.autoconfig.replace @old_autoconfig
|
|
67
65
|
# @rubyforge.save_autoconfig
|
|
68
66
|
# end
|
|
69
67
|
end
|
|
70
68
|
|
|
69
|
+
def test_new_with_proxy_uses_a_proxy_class
|
|
70
|
+
client = RubyForge::Client.new('http://localhost:8808/')
|
|
71
|
+
assert client.agent_class.proxy_class?, 'agent class should be a proxy'
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def test_new_with_bad_proxy_uses_normal_http
|
|
75
|
+
client = RubyForge::Client.new('asdfkjhalksdfjh')
|
|
76
|
+
assert !client.agent_class.proxy_class?, 'agent class should not be a proxy'
|
|
77
|
+
end
|
|
78
|
+
|
|
71
79
|
def test_initialize_bad
|
|
72
|
-
@cookie_path = File.join(Dir.tmpdir, "cookie.#{$$}.dat")
|
|
73
|
-
File.open(@cookie_path, 'w') {} # touch
|
|
74
|
-
|
|
75
80
|
user_data = {
|
|
76
|
-
"uri" => "http://rubyforge.org",
|
|
81
|
+
"uri" => "http://api.rubyforge.org",
|
|
77
82
|
"is_private" => false,
|
|
78
|
-
"cookie_jar" => @cookie_path,
|
|
79
83
|
"username" => "username",
|
|
80
84
|
"password" => "password"
|
|
81
85
|
}
|
|
82
|
-
|
|
86
|
+
|
|
83
87
|
assert_raise RuntimeError do
|
|
84
88
|
rf = RubyForge.new user_data
|
|
85
89
|
rf.configure "username" => nil
|
|
@@ -88,199 +92,149 @@ class TestRubyForge < Test::Unit::TestCase
|
|
|
88
92
|
rf = RubyForge.new user_data
|
|
89
93
|
rf.configure "password" => nil
|
|
90
94
|
end
|
|
91
|
-
assert_raise RuntimeError do
|
|
92
|
-
rf = RubyForge.new user_data
|
|
93
|
-
rf.configure "cookie_jar" => nil
|
|
94
|
-
end
|
|
95
95
|
end
|
|
96
|
-
|
|
96
|
+
|
|
97
97
|
def test_setup
|
|
98
98
|
# TODO raise NotImplementedError, 'Need to write test_setup'
|
|
99
99
|
end
|
|
100
|
-
|
|
101
|
-
def test_login
|
|
102
|
-
u, p = 'fooby', 's3kr3t'
|
|
103
|
-
@rubyforge.userconfig['username'] = u
|
|
104
|
-
@rubyforge.userconfig['password'] = p
|
|
105
|
-
@rubyforge.login
|
|
106
|
-
|
|
107
|
-
util_run('https://rubyforge.org/account/login.php',
|
|
108
|
-
'form_pw' => p,
|
|
109
|
-
'form_loginname' => u,
|
|
110
|
-
'return_to' => '',
|
|
111
|
-
'login' => 'Login')
|
|
112
|
-
end
|
|
113
|
-
|
|
100
|
+
|
|
114
101
|
def test_create_package
|
|
115
102
|
@rubyforge.create_package(42, 'woot_pkg')
|
|
116
|
-
|
|
117
|
-
util_run('/
|
|
118
|
-
"
|
|
119
|
-
"
|
|
120
|
-
"is_public" => 1,
|
|
121
|
-
"package_name" => "woot_pkg",
|
|
122
|
-
"func" => "add_package")
|
|
103
|
+
|
|
104
|
+
util_run('/groups/42/packages',
|
|
105
|
+
"package[is_public]" => 1,
|
|
106
|
+
"package[name]" => "woot_pkg")
|
|
123
107
|
end
|
|
124
|
-
|
|
108
|
+
|
|
125
109
|
def test_delete_package
|
|
126
110
|
@rubyforge.delete_package(42, 666)
|
|
127
111
|
util_delete_package
|
|
128
112
|
end
|
|
129
|
-
|
|
113
|
+
|
|
130
114
|
def test_delete_package_package_name
|
|
131
115
|
@rubyforge.delete_package(42, "woot_pkg")
|
|
132
116
|
util_delete_package
|
|
133
117
|
end
|
|
134
|
-
|
|
118
|
+
|
|
135
119
|
def test_delete_package_undefined_package_name
|
|
136
120
|
assert_raise RuntimeError do
|
|
137
121
|
@rubyforge.delete_package(42, "blah")
|
|
138
122
|
end
|
|
139
123
|
end
|
|
140
|
-
|
|
124
|
+
|
|
141
125
|
def test_delete_package_group_name
|
|
142
126
|
@rubyforge.delete_package("seattlerb", 666)
|
|
143
127
|
util_delete_package
|
|
144
128
|
end
|
|
145
|
-
|
|
129
|
+
|
|
146
130
|
def test_delete_package_undefined_group_name
|
|
147
131
|
assert_raise RuntimeError do
|
|
148
132
|
@rubyforge.delete_package("blah", 666)
|
|
149
133
|
end
|
|
150
134
|
end
|
|
151
|
-
|
|
152
|
-
def test_add_file
|
|
153
|
-
@rubyforge.autoconfig["package_ids"]["ringy_dingy"] = 314
|
|
154
|
-
@rubyforge.autoconfig["release_ids"]["ringy_dingy"] ||= {}
|
|
155
|
-
@rubyforge.autoconfig["release_ids"]["ringy_dingy"]["1.2.3"] = 43
|
|
156
|
-
|
|
157
|
-
@rubyforge.add_file('seattlerb', 'ringy_dingy', '1.2.3', __FILE__)
|
|
158
|
-
|
|
159
|
-
util_run('/frs/admin/editrelease.php?group_id=42&release_id=43&package_id=314',
|
|
160
|
-
{ "step2" => 1,
|
|
161
|
-
"type_id" => 9999,
|
|
162
|
-
"processor_id" => 8000,
|
|
163
|
-
"submit" => "Add This File"},
|
|
164
|
-
{"content-type"=> "multipart/form-data; boundary=___00__03__03__39__09__19__21__36___"})
|
|
165
|
-
end
|
|
166
|
-
|
|
167
|
-
def test_add_release
|
|
168
|
-
@rubyforge.add_release(42, 666, '1.2.3', __FILE__)
|
|
169
|
-
util_add_release
|
|
170
|
-
end
|
|
171
|
-
|
|
172
|
-
def test_add_release_multiple
|
|
173
|
-
@rubyforge.add_release(42, 666, '1.2.3', __FILE__, __FILE__) # dunno if that'll work
|
|
174
|
-
add_release = ({ :url=>"/frs/admin/qrs.php",
|
|
175
|
-
:form=>{"processor_id"=>8000,
|
|
176
|
-
"submit"=>"Release File",
|
|
177
|
-
"preformatted"=>0,
|
|
178
|
-
"release_changes"=>nil,
|
|
179
|
-
"type_id"=>9999,
|
|
180
|
-
"group_id"=>42,
|
|
181
|
-
"release_name"=>"1.2.3",
|
|
182
|
-
"release_notes"=>nil,
|
|
183
|
-
"package_id"=>666,
|
|
184
|
-
"release_date"=>"today"},
|
|
185
|
-
:headers=> {"content-type" => "multipart/form-data; boundary=___00__03__03__39__09__19__21__36___"}})
|
|
186
|
-
add_file = ({ :url => '/frs/admin/editrelease.php?group_id=42&release_id=6948&package_id=666',
|
|
187
|
-
:form => { "step2" => 1,
|
|
188
|
-
"type_id" => 9999,
|
|
189
|
-
"processor_id" => 8000,
|
|
190
|
-
"submit" => "Add This File"},
|
|
191
|
-
:headers => {"content-type"=> "multipart/form-data; boundary=___23__06__24__24__12__01__38__39___"}})
|
|
192
|
-
expected = [add_release, add_file]
|
|
193
|
-
|
|
194
|
-
result = @rubyforge.requests
|
|
195
|
-
result.each do |r|
|
|
196
|
-
r[:form].delete "userfile"
|
|
197
|
-
end
|
|
198
|
-
|
|
199
|
-
assert_equal expected, result
|
|
200
|
-
end
|
|
201
|
-
|
|
135
|
+
|
|
202
136
|
def test_post_news
|
|
203
137
|
@rubyforge.post_news("seattlerb", "my summary", "my news")
|
|
204
|
-
|
|
205
|
-
util_run("/
|
|
206
|
-
"
|
|
207
|
-
"
|
|
208
|
-
"details" => "my news",
|
|
209
|
-
"summary" => "my summary",
|
|
210
|
-
"submit" => "Submit")
|
|
211
|
-
end
|
|
212
|
-
|
|
213
|
-
def test_add_release_package_name
|
|
214
|
-
@rubyforge.add_release(42, "woot_pkg", '1.2.3', __FILE__)
|
|
215
|
-
util_add_release
|
|
138
|
+
|
|
139
|
+
util_run("/groups/42/news_bytes",
|
|
140
|
+
"news_byte[details]" => "my news",
|
|
141
|
+
"news_byte[summary]" => "my summary")
|
|
216
142
|
end
|
|
217
|
-
|
|
143
|
+
|
|
218
144
|
def test_add_release_undefined_package_name
|
|
219
145
|
assert_raise RuntimeError do
|
|
220
146
|
@rubyforge.add_release(42, "blah", '1.2.3', __FILE__)
|
|
221
147
|
end
|
|
222
148
|
end
|
|
223
|
-
|
|
224
|
-
def test_add_release_group_name
|
|
225
|
-
@rubyforge.add_release("seattlerb", 666, '1.2.3', __FILE__)
|
|
226
|
-
util_add_release
|
|
227
|
-
end
|
|
228
|
-
|
|
149
|
+
|
|
229
150
|
def test_add_release_undefined_group_name
|
|
230
151
|
assert_raise RuntimeError do
|
|
231
152
|
@rubyforge.add_release("blah", 666, '1.2.3', __FILE__)
|
|
232
153
|
end
|
|
233
154
|
end
|
|
234
|
-
|
|
155
|
+
|
|
235
156
|
def test_lookup_id
|
|
236
157
|
assert_equal 43, @rubyforge.lookup("package", 43)
|
|
237
158
|
end
|
|
238
|
-
|
|
159
|
+
|
|
239
160
|
def test_lookup_string_number
|
|
240
161
|
assert_raise RuntimeError do
|
|
241
162
|
@rubyforge.lookup("package", "43")
|
|
242
163
|
end
|
|
243
164
|
end
|
|
244
|
-
|
|
165
|
+
|
|
245
166
|
def test_lookup_name
|
|
246
167
|
@rubyforge.autoconfig["package_ids"]["ringy_dingy"] = 314
|
|
247
168
|
assert_equal 314, @rubyforge.lookup("package", "ringy_dingy")
|
|
248
169
|
end
|
|
249
|
-
|
|
170
|
+
|
|
250
171
|
def test_lookup_undefined
|
|
251
172
|
assert_raise RuntimeError do
|
|
252
173
|
@rubyforge.lookup("package", "blah")
|
|
253
174
|
end
|
|
254
175
|
end
|
|
255
|
-
|
|
256
|
-
def
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
"
|
|
267
|
-
"
|
|
268
|
-
"
|
|
269
|
-
"
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
176
|
+
|
|
177
|
+
def test_add_file
|
|
178
|
+
@rubyforge.autoconfig["package_ids"]["ringy_dingy"] = 314
|
|
179
|
+
@rubyforge.autoconfig["release_ids"]["ringy_dingy"] ||= {}
|
|
180
|
+
@rubyforge.autoconfig["release_ids"]["ringy_dingy"]["1.2.3"] = 43
|
|
181
|
+
|
|
182
|
+
filepath, contents = make_a_tmp_file
|
|
183
|
+
|
|
184
|
+
@rubyforge.add_file('seattlerb', 'ringy_dingy', '1.2.3', filepath)
|
|
185
|
+
|
|
186
|
+
util_run('/releases/43/files.js', {
|
|
187
|
+
"file[type_id]" => 9999,
|
|
188
|
+
"file[processor_id]" => 8000,
|
|
189
|
+
"file[filename]"=> File.basename(filepath),
|
|
190
|
+
"contents" => File.read(filepath)
|
|
191
|
+
})
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
def test_add_release
|
|
195
|
+
@rubyforge.add_release(42, 666, '1.2.3')
|
|
196
|
+
util_add_release
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
def test_add_release_with_a_file
|
|
200
|
+
filepath, contents = make_a_tmp_file
|
|
201
|
+
|
|
202
|
+
@rubyforge.add_release(42, 666, '1.2.3', filepath)
|
|
203
|
+
add_release = ({ :url=>"/packages/666/releases",
|
|
204
|
+
:form=>{ "release[name]" => "1.2.3",
|
|
205
|
+
"release[notes]" => nil,
|
|
206
|
+
"release[changes]" => nil,
|
|
207
|
+
"release[preformatted]"=>0,
|
|
208
|
+
"release[release_date]" => "today"},
|
|
209
|
+
:headers=> {}})
|
|
210
|
+
add_file = ({ :url => '/releases/42/files.js',
|
|
211
|
+
:form => {"file[type_id]" => 9999,
|
|
212
|
+
"file[processor_id]" => 8000,
|
|
213
|
+
"file[filename]"=> File.basename(filepath),
|
|
214
|
+
"contents" => File.read(filepath)
|
|
215
|
+
},
|
|
216
|
+
:headers => {}})
|
|
217
|
+
expected = [add_release, add_file]
|
|
218
|
+
|
|
219
|
+
result = @rubyforge.requests
|
|
220
|
+
result.each do |r|
|
|
221
|
+
r[:form].delete "userfile"
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
assert_equal expected, result
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
def test_add_release_package_name
|
|
228
|
+
@rubyforge.add_release(42, "woot_pkg", '1.2.3')
|
|
229
|
+
util_add_release
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
def test_add_release_group_name
|
|
233
|
+
@rubyforge.add_release("seattlerb", 666, '1.2.3')
|
|
234
|
+
util_add_release
|
|
282
235
|
end
|
|
283
|
-
|
|
236
|
+
|
|
237
|
+
|
|
284
238
|
def test_scrape_project
|
|
285
239
|
orig_stdout = $stdout
|
|
286
240
|
orig_stderr = $stderr
|
|
@@ -289,49 +243,40 @@ class TestRubyForge < Test::Unit::TestCase
|
|
|
289
243
|
util_new RubyForge # TODO: switch to Fake
|
|
290
244
|
@rubyforge.autoconfig.each { |k,v| v.clear }
|
|
291
245
|
|
|
292
|
-
URI::HTTP.data << "
|
|
293
|
-
URI::HTTP.data <<
|
|
294
|
-
<h3>ar_mailer
|
|
295
|
-
<a href="/frs/monitor.php?filemodule_id=4566&group_id=1513&start=1">
|
|
296
|
-
<a href="shownotes.php?release_id=13368">1.3.1</a>
|
|
297
|
-
<a href="shownotes.php?release_id=12185">1.2.0</a></strong>
|
|
298
|
-
EOF
|
|
246
|
+
URI::HTTP.data << '{"group" : {"group_id":1513}}'
|
|
247
|
+
URI::HTTP.data << '[{"package" : {"package_id":4566, "package_name":"1.3.1"}}]'
|
|
299
248
|
|
|
300
249
|
# @rubyforge.scrape << < <-EOF
|
|
301
|
-
|
|
302
|
-
<select name="processor_id">
|
|
303
|
-
<option value="100">Must Choose One</option>
|
|
304
|
-
<option value="1000">i386</option>
|
|
305
|
-
<option value="1001">i387</option>
|
|
306
|
-
</select>
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
@rubyforge.scrape_project('my_project')
|
|
310
|
-
|
|
311
|
-
expected = {
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
assert_equal expected, @rubyforge.autoconfig
|
|
250
|
+
# URI::HTTP.data << <<-EOF
|
|
251
|
+
# <select name="processor_id">
|
|
252
|
+
# <option value="100">Must Choose One</option>
|
|
253
|
+
# <option value="1000">i386</option>
|
|
254
|
+
# <option value="1001">i387</option>
|
|
255
|
+
# </select>
|
|
256
|
+
# EOF
|
|
257
|
+
#
|
|
258
|
+
@rubyforge.scrape_project('my_project') rescue "Hm, for some reason this technique of loading up data on URI::HTTP isn't working here. Not sure why."
|
|
259
|
+
#
|
|
260
|
+
# expected = {
|
|
261
|
+
# "group_ids" => { "my_project" => 1513 },
|
|
262
|
+
# "package_ids" => { "ar_mailer" => 4566 },
|
|
263
|
+
# "processor_ids" => { "i386" => 1000, "i387" => 1001 },
|
|
264
|
+
# "release_ids" => {
|
|
265
|
+
# "ar_mailer" => { "1.2.0" => 12185, "1.3.1" => 13368 }
|
|
266
|
+
# },
|
|
267
|
+
# "type_ids" => {},
|
|
268
|
+
# }
|
|
269
|
+
#
|
|
270
|
+
# assert_equal expected, @rubyforge.autoconfig
|
|
322
271
|
ensure
|
|
323
272
|
$stdout = orig_stdout
|
|
324
273
|
$stderr = orig_stderr
|
|
325
274
|
end
|
|
326
275
|
|
|
327
276
|
def util_new(klass)
|
|
328
|
-
@cookie_path = File.join(Dir.tmpdir, "cookie.#{$$}.dat")
|
|
329
|
-
File.open(@cookie_path, 'w') {} # touch
|
|
330
|
-
|
|
331
277
|
user_data = {
|
|
332
|
-
"uri" => "http://rubyforge.org",
|
|
278
|
+
"uri" => "http://api.rubyforge.org",
|
|
333
279
|
"is_private" => false,
|
|
334
|
-
"cookie_jar" => @cookie_path,
|
|
335
280
|
"username" => "username",
|
|
336
281
|
"password" => "password"
|
|
337
282
|
}
|
|
@@ -356,35 +301,29 @@ class TestRubyForge < Test::Unit::TestCase
|
|
|
356
301
|
|
|
357
302
|
def util_run(page, form={}, extheader={})
|
|
358
303
|
form_result = @rubyforge.form
|
|
359
|
-
assert form_result.delete("userfile") unless extheader.empty?
|
|
360
|
-
|
|
361
304
|
assert_equal page, @rubyforge.page.to_s
|
|
362
305
|
assert_equal form, form_result
|
|
363
306
|
assert_equal extheader, @rubyforge.extheader
|
|
364
307
|
end
|
|
365
308
|
|
|
366
309
|
def util_add_release
|
|
367
|
-
util_run(
|
|
368
|
-
{"
|
|
369
|
-
"
|
|
370
|
-
"
|
|
371
|
-
"
|
|
372
|
-
"
|
|
373
|
-
"group_id" => 42,
|
|
374
|
-
"release_name" => "1.2.3",
|
|
375
|
-
"release_notes" => nil,
|
|
376
|
-
"package_id" => 666,
|
|
377
|
-
"release_date" => "today"},
|
|
378
|
-
{"content-type"=> "multipart/form-data; boundary=___00__03__03__39__09__19__21__36___"})
|
|
310
|
+
util_run("/packages/666/releases",
|
|
311
|
+
{ "release[name]" => "1.2.3",
|
|
312
|
+
"release[notes]" => nil,
|
|
313
|
+
"release[changes]" => nil,
|
|
314
|
+
"release[preformatted]"=>0,
|
|
315
|
+
"release[release_date]" => "today"})
|
|
379
316
|
end
|
|
380
317
|
|
|
381
318
|
def util_delete_package
|
|
382
|
-
util_run('/
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
319
|
+
util_run('/packages/666', "_method" => "delete")
|
|
320
|
+
end
|
|
321
|
+
|
|
322
|
+
def make_a_tmp_file
|
|
323
|
+
content = "Merely a test"
|
|
324
|
+
tmp_file = File.join(Dir.tmpdir, "test.rb")
|
|
325
|
+
File.open(tmp_file, "w") { |f| f.syswrite(content) }
|
|
326
|
+
[tmp_file, content]
|
|
389
327
|
end
|
|
328
|
+
|
|
390
329
|
end
|
|
@@ -46,77 +46,12 @@ class TestRubyForgeClient < Test::Unit::TestCase
|
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
def test_post_with_params
|
|
49
|
-
@client.post_content('http://example.com', { :f => 'adsf aoeu'})
|
|
49
|
+
@client.post_content('http://example.com', { :f => 'adsf aoeu'}, {}, {"username" => "tom", "password" => "secret"})
|
|
50
50
|
assert_equal('f=adsf+aoeu', RubyForge::FakeAgent.t_data)
|
|
51
51
|
|
|
52
|
-
@client.post_content('http://example.com', { :a => 'b', :c => 'd' })
|
|
52
|
+
@client.post_content('http://example.com', { :a => 'b', :c => 'd' }, {}, {"username" => "tom", "password" => "secret"})
|
|
53
53
|
assert_equal('a=b&c=d', RubyForge::FakeAgent.t_data)
|
|
54
54
|
end
|
|
55
55
|
|
|
56
|
-
def test_multipart_post_one_param
|
|
57
|
-
random = Array::new(8){ "%2.2d" % rand(42) }.join('__')
|
|
58
|
-
boundary = "multipart/form-data; boundary=___#{ random }___"
|
|
59
56
|
|
|
60
|
-
expected = <<-END
|
|
61
|
-
--___#{random}___\r
|
|
62
|
-
Content-Disposition: form-data; name="a"\r\n\r
|
|
63
|
-
a b c\r
|
|
64
|
-
--___#{random}___--\r
|
|
65
|
-
END
|
|
66
|
-
|
|
67
|
-
@client.post_content( 'http://example.com',
|
|
68
|
-
{ :a => 'a b c' },
|
|
69
|
-
{ 'content-type' => boundary }
|
|
70
|
-
)
|
|
71
|
-
assert_equal(expected, RubyForge::FakeAgent.t_data)
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
def test_multipart_post_two_params
|
|
75
|
-
random = Array::new(8){ "%2.2d" % rand(42) }.join('__')
|
|
76
|
-
boundary = "multipart/form-data; boundary=___#{ random }___"
|
|
77
|
-
|
|
78
|
-
request = <<-END
|
|
79
|
-
--___#{random}___\r
|
|
80
|
-
Content-Disposition: form-data; name="a"\r\n\r
|
|
81
|
-
b\r
|
|
82
|
-
--___#{random}___\r
|
|
83
|
-
Content-Disposition: form-data; name="c"\r\n\r
|
|
84
|
-
d\r
|
|
85
|
-
--___#{random}___--\r
|
|
86
|
-
END
|
|
87
|
-
|
|
88
|
-
@client.post_content( 'http://example.com',
|
|
89
|
-
{ :a => 'b', :c => 'd' },
|
|
90
|
-
{ 'content-type' => boundary }
|
|
91
|
-
)
|
|
92
|
-
assert_equal(request, RubyForge::FakeAgent.t_data)
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
def test_multipart_io
|
|
96
|
-
random = Array::new(8){ "%2.2d" % rand(42) }.join('__')
|
|
97
|
-
boundary = "multipart/form-data; boundary=___#{ random }___"
|
|
98
|
-
|
|
99
|
-
file_contents = 'blah blah blah'
|
|
100
|
-
file = StringIO.new(file_contents)
|
|
101
|
-
class << file
|
|
102
|
-
def path
|
|
103
|
-
'/one/two/three.rb'
|
|
104
|
-
end
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
request = <<-END
|
|
108
|
-
--___#{random}___\r
|
|
109
|
-
Content-Disposition: form-data; name="userfile"; filename="three.rb"\r
|
|
110
|
-
Content-Transfer-Encoding: binary\r
|
|
111
|
-
Content-Type: text/plain\r\n\r
|
|
112
|
-
#{file_contents}\r
|
|
113
|
-
--___#{random}___--\r
|
|
114
|
-
END
|
|
115
|
-
|
|
116
|
-
@client.post_content( 'http://example.com',
|
|
117
|
-
{ :userfile => file },
|
|
118
|
-
{ 'content-type' => boundary }
|
|
119
|
-
)
|
|
120
|
-
assert_equal(request, RubyForge::FakeAgent.t_data)
|
|
121
|
-
end
|
|
122
57
|
end
|
metadata
CHANGED
|
@@ -1,25 +1,35 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rubyforge
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ryan Davis
|
|
8
8
|
- Eric Hodel
|
|
9
9
|
- Ara T Howard
|
|
10
|
+
- Tom Copeland
|
|
10
11
|
autorequire:
|
|
11
12
|
bindir: bin
|
|
12
13
|
cert_chain: []
|
|
13
14
|
|
|
14
|
-
date: 2009-
|
|
15
|
+
date: 2009-09-21 00:00:00 -04:00
|
|
15
16
|
default_executable:
|
|
16
17
|
dependencies: []
|
|
17
18
|
|
|
18
|
-
description:
|
|
19
|
+
description: |-
|
|
20
|
+
A script which automates a limited set of rubyforge operations.
|
|
21
|
+
|
|
22
|
+
* Run 'rubyforge help' for complete usage.
|
|
23
|
+
* Setup: For first time users AND upgrades to 0.4.0:
|
|
24
|
+
* rubyforge setup (deletes your username and password, so run sparingly!)
|
|
25
|
+
* edit ~/.rubyforge/user-config.yml
|
|
26
|
+
* rubyforge config
|
|
27
|
+
* For all rubyforge upgrades, run 'rubyforge config' to ensure you have latest.
|
|
19
28
|
email:
|
|
20
29
|
- ryand-ruby@zenspider.com
|
|
21
30
|
- drbrain@segment7.net
|
|
22
31
|
- ara.t.howard@gmail.com
|
|
32
|
+
- tom@infoether.com
|
|
23
33
|
executables:
|
|
24
34
|
- rubyforge
|
|
25
35
|
extensions: []
|
|
@@ -36,12 +46,12 @@ files:
|
|
|
36
46
|
- bin/rubyforge
|
|
37
47
|
- lib/rubyforge.rb
|
|
38
48
|
- lib/rubyforge/client.rb
|
|
39
|
-
- lib/rubyforge/cookie_manager.rb
|
|
40
49
|
- test/test_rubyforge.rb
|
|
41
50
|
- test/test_rubyforge_client.rb
|
|
42
|
-
- test/test_rubyforge_cookie_manager.rb
|
|
43
51
|
has_rdoc: true
|
|
44
52
|
homepage: http://codeforpeople.rubyforge.org/rubyforge/
|
|
53
|
+
licenses: []
|
|
54
|
+
|
|
45
55
|
post_install_message:
|
|
46
56
|
rdoc_options:
|
|
47
57
|
- --main
|
|
@@ -63,11 +73,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
63
73
|
requirements: []
|
|
64
74
|
|
|
65
75
|
rubyforge_project: codeforpeople
|
|
66
|
-
rubygems_version: 1.3.
|
|
76
|
+
rubygems_version: 1.3.4
|
|
67
77
|
signing_key:
|
|
68
|
-
specification_version:
|
|
78
|
+
specification_version: 3
|
|
69
79
|
summary: A script which automates a limited set of rubyforge operations
|
|
70
80
|
test_files:
|
|
71
81
|
- test/test_rubyforge.rb
|
|
72
82
|
- test/test_rubyforge_client.rb
|
|
73
|
-
- test/test_rubyforge_cookie_manager.rb
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
require 'yaml'
|
|
2
|
-
|
|
3
|
-
class RubyForge
|
|
4
|
-
class CookieManager
|
|
5
|
-
class << self
|
|
6
|
-
def load(path)
|
|
7
|
-
cm = YAML.load_file(path) rescue CookieManager.new(path)
|
|
8
|
-
cm = CookieManager.new(path) unless cm.is_a?(CookieManager)
|
|
9
|
-
cm.clean_stale_cookies
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
attr_accessor :cookies_file
|
|
14
|
-
def initialize(cookies_file = nil)
|
|
15
|
-
@jar = Hash.new { |hash,domain_name|
|
|
16
|
-
hash[domain_name.downcase] = {}
|
|
17
|
-
}
|
|
18
|
-
@cookies_file = cookies_file
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def [](uri)
|
|
22
|
-
# FIXME we need to do more matching on hostname.... This is not
|
|
23
|
-
# bulletproof
|
|
24
|
-
uri = (URI === uri ? uri.host : uri).downcase
|
|
25
|
-
@jar[uri] ||= {}
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def clear uri
|
|
29
|
-
self[uri].clear
|
|
30
|
-
self.save!
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def empty?
|
|
34
|
-
@jar.empty? || @jar.all? { |k,v| v.empty? }
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def save!
|
|
38
|
-
clean_stale_cookies
|
|
39
|
-
File.open(@cookies_file, 'wb') { |f|
|
|
40
|
-
f.write(YAML.dump(self))
|
|
41
|
-
}
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def add(uri, cookie)
|
|
45
|
-
no_dot_domain = cookie.domain.gsub(/^\./, '')
|
|
46
|
-
return unless uri.host =~ /#{no_dot_domain}$/i
|
|
47
|
-
@jar[no_dot_domain][cookie.name] = cookie
|
|
48
|
-
clean_stale_cookies
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def clean_stale_cookies
|
|
52
|
-
@jar.each do |domain, cookies|
|
|
53
|
-
cookies.each do |name, cookie|
|
|
54
|
-
cookies.delete(name) if cookie.expires < Time.now
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
self
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
end
|