rubyforge 1.0.5 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/Manifest.txt +0 -2
- data/README.txt +1 -4
- data/Rakefile +6 -0
- data/bin/rubyforge +18 -34
- data/lib/rubyforge.rb +74 -183
- data/lib/rubyforge/client.rb +13 -34
- data/test/test_rubyforge.rb +128 -199
- data/test/test_rubyforge_client.rb +2 -67
- metadata +6 -32
- data.tar.gz.sig +0 -0
- data/lib/rubyforge/cookie_manager.rb +0 -60
- data/test/test_rubyforge_cookie_manager.rb +0 -97
- metadata.gz.sig +0 -0
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
data/README.txt
CHANGED
@@ -13,10 +13,6 @@ A script which automates a limited set of rubyforge operations.
|
|
13
13
|
* edit ~/.rubyforge/user-config.yml
|
14
14
|
* rubyforge config
|
15
15
|
* For all rubyforge upgrades, run 'rubyforge config' to ensure you have latest.
|
16
|
-
* Don't forget to login! logging in will store a cookie in your
|
17
|
-
.rubyforge directory which expires after a time. always run the
|
18
|
-
login command before any operation that requires authentication,
|
19
|
-
such as uploading a package.
|
20
16
|
|
21
17
|
== Synopsis
|
22
18
|
|
@@ -25,6 +21,7 @@ A script which automates a limited set of rubyforge operations.
|
|
25
21
|
== REQUIREMENTS
|
26
22
|
|
27
23
|
* hoe
|
24
|
+
* json
|
28
25
|
* rubygems
|
29
26
|
|
30
27
|
== INSTALL
|
data/Rakefile
CHANGED
@@ -2,14 +2,18 @@
|
|
2
2
|
|
3
3
|
require 'rubygems'
|
4
4
|
require 'hoe'
|
5
|
+
require 'json'
|
5
6
|
|
6
7
|
abort "you _must_ install this gem to release it" if
|
7
8
|
ENV['VERSION'] && ENV['VERSION'] != RubyForge::VERSION
|
8
9
|
|
10
|
+
Hoe.plugin :email
|
11
|
+
|
9
12
|
Hoe.spec "rubyforge" do
|
10
13
|
developer 'Ryan Davis', 'ryand-ruby@zenspider.com'
|
11
14
|
developer 'Eric Hodel', 'drbrain@segment7.net'
|
12
15
|
developer 'Ara T Howard', 'ara.t.howard@gmail.com'
|
16
|
+
developer 'Tom Copeland', 'tom@infoether.com'
|
13
17
|
|
14
18
|
multiruby_skip << "rubinius"
|
15
19
|
|
@@ -17,6 +21,8 @@ Hoe.spec "rubyforge" do
|
|
17
21
|
self.need_tar = false
|
18
22
|
end
|
19
23
|
|
24
|
+
task :postrelease => :announce
|
25
|
+
|
20
26
|
task :backup do
|
21
27
|
Dir.chdir File.expand_path("~/.rubyforge") do
|
22
28
|
cp "user-config.yml", "user-config.yml.bak"
|
data/bin/rubyforge
CHANGED
@@ -41,21 +41,12 @@ MODES
|
|
41
41
|
example :
|
42
42
|
#{ PROGRAM } names
|
43
43
|
|
44
|
-
login()
|
45
|
-
sends username and password from config.yml (or --username/--password
|
46
|
-
options) and stores login cookie in cookie.dat. this is required for
|
47
|
-
subsquent operations work.
|
48
|
-
|
49
|
-
example :
|
50
|
-
#{ PROGRAM } login
|
51
|
-
#{ PROGRAM } login --username zaphod --password 42
|
52
|
-
|
53
44
|
create_package(group_id, package_name)
|
54
45
|
creates the named package under the specified group.
|
55
46
|
|
56
47
|
example :
|
57
48
|
#{ PROGRAM } create_package 1024 traits
|
58
|
-
#{ PROGRAM }
|
49
|
+
#{ PROGRAM } create_package codeforpeople.com traits
|
59
50
|
|
60
51
|
add_release(group_id, package_id, release_name, userfile)
|
61
52
|
release a file as release_name under the specified group_id and
|
@@ -65,7 +56,7 @@ MODES
|
|
65
56
|
#{ PROGRAM } add_release codeforpeople.com traits 0.8.0 traits-0.8.0.gem
|
66
57
|
#{ PROGRAM } add_release codeforpeople.com traits 0.8.0 traits-0.8.0.tgz
|
67
58
|
#{ PROGRAM } add_release 1024 1242 0.8.0 traits-0.8.0.gem
|
68
|
-
#{ PROGRAM }
|
59
|
+
#{ PROGRAM } add_release 1024 1242 0.8.0 traits-0.8.0.gem
|
69
60
|
|
70
61
|
add_file(group_id, package_id, release_id, userfile)
|
71
62
|
add a file to an existing release under the specified group_id,
|
@@ -83,6 +74,12 @@ MODES
|
|
83
74
|
#{ PROGRAM } delete_package codeforpeople.com traits
|
84
75
|
#{ PROGRAM } delete_package 1024 traits
|
85
76
|
|
77
|
+
post_news(group_id, summary, details)
|
78
|
+
posts a news item to the specified group
|
79
|
+
|
80
|
+
example :
|
81
|
+
#{ PROGRAM } post_news codeforpeople.com "new release" "this release is great!"
|
82
|
+
#{ PROGRAM } post_news 1024 traits "new release" "this release is great!"
|
86
83
|
NOTES
|
87
84
|
|
88
85
|
- In order to use group_id, package_id, or release_id by name,
|
@@ -90,16 +87,10 @@ NOTES
|
|
90
87
|
rubyforge[package_ids] translation tables in your config.yml. See
|
91
88
|
the config command for more information and help.
|
92
89
|
|
93
|
-
- don\'t forget to login! logging in will store a cookie in your
|
94
|
-
.rubyforge directory which expires after a time. always run the login
|
95
|
-
command before any operation that requires authentication, such as
|
96
|
-
uploading a package.
|
97
|
-
|
98
90
|
TODO
|
99
91
|
|
100
|
-
- add error checking. this
|
101
|
-
|
102
|
-
and only the html text reveals the status.
|
92
|
+
- add error checking. this may require mods to the REST API as
|
93
|
+
well to ensure that it returns useful error codes.
|
103
94
|
|
104
95
|
OPTIONS
|
105
96
|
|
@@ -112,8 +103,6 @@ OPTIONS
|
|
112
103
|
specify username, taken from config otherwise
|
113
104
|
--password , -p
|
114
105
|
specify password, taken from config otherwise
|
115
|
-
--cookie_jar , -C
|
116
|
-
specify cookie storage file (default #{ RubyForge::COOKIE_F })
|
117
106
|
|
118
107
|
add_release :
|
119
108
|
--is_private , -P
|
@@ -140,7 +129,6 @@ opts = GetoptLong::new(
|
|
140
129
|
[ "--force" , "-F" , GetoptLong::NO_ARGUMENT ],
|
141
130
|
[ "--username" , "-u" , GetoptLong::REQUIRED_ARGUMENT ],
|
142
131
|
[ "--password" , "-p" , GetoptLong::REQUIRED_ARGUMENT ],
|
143
|
-
[ "--cookie_jar" , "-C" , GetoptLong::REQUIRED_ARGUMENT ],
|
144
132
|
[ "--is_private" , "-P" , GetoptLong::REQUIRED_ARGUMENT ],
|
145
133
|
[ "--release_date" , "-r" , GetoptLong::REQUIRED_ARGUMENT ],
|
146
134
|
[ "--type_id" , "-t" , GetoptLong::REQUIRED_ARGUMENT ],
|
@@ -171,10 +159,6 @@ when %r/names/
|
|
171
159
|
rf = rubyforge.autoconfig
|
172
160
|
puts "groups : #{rf["group_ids"].keys.sort.join(", ")}"
|
173
161
|
puts "packages: #{rf["package_ids"].keys.sort.join(", ")}"
|
174
|
-
when %r/login/
|
175
|
-
rubyforge.login
|
176
|
-
when %r/logout/
|
177
|
-
rubyforge.logout
|
178
162
|
when %r/create_package/
|
179
163
|
page, msg = "/frs/admin/index.php", "post_content"
|
180
164
|
|
@@ -185,9 +169,15 @@ when %r/create_package/
|
|
185
169
|
|
186
170
|
group_id = Integer(group_id) rescue group_id
|
187
171
|
|
188
|
-
rubyforge.login
|
189
|
-
|
190
172
|
rubyforge.create_package group_id, package_name
|
173
|
+
when %r/post_news/
|
174
|
+
group_id, summary, details = ARGV
|
175
|
+
|
176
|
+
abort "no <group_id>" unless group_id
|
177
|
+
|
178
|
+
group_id = Integer(group_id) rescue group_id
|
179
|
+
|
180
|
+
rubyforge.post_news group_id, summary, details
|
191
181
|
when %r/delete_package/
|
192
182
|
group_id, package_id = ARGV
|
193
183
|
|
@@ -197,8 +187,6 @@ when %r/delete_package/
|
|
197
187
|
group_id = Integer(group_id) rescue group_id
|
198
188
|
package_id = Integer(package_id) rescue package_id
|
199
189
|
|
200
|
-
rubyforge.login
|
201
|
-
|
202
190
|
rubyforge.delete_package group_id, package_id
|
203
191
|
when %r/add_release/
|
204
192
|
group_id, package_id, release_name, userfile = ARGV
|
@@ -211,8 +199,6 @@ when %r/add_release/
|
|
211
199
|
group_id = Integer(group_id) rescue group_id
|
212
200
|
package_id = Integer(package_id) rescue package_id
|
213
201
|
|
214
|
-
rubyforge.login
|
215
|
-
|
216
202
|
rubyforge.add_release group_id, package_id, release_name, userfile
|
217
203
|
when %r/add_file/
|
218
204
|
group_id, package_id, release_id, userfile = ARGV
|
@@ -226,8 +212,6 @@ when %r/add_file/
|
|
226
212
|
package_id = Integer(package_id) rescue package_id
|
227
213
|
release_id = Integer(release_id) rescue release_id
|
228
214
|
|
229
|
-
rubyforge.login
|
230
|
-
|
231
215
|
rubyforge.add_file group_id, package_id, release_id, userfile
|
232
216
|
else
|
233
217
|
abort USAGE
|
data/lib/rubyforge.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
#! /usr/bin/env ruby -w
|
2
2
|
|
3
|
+
require 'json'
|
3
4
|
require 'enumerator'
|
4
5
|
require 'fileutils'
|
5
6
|
require 'yaml'
|
@@ -8,14 +9,15 @@ require 'rubyforge/client'
|
|
8
9
|
|
9
10
|
$TESTING = false unless defined? $TESTING
|
10
11
|
|
12
|
+
$DEBUG=false
|
13
|
+
|
11
14
|
class RubyForge
|
12
15
|
|
13
16
|
# :stopdoc:
|
14
|
-
VERSION = '
|
17
|
+
VERSION = '2.0.0'
|
15
18
|
HOME = ENV["HOME"] || ENV["HOMEPATH"] || File::expand_path("~")
|
16
19
|
RUBYFORGE_D = File::join HOME, ".rubyforge"
|
17
20
|
CONFIG_F = File::join RUBYFORGE_D, "user-config.yml"
|
18
|
-
COOKIE_F = File::join RUBYFORGE_D, "cookie.dat"
|
19
21
|
|
20
22
|
# We must use __FILE__ instead of DATA because this is now a library
|
21
23
|
# and DATA is relative to $0, not __FILE__.
|
@@ -36,6 +38,10 @@ class RubyForge
|
|
36
38
|
@client = nil
|
37
39
|
@uri = nil
|
38
40
|
end
|
41
|
+
|
42
|
+
# These are no-ops now, but we'll keep them here for backwards compatibility
|
43
|
+
def login ; end
|
44
|
+
def logout ; end
|
39
45
|
|
40
46
|
def configure opts = {}
|
41
47
|
user_path = CONFIG_F
|
@@ -56,7 +62,6 @@ class RubyForge
|
|
56
62
|
|
57
63
|
raise "no <username>" unless @userconfig["username"]
|
58
64
|
raise "no <password>" unless @userconfig["password"]
|
59
|
-
raise "no <cookie_jar>" unless @userconfig["cookie_jar"]
|
60
65
|
|
61
66
|
self
|
62
67
|
end
|
@@ -65,10 +70,6 @@ class RubyForge
|
|
65
70
|
@userconfig['force']
|
66
71
|
end
|
67
72
|
|
68
|
-
def cookie_store
|
69
|
-
client.cookie_store
|
70
|
-
end
|
71
|
-
|
72
73
|
def uri
|
73
74
|
@uri ||= URI.parse @userconfig['uri']
|
74
75
|
end
|
@@ -82,7 +83,6 @@ class RubyForge
|
|
82
83
|
open(CONFIG_F, "w") { |f|
|
83
84
|
f.write YAML.dump(config)
|
84
85
|
}
|
85
|
-
FileUtils::touch COOKIE_F
|
86
86
|
edit = (ENV["EDITOR"] || ENV["EDIT"] || "vi") + " '#{CONFIG_F}'"
|
87
87
|
system edit or puts "edit '#{CONFIG_F}'"
|
88
88
|
end
|
@@ -99,18 +99,21 @@ class RubyForge
|
|
99
99
|
%w(group package processor release).each do |type|
|
100
100
|
@autoconfig["#{type}_ids"].clear if @autoconfig["#{type}_ids"]
|
101
101
|
end
|
102
|
+
|
103
|
+
json = get_via_rest_api "/users/#{username}/groups.js"
|
102
104
|
|
103
|
-
|
104
|
-
html = URI.parse("http://rubyforge.org/users/#{username}/index.html").read
|
105
|
-
|
106
|
-
projects = html.scan(%r%/projects/([^/]+)/%).flatten
|
107
|
-
|
105
|
+
projects = json.collect {|group| group['group']['unix_group_name'] }
|
108
106
|
puts "Fetching #{projects.size} projects"
|
109
107
|
projects.each do |project|
|
110
|
-
next if project == "support"
|
111
108
|
scrape_project(project)
|
112
109
|
end
|
113
110
|
end
|
111
|
+
|
112
|
+
def get_via_rest_api(path)
|
113
|
+
url = "#{@userconfig['uri']}#{path}"
|
114
|
+
puts "Hitting REST API: #{url}" if $DEBUG
|
115
|
+
JSON.parse(client.get_content(url, {}, {}, @userconfig))
|
116
|
+
end
|
114
117
|
|
115
118
|
def scrape_project(project)
|
116
119
|
data = {
|
@@ -120,47 +123,30 @@ class RubyForge
|
|
120
123
|
"release_ids" => Hash.new { |h,k| h[k] = {} },
|
121
124
|
}
|
122
125
|
|
123
|
-
puts "Updating #{project}"
|
124
|
-
|
125
126
|
unless data["group_ids"].has_key? project then
|
126
|
-
|
127
|
-
group_id =
|
128
|
-
|
127
|
+
json = get_via_rest_api "/groups/#{project}.js"
|
128
|
+
group_id = json["group"]["group_id"].to_i
|
129
129
|
data["group_ids"][project] = group_id
|
130
130
|
end
|
131
131
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
break
|
141
|
-
when /<h3>([^<]+)/ then
|
142
|
-
package = $1.strip
|
143
|
-
when /release_id=(\d+)">([^<]+)/ then
|
144
|
-
data["release_ids"][package][$2] = $1.to_i
|
145
|
-
when /filemodule_id=(\d+)/ then
|
146
|
-
data["package_ids"][package] = $1.to_i
|
132
|
+
# Get project's packages
|
133
|
+
json = get_via_rest_api "/groups/#{project}/packages.js"
|
134
|
+
json.each do |package|
|
135
|
+
data["package_ids"][package["package"]["name"]] = package["package"]["package_id"]
|
136
|
+
# Get releases for this package
|
137
|
+
json = get_via_rest_api "/packages/#{package["package"]["package_id"]}/releases.js"
|
138
|
+
json.each do |release|
|
139
|
+
data["release_ids"][package["package"]["name"]][release["name"]] = release["release_id"]
|
147
140
|
end
|
148
141
|
end
|
149
142
|
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
html = client.get_content "http://rubyforge.org/frs/admin/qrs.php?package=&group_id=#{group_id}"
|
158
|
-
|
159
|
-
html =~ /<select name="processor_id">(.*?)<\/select>/m
|
160
|
-
processors = $1
|
161
|
-
processors.scan(/<option value="(\d{4})">([^<]+)/) do
|
162
|
-
data["processor_ids"][$2] = $1.to_i
|
163
|
-
end if processors
|
143
|
+
# Get processor ids
|
144
|
+
if @autoconfig['processor_ids'].nil? || @autoconfig['processor_ids'].empty?
|
145
|
+
puts "Fetching processor ids" if $DEBUG
|
146
|
+
json = get_via_rest_api "/processors.js"
|
147
|
+
json.each do |processor|
|
148
|
+
data["processor_ids"][processor["processor"]["name"]] = processor["processor"]["processor_id"]
|
149
|
+
end
|
164
150
|
end
|
165
151
|
|
166
152
|
data.each do |key, val|
|
@@ -171,51 +157,16 @@ class RubyForge
|
|
171
157
|
save_autoconfig
|
172
158
|
end
|
173
159
|
|
174
|
-
def logout
|
175
|
-
cookie_store.clear "rubyforge.org"
|
176
|
-
end
|
177
|
-
|
178
|
-
def login
|
179
|
-
return if(!force and cookie_store['rubyforge.org']['session_ser']) rescue false
|
180
|
-
|
181
|
-
page = self.uri + "/account/login.php"
|
182
|
-
page.scheme = 'https'
|
183
|
-
page = URI.parse page.to_s # set SSL port correctly
|
184
|
-
|
185
|
-
username = @userconfig["username"]
|
186
|
-
password = @userconfig["password"]
|
187
|
-
|
188
|
-
form = {
|
189
|
-
"return_to" => "",
|
190
|
-
"form_loginname" => username,
|
191
|
-
"form_pw" => password,
|
192
|
-
"login" => "Login"
|
193
|
-
}
|
194
|
-
|
195
|
-
response = run page, form
|
196
|
-
|
197
|
-
re = %r/personal\s+page/iom
|
198
|
-
unless response =~ re
|
199
|
-
warn("%s:%d: warning: potentially failed login using %s" %
|
200
|
-
[__FILE__, __LINE__, username]) unless $TESTING
|
201
|
-
end
|
202
|
-
|
203
|
-
response
|
204
|
-
end
|
205
|
-
|
206
160
|
def create_package(group_id, package_name)
|
207
|
-
page = "/
|
161
|
+
page = "/groups/#{group_id}/packages"
|
208
162
|
|
209
163
|
group_id = lookup "group", group_id
|
210
164
|
is_private = @userconfig["is_private"]
|
211
165
|
is_public = is_private ? 0 : 1
|
212
166
|
|
213
167
|
form = {
|
214
|
-
"
|
215
|
-
"
|
216
|
-
"package_name" => package_name,
|
217
|
-
"is_public" => is_public,
|
218
|
-
"submit" => "Create This Package",
|
168
|
+
"package[name]" => package_name,
|
169
|
+
"package[is_public]" => is_public
|
219
170
|
}
|
220
171
|
|
221
172
|
run page, form
|
@@ -228,102 +179,61 @@ class RubyForge
|
|
228
179
|
# Posts news item to +group_id+ (can be name) with +subject+ and +body+
|
229
180
|
|
230
181
|
def post_news(group_id, subject, body)
|
231
|
-
|
232
|
-
group_id = lookup "group", group_id
|
233
|
-
|
182
|
+
# TODO - what was the post_changes parameter for?
|
234
183
|
form = {
|
235
|
-
"
|
236
|
-
"
|
237
|
-
"summary" => subject,
|
238
|
-
"details" => body,
|
239
|
-
"submit" => "Submit",
|
184
|
+
"news_byte[summary]" => subject,
|
185
|
+
"news_byte[details]" => body
|
240
186
|
}
|
241
|
-
|
242
|
-
|
187
|
+
group_id = lookup "group", group_id
|
188
|
+
url = "/groups/#{group_id}/news_bytes"
|
189
|
+
run url, form
|
243
190
|
end
|
244
191
|
|
245
192
|
def delete_package(group_id, package_id)
|
246
|
-
page = "/frs/admin/index.php"
|
247
|
-
|
248
193
|
group_id = lookup "group", group_id
|
249
194
|
package_id = lookup "package", package_id
|
250
|
-
|
251
|
-
form = {
|
252
|
-
"func" => "delete_package",
|
253
|
-
"group_id" => group_id,
|
254
|
-
"package_id" => package_id,
|
255
|
-
"sure" => "1",
|
256
|
-
"really_sure" => "1",
|
257
|
-
"submit" => "Delete",
|
258
|
-
}
|
259
|
-
|
260
195
|
package_name = @autoconfig["package_ids"].invert[package_id]
|
261
196
|
@autoconfig["package_ids"].delete package_name
|
262
197
|
@autoconfig["release_ids"].delete package_name
|
263
198
|
save_autoconfig
|
264
|
-
|
265
|
-
run
|
199
|
+
url = "/packages/#{package_id}"
|
200
|
+
run url, {"_method" => "delete"}
|
266
201
|
end
|
267
202
|
|
268
203
|
def add_release(group_id, package_id, release_name, *files)
|
269
|
-
userfile = files.shift
|
270
|
-
page = "/frs/admin/qrs.php"
|
271
|
-
|
272
204
|
group_id = lookup "group", group_id
|
273
205
|
package_id = lookup "package", package_id
|
274
|
-
userfile = open userfile, 'rb'
|
275
206
|
release_date = @userconfig["release_date"]
|
276
|
-
type_id = @userconfig["type_id"]
|
277
|
-
processor_id = @userconfig["processor_id"]
|
278
207
|
release_notes = @userconfig["release_notes"]
|
279
208
|
release_changes = @userconfig["release_changes"]
|
280
209
|
preformatted = @userconfig["preformatted"]
|
281
|
-
|
282
210
|
release_date ||= Time.now.strftime("%Y-%m-%d %H:%M")
|
283
|
-
|
284
|
-
type_id ||= userfile.path[%r|\.[^\./]+$|]
|
285
|
-
type_id = (lookup "type", type_id rescue lookup "type", ".oth")
|
286
|
-
|
287
|
-
processor_id ||= "Any"
|
288
|
-
processor_id = lookup "processor", processor_id
|
289
|
-
|
290
211
|
release_notes = IO::read(release_notes) if
|
291
212
|
test(?e, release_notes) if release_notes
|
292
|
-
|
293
213
|
release_changes = IO::read(release_changes) if
|
294
214
|
test(?e, release_changes) if release_changes
|
295
|
-
|
296
215
|
preformatted = preformatted ? 1 : 0
|
297
216
|
|
298
217
|
form = {
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
"processor_id" => processor_id,
|
305
|
-
"release_notes" => release_notes,
|
306
|
-
"release_changes" => release_changes,
|
307
|
-
"preformatted" => preformatted,
|
308
|
-
"userfile" => userfile,
|
309
|
-
"submit" => "Release File"
|
218
|
+
"release[name]" => release_name,
|
219
|
+
"release[release_date]" => release_date,
|
220
|
+
"release[notes]" => release_notes,
|
221
|
+
"release[changes]" => release_changes,
|
222
|
+
"release[preformatted]" => preformatted,
|
310
223
|
}
|
311
224
|
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
raise "Invalid package_id #{package_id}" if html[/Invalid package_id/]
|
317
|
-
raise "You have already released this version." if html[/That filename already exists in this project/]
|
318
|
-
|
319
|
-
release_id = html[/release_id=\d+/][/\d+/].to_i rescue nil
|
320
|
-
|
225
|
+
url = "/packages/#{package_id}/releases"
|
226
|
+
json = run url, form
|
227
|
+
|
228
|
+
release_id = JSON.parse(json)["release_id"].to_i rescue nil
|
321
229
|
unless release_id then
|
322
|
-
puts
|
323
|
-
raise "Couldn't get release_id, upload failed
|
230
|
+
puts json if $DEBUG
|
231
|
+
raise "Couldn't get release_id, upload failed?"
|
324
232
|
end
|
325
233
|
|
326
|
-
|
234
|
+
# FIXME
|
235
|
+
#raise "Invalid package_id #{package_id}" if html[/Invalid package_id/]
|
236
|
+
#raise "You have already released this version." if html[/That filename already exists in this project/]
|
327
237
|
|
328
238
|
files.each do |file|
|
329
239
|
add_file(group_id, package_id, release_id, file)
|
@@ -348,35 +258,29 @@ class RubyForge
|
|
348
258
|
# add_file(1024, 1242, "0.8.0", "traits-0.8.0.gem")
|
349
259
|
|
350
260
|
def add_file(group_name, package_name, release_name, userfile)
|
351
|
-
page = '/frs/admin/editrelease.php'
|
352
261
|
type_id = @userconfig["type_id"]
|
353
262
|
group_id = lookup "group", group_name
|
354
263
|
package_id = lookup "package", package_name
|
355
264
|
release_id = (Integer === release_name) ? release_name : lookup("release", package_name)[release_name]
|
356
|
-
|
357
|
-
|
358
|
-
page = "/frs/admin/editrelease.php?group_id=#{group_id}&release_id=#{release_id}&package_id=#{package_id}"
|
265
|
+
url = "/releases/#{release_id}/files.js"
|
359
266
|
|
360
267
|
userfile = open userfile, 'rb'
|
361
268
|
|
362
269
|
type_id ||= userfile.path[%r|\.[^\./]+$|]
|
363
270
|
type_id = (lookup "type", type_id rescue lookup "type", ".oth")
|
364
271
|
|
272
|
+
processor_id = @userconfig["processor_id"]
|
365
273
|
processor_id ||= "Any"
|
366
274
|
processor_id = lookup "processor", processor_id
|
367
275
|
|
368
276
|
form = {
|
369
|
-
"
|
370
|
-
"
|
371
|
-
"
|
372
|
-
"
|
373
|
-
|
374
|
-
}
|
375
|
-
|
376
|
-
boundary = Array::new(8){ "%2.2d" % rand(42) }.join('__')
|
377
|
-
boundary = "multipart/form-data; boundary=___#{ boundary }___"
|
277
|
+
"file[filename]" => File.basename(userfile.path),
|
278
|
+
"file[processor_id]" => processor_id,
|
279
|
+
"file[type_id]" => type_id,
|
280
|
+
"contents" => userfile.read
|
281
|
+
}
|
378
282
|
|
379
|
-
run
|
283
|
+
run url, form
|
380
284
|
end
|
381
285
|
|
382
286
|
def client
|
@@ -384,29 +288,16 @@ class RubyForge
|
|
384
288
|
|
385
289
|
@client = RubyForge::Client::new ENV["HTTP_PROXY"]
|
386
290
|
@client.debug_dev = STDERR if ENV["RUBYFORGE_DEBUG"] || ENV["DEBUG"] || $DEBUG
|
387
|
-
@client.cookie_store = @userconfig["cookie_jar"]
|
388
291
|
|
389
292
|
@client
|
390
293
|
end
|
391
294
|
|
392
295
|
def run(page, form, extheader={}) # :nodoc:
|
393
296
|
uri = self.uri + page
|
394
|
-
if $DEBUG
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
response = client.post_content uri, form, extheader
|
399
|
-
|
400
|
-
client.save_cookie_store
|
401
|
-
|
402
|
-
if $DEBUG then
|
403
|
-
response.sub!(/\A.*end tabGenerator -->/m, '')
|
404
|
-
response.gsub!(/\t/, ' ')
|
405
|
-
response.gsub!(/\n{3,}/, "\n\n")
|
406
|
-
puts response
|
407
|
-
end
|
408
|
-
|
409
|
-
return response
|
297
|
+
puts "client.post_content #{uri.inspect}, #{form.inspect}, #{extheader.inspect}" if $DEBUG
|
298
|
+
response = client.post_content uri, form, extheader, @userconfig
|
299
|
+
puts response if $DEBUG
|
300
|
+
response
|
410
301
|
end
|
411
302
|
|
412
303
|
def lookup(type, val) # :nodoc:
|
@@ -423,11 +314,11 @@ __END__
|
|
423
314
|
#
|
424
315
|
# base rubyforge uri - store in #{ CONFIG_F }
|
425
316
|
#
|
426
|
-
uri : http://rubyforge.org
|
317
|
+
uri : http://api.rubyforge.org
|
427
318
|
#
|
428
319
|
# this must be your username
|
429
320
|
#
|
430
|
-
username :
|
321
|
+
username : tom
|
431
322
|
#
|
432
323
|
# this must be your password
|
433
324
|
#
|
@@ -435,7 +326,6 @@ __END__
|
|
435
326
|
#
|
436
327
|
# defaults for some values
|
437
328
|
#
|
438
|
-
cookie_jar : #{ COOKIE_F }
|
439
329
|
is_private : false
|
440
330
|
# AUTOCONFIG:
|
441
331
|
rubyforge :
|
@@ -444,6 +334,7 @@ __END__
|
|
444
334
|
#
|
445
335
|
group_ids :
|
446
336
|
codeforpeople : 1024
|
337
|
+
support : 5
|
447
338
|
#
|
448
339
|
# map your package names to their rubyforge ids
|
449
340
|
#
|