rubyforge 1.0.4 → 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 +11 -0
- data/Manifest.txt +0 -2
- data/README.txt +1 -4
- data/Rakefile +6 -0
- data/bin/rubyforge +18 -34
- data/lib/rubyforge/client.rb +13 -34
- data/lib/rubyforge.rb +74 -181
- data/test/test_rubyforge.rb +128 -199
- data/test/test_rubyforge_client.rb +2 -67
- metadata +4 -9
- data/lib/rubyforge/cookie_manager.rb +0 -60
- data/test/test_rubyforge_cookie_manager.rb +0 -97
data/History.txt
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
=== 2.0.0 / 2009-09-21
|
|
2
|
+
|
|
3
|
+
* Modified to use RubyForge REST API rather than scraping HTML.
|
|
4
|
+
|
|
5
|
+
=== 1.0.5 / 2009-09-15
|
|
6
|
+
|
|
7
|
+
* Added experimental script to sync RF trackers with release names.
|
|
8
|
+
* Fixed that damned processor_id bug. (hinegardner)
|
|
9
|
+
* The century usually doesn't change across runs. Refactor.
|
|
10
|
+
* Fix use of Time.utc if args.size < 10, tho seems unnecessary.
|
|
11
|
+
|
|
1
12
|
=== 1.0.4 / 2009-07-21
|
|
2
13
|
|
|
3
14
|
* Uses the passed in proxy, if provided. (Thanks sdabet, RF #24071).
|
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/client.rb
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
require 'webrick/cookie'
|
|
2
2
|
require 'net/http'
|
|
3
3
|
require 'net/https'
|
|
4
|
-
require 'rubyforge/cookie_manager'
|
|
5
4
|
|
|
6
5
|
# clean up warnings caused by web servers that send down 2 digit years
|
|
7
6
|
class Time
|
|
7
|
+
CENTURY = Time.now.year / 100 * 100
|
|
8
|
+
|
|
8
9
|
class << self
|
|
9
10
|
alias :old_utc :utc
|
|
10
11
|
|
|
11
12
|
def utc(*args)
|
|
12
|
-
|
|
13
|
-
args[0] += century if args[0] < 100
|
|
13
|
+
args[0] += CENTURY if args[0] < 100
|
|
14
14
|
old_utc(*args)
|
|
15
15
|
end
|
|
16
16
|
end
|
|
@@ -32,7 +32,6 @@ class RubyForge
|
|
|
32
32
|
def initialize(proxy = nil)
|
|
33
33
|
@debug_dev = nil
|
|
34
34
|
@ssl_verify_mode = OpenSSL::SSL::VERIFY_NONE
|
|
35
|
-
@cookie_manager = CookieManager.new
|
|
36
35
|
if proxy
|
|
37
36
|
begin
|
|
38
37
|
proxy_uri = URI.parse(proxy)
|
|
@@ -43,41 +42,31 @@ class RubyForge
|
|
|
43
42
|
@agent_class ||= Net::HTTP
|
|
44
43
|
end
|
|
45
44
|
|
|
46
|
-
def
|
|
47
|
-
@cookie_manager
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def cookie_store=(path)
|
|
51
|
-
@cookie_manager = CookieManager.load(path)
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def post_content(uri, form = {}, headers = {})
|
|
45
|
+
def post_content(uri, form = {}, headers = {}, userconfig = nil)
|
|
55
46
|
uri = URI.parse(uri) unless uri.is_a?(URI)
|
|
56
47
|
request = agent_class::Post.new(uri.request_uri)
|
|
57
|
-
execute(request, uri, form, headers)
|
|
48
|
+
execute(request, uri, form, headers, userconfig)
|
|
58
49
|
end
|
|
59
50
|
|
|
60
|
-
def get_content(uri, query = {}, headers = {})
|
|
51
|
+
def get_content(uri, query = {}, headers = {}, userconfig = nil)
|
|
61
52
|
uri = URI.parse(uri) unless uri.is_a?(URI)
|
|
62
53
|
request = agent_class::Get.new(uri.request_uri)
|
|
63
|
-
execute(request, uri, query, headers)
|
|
54
|
+
execute(request, uri, query, headers, userconfig)
|
|
64
55
|
end
|
|
65
56
|
|
|
66
|
-
def execute(request, uri, parameters = {}, headers = {})
|
|
57
|
+
def execute(request, uri, parameters = {}, headers = {}, userconfig = nil)
|
|
67
58
|
{
|
|
68
59
|
'content-type' => 'application/x-www-form-urlencoded'
|
|
69
60
|
}.merge(headers).each { |k,v| request[k] = v }
|
|
70
61
|
|
|
71
|
-
@cookie_manager[uri].each { |k,v|
|
|
72
|
-
request['Cookie'] = v.to_s
|
|
73
|
-
} if @cookie_manager[uri]
|
|
74
|
-
|
|
75
62
|
http = agent_class.new( uri.host, uri.port )
|
|
76
63
|
|
|
77
|
-
if uri.scheme == 'https'
|
|
78
|
-
|
|
79
|
-
|
|
64
|
+
if uri.scheme == 'https' && uri.host !~ /localhost/
|
|
65
|
+
http.use_ssl = true
|
|
66
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
|
80
67
|
end
|
|
68
|
+
|
|
69
|
+
request.basic_auth(userconfig["username"], userconfig["password"])
|
|
81
70
|
|
|
82
71
|
request_data = case request['Content-Type']
|
|
83
72
|
when /boundary=(.*)$/
|
|
@@ -88,13 +77,6 @@ class RubyForge
|
|
|
88
77
|
request['Content-Length'] = request_data.length.to_s
|
|
89
78
|
|
|
90
79
|
response = http.request(request, request_data)
|
|
91
|
-
(response.get_fields('Set-Cookie') || []).each do |raw_cookie|
|
|
92
|
-
WEBrick::Cookie.parse_set_cookies(raw_cookie).each { |baked_cookie|
|
|
93
|
-
baked_cookie.domain ||= url.host
|
|
94
|
-
baked_cookie.path ||= url.path
|
|
95
|
-
@cookie_manager.add(uri, baked_cookie)
|
|
96
|
-
}
|
|
97
|
-
end
|
|
98
80
|
|
|
99
81
|
return response.body if response.class <= Net::HTTPSuccess
|
|
100
82
|
|
|
@@ -138,8 +120,5 @@ class RubyForge
|
|
|
138
120
|
}.compact.join('&')
|
|
139
121
|
end
|
|
140
122
|
|
|
141
|
-
def save_cookie_store
|
|
142
|
-
@cookie_manager.save!
|
|
143
|
-
end
|
|
144
123
|
end
|
|
145
124
|
end
|