rubyforge 1.0.1 → 1.0.2
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 +7 -0
- data/README.txt +34 -0
- data/Rakefile +2 -0
- data/bin/rubyforge +20 -10
- data/lib/rubyforge.rb +20 -7
- data/lib/rubyforge/client.rb +5 -1
- data/lib/rubyforge/cookie_manager.rb +10 -1
- metadata +3 -3
data/History.txt
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
== Version History:
|
2
2
|
|
3
|
+
=== 1.0.2 / 2009-01-05:
|
4
|
+
|
5
|
+
* All webby commands now login automatically.
|
6
|
+
* Login now no-ops if it already has a session cookie.
|
7
|
+
* Added logout command.
|
8
|
+
* Much more of the config is self-repairing, but still not bulletproof yet.
|
9
|
+
|
3
10
|
=== 1.0.1 / 2008-10-22:
|
4
11
|
|
5
12
|
* Fixed multipart form upload so it isn't url escaping the data. DOH.
|
data/README.txt
CHANGED
@@ -22,3 +22,37 @@ A script which automates a limited set of rubyforge operations.
|
|
22
22
|
|
23
23
|
rubyforge [options]* mode [mode_args]*
|
24
24
|
|
25
|
+
== REQUIREMENTS
|
26
|
+
|
27
|
+
* hoe
|
28
|
+
* rubygems
|
29
|
+
|
30
|
+
== INSTALL
|
31
|
+
|
32
|
+
* sudo gem install rubyforge
|
33
|
+
|
34
|
+
== LICENSE
|
35
|
+
|
36
|
+
(The MIT License)
|
37
|
+
|
38
|
+
Copyright (c) 2006-2009 Ryan Davis, Eric Hodel, Ara T Howard.
|
39
|
+
|
40
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
41
|
+
a copy of this software and associated documentation files (the
|
42
|
+
"Software"), to deal in the Software without restriction, including
|
43
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
44
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
45
|
+
permit persons to whom the Software is furnished to do so, subject to
|
46
|
+
the following conditions:
|
47
|
+
|
48
|
+
The above copyright notice and this permission notice shall be
|
49
|
+
included in all copies or substantial portions of the Software.
|
50
|
+
|
51
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
52
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
53
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
54
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
55
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
56
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
57
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
58
|
+
|
data/Rakefile
CHANGED
data/bin/rubyforge
CHANGED
@@ -172,51 +172,61 @@ when %r/names/
|
|
172
172
|
puts "packages: #{rf["package_ids"].keys.sort.join(", ")}"
|
173
173
|
when %r/login/
|
174
174
|
rubyforge.login
|
175
|
+
when %r/logout/
|
176
|
+
rubyforge.logout
|
175
177
|
when %r/create_package/
|
176
178
|
page, msg = "/frs/admin/index.php", "post_content"
|
177
179
|
|
178
180
|
group_id, package_name = ARGV
|
179
181
|
|
180
|
-
abort "no <group_id>"
|
182
|
+
abort "no <group_id>" unless group_id
|
181
183
|
abort "no <package_name>" unless package_name
|
182
184
|
|
183
185
|
group_id = Integer(group_id) rescue group_id
|
184
186
|
|
187
|
+
rubyforge.login
|
188
|
+
|
185
189
|
rubyforge.create_package group_id, package_name
|
186
190
|
when %r/delete_package/
|
187
191
|
group_id, package_id = ARGV
|
188
192
|
|
189
|
-
abort "no <group_id>"
|
193
|
+
abort "no <group_id>" unless group_id
|
190
194
|
abort "no <package_id>" unless package_id
|
191
195
|
|
192
|
-
group_id
|
196
|
+
group_id = Integer(group_id) rescue group_id
|
193
197
|
package_id = Integer(package_id) rescue package_id
|
194
198
|
|
199
|
+
rubyforge.login
|
200
|
+
|
195
201
|
rubyforge.delete_package group_id, package_id
|
196
202
|
when %r/add_release/
|
197
203
|
group_id, package_id, release_name, userfile = ARGV
|
198
204
|
|
199
|
-
abort "no <group_id>"
|
200
|
-
abort "no <package_id>"
|
205
|
+
abort "no <group_id>" unless group_id
|
206
|
+
abort "no <package_id>" unless package_id
|
201
207
|
abort "no <release_name>" unless release_name
|
202
|
-
abort "no <userfile>"
|
208
|
+
abort "no <userfile>" unless userfile
|
203
209
|
|
204
|
-
group_id
|
210
|
+
group_id = Integer(group_id) rescue group_id
|
205
211
|
package_id = Integer(package_id) rescue package_id
|
206
212
|
|
213
|
+
rubyforge.login
|
214
|
+
|
207
215
|
rubyforge.add_release group_id, package_id, release_name, userfile
|
208
216
|
when %r/add_file/
|
209
217
|
group_id, package_id, release_id, userfile = ARGV
|
210
218
|
|
211
|
-
abort "no <group_id>"
|
219
|
+
abort "no <group_id>" unless group_id
|
212
220
|
abort "no <package_id>" unless package_id
|
213
221
|
abort "no <release_id>" unless release_id
|
214
|
-
abort "no <userfile>"
|
222
|
+
abort "no <userfile>" unless userfile
|
215
223
|
|
216
|
-
group_id
|
224
|
+
group_id = Integer(group_id) rescue group_id
|
217
225
|
package_id = Integer(package_id) rescue package_id
|
218
226
|
release_id = Integer(release_id) rescue release_id
|
219
227
|
|
228
|
+
rubyforge.login
|
229
|
+
|
220
230
|
rubyforge.add_file group_id, package_id, release_id, userfile
|
221
231
|
else
|
222
232
|
abort USAGE
|
data/lib/rubyforge.rb
CHANGED
@@ -11,7 +11,7 @@ $TESTING = false unless defined? $TESTING
|
|
11
11
|
class RubyForge
|
12
12
|
|
13
13
|
# :stopdoc:
|
14
|
-
VERSION = '1.0.
|
14
|
+
VERSION = '1.0.2'
|
15
15
|
HOME = ENV["HOME"] || ENV["HOMEPATH"] || File::expand_path("~")
|
16
16
|
RUBYFORGE_D = File::join HOME, ".rubyforge"
|
17
17
|
CONFIG_F = File::join RUBYFORGE_D, "user-config.yml"
|
@@ -23,6 +23,7 @@ class RubyForge
|
|
23
23
|
CONFIG = YAML.load(config)
|
24
24
|
# :startdoc:
|
25
25
|
|
26
|
+
# TODO: add an autoconfig method that is self-repairing, removing key checks
|
26
27
|
attr_reader :userconfig, :autoconfig
|
27
28
|
|
28
29
|
def initialize(userconfig=nil, autoconfig=nil, opts=nil)
|
@@ -60,6 +61,10 @@ class RubyForge
|
|
60
61
|
self
|
61
62
|
end
|
62
63
|
|
64
|
+
def cookie_store
|
65
|
+
client.cookie_store
|
66
|
+
end
|
67
|
+
|
63
68
|
def uri
|
64
69
|
@uri ||= URI.parse @userconfig['uri']
|
65
70
|
end
|
@@ -88,7 +93,7 @@ class RubyForge
|
|
88
93
|
username = @userconfig['username']
|
89
94
|
|
90
95
|
%w(group package processor release).each do |type|
|
91
|
-
@autoconfig["#{type}_ids"].clear
|
96
|
+
@autoconfig["#{type}_ids"].clear if @autoconfig["#{type}_ids"]
|
92
97
|
end
|
93
98
|
|
94
99
|
puts "Getting #{username}"
|
@@ -105,10 +110,10 @@ class RubyForge
|
|
105
110
|
|
106
111
|
def scrape_project(project)
|
107
112
|
data = {
|
108
|
-
"group_ids"
|
109
|
-
"package_ids"
|
113
|
+
"group_ids" => {},
|
114
|
+
"package_ids" => {},
|
110
115
|
"processor_ids" => Hash.new { |h,k| h[k] = {} },
|
111
|
-
"release_ids"
|
116
|
+
"release_ids" => Hash.new { |h,k| h[k] = {} },
|
112
117
|
}
|
113
118
|
|
114
119
|
puts "Updating #{project}"
|
@@ -136,7 +141,8 @@ class RubyForge
|
|
136
141
|
end
|
137
142
|
|
138
143
|
if not data['release_ids'][package].empty? and
|
139
|
-
|
144
|
+
(@autoconfig['processor_ids'].nil? or
|
145
|
+
@autoconfig['processor_ids'].empty?) then
|
140
146
|
puts "Fetching processor ids"
|
141
147
|
|
142
148
|
login
|
@@ -151,13 +157,20 @@ class RubyForge
|
|
151
157
|
end
|
152
158
|
|
153
159
|
data.each do |key, val|
|
160
|
+
@autoconfig[key] ||= {}
|
154
161
|
@autoconfig[key].merge! val
|
155
162
|
end
|
156
163
|
|
157
164
|
save_autoconfig
|
158
165
|
end
|
159
166
|
|
167
|
+
def logout
|
168
|
+
cookie_store.clear "rubyforge.org"
|
169
|
+
end
|
170
|
+
|
160
171
|
def login
|
172
|
+
return if cookie_store['rubyforge.org']['session_ser'] rescue false
|
173
|
+
|
161
174
|
page = self.uri + "/account/login.php"
|
162
175
|
page.scheme = 'https'
|
163
176
|
page = URI.parse page.to_s # set SSL port correctly
|
@@ -177,7 +190,7 @@ class RubyForge
|
|
177
190
|
re = %r/personal\s+page\s+for:\s+#{ Regexp.escape username }/iom
|
178
191
|
unless response =~ re
|
179
192
|
warn("%s:%d: warning: potentially failed login using %s:%s" %
|
180
|
-
|
193
|
+
[__FILE__,__LINE__,username,password]) unless $TESTING
|
181
194
|
end
|
182
195
|
|
183
196
|
response
|
data/lib/rubyforge/client.rb
CHANGED
@@ -36,6 +36,10 @@ class RubyForge
|
|
36
36
|
@agent_class = Net::HTTP
|
37
37
|
end
|
38
38
|
|
39
|
+
def cookie_store
|
40
|
+
@cookie_manager
|
41
|
+
end
|
42
|
+
|
39
43
|
def cookie_store=(path)
|
40
44
|
@cookie_manager = CookieManager.load(path)
|
41
45
|
end
|
@@ -59,7 +63,7 @@ class RubyForge
|
|
59
63
|
|
60
64
|
@cookie_manager[uri].each { |k,v|
|
61
65
|
request['Cookie'] = v.to_s
|
62
|
-
}
|
66
|
+
} if @cookie_manager[uri]
|
63
67
|
|
64
68
|
http = agent_class.new( uri.host, uri.port )
|
65
69
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
1
3
|
class RubyForge
|
2
4
|
class CookieManager
|
3
5
|
class << self
|
@@ -19,7 +21,13 @@ class RubyForge
|
|
19
21
|
def [](uri)
|
20
22
|
# FIXME we need to do more matching on hostname.... This is not
|
21
23
|
# bulletproof
|
22
|
-
|
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!
|
23
31
|
end
|
24
32
|
|
25
33
|
def empty?
|
@@ -27,6 +35,7 @@ class RubyForge
|
|
27
35
|
end
|
28
36
|
|
29
37
|
def save!
|
38
|
+
clean_stale_cookies
|
30
39
|
File.open(@cookies_file, 'wb') { |f|
|
31
40
|
f.write(YAML.dump(self))
|
32
41
|
}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubyforge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Davis
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date:
|
14
|
+
date: 2009-01-05 00:00:00 -08:00
|
15
15
|
default_executable:
|
16
16
|
dependencies: []
|
17
17
|
|
@@ -63,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
63
63
|
requirements: []
|
64
64
|
|
65
65
|
rubyforge_project: codeforpeople
|
66
|
-
rubygems_version: 1.3.
|
66
|
+
rubygems_version: 1.3.1
|
67
67
|
signing_key:
|
68
68
|
specification_version: 2
|
69
69
|
summary: A script which automates a limited set of rubyforge operations
|