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 CHANGED
@@ -1,52 +1,74 @@
1
- == Version History:
1
+ === 2.0.0 / 2009-09-21
2
2
 
3
- === 1.0.2 / 2009-01-05:
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
+
12
+ === 1.0.4 / 2009-07-21
13
+
14
+ * Uses the passed in proxy, if provided. (Thanks sdabet, RF #24071).
15
+ * Update group_id pattern for scraping project configs you are only a member of.
16
+ * Update regexp used to validate login page to be less restrictive.
17
+ * Fixed --help to not require an argument.
18
+ * add --force flag for login command to ignore previous cookie. (or use logout)
19
+
20
+ === 1.0.3 / 2009-02-26
21
+
22
+ * Fixed nil error in our Net::HTTP patches.
23
+ * Removed password from warning if the login possibly failed.
24
+
25
+ === 1.0.2 / 2009-01-05
4
26
 
5
27
  * All webby commands now login automatically.
6
28
  * Login now no-ops if it already has a session cookie.
7
29
  * Added logout command.
8
30
  * Much more of the config is self-repairing, but still not bulletproof yet.
9
31
 
10
- === 1.0.1 / 2008-10-22:
32
+ === 1.0.1 / 2008-10-22
11
33
 
12
34
  * Fixed multipart form upload so it isn't url escaping the data. DOH.
13
35
  * Affects release_notes and release_changes, but never reported for 5 months.
14
36
 
15
- === 1.0.0 / 2008-05-20:
37
+ === 1.0.0 / 2008-05-20
16
38
 
17
39
  * Removed HTTPAccess2, thanks to Aaron Patterson. Even tho he's whiny.
18
40
  * Changed initialize/configure to make testing scream. 100x faster.
19
41
 
20
- === 0.4.5 / 2008-03-11:
42
+ === 0.4.5 / 2008-03-11
21
43
 
22
44
  * Update for Ruby 1.9.0.
23
45
  * Updated History, Rakefile, and Readme for new hoe abilities.
24
46
  * Added config backup/restore rake tasks (for testing).
25
47
 
26
- === 0.4.4 / 2007-08-13:
48
+ === 0.4.4 / 2007-08-13
27
49
 
28
50
  * New type_id values will merge with extant data. (self-repairing data is Good)
29
51
  * Scrape processor_ids, merging in with extant data.
30
52
  * Default to "Other" if a file's type is unrecognized.
31
53
 
32
- === 0.4.3 / 2007-07-23:
54
+ === 0.4.3 / 2007-07-23
33
55
 
34
56
  * Set mode on .rubyforge directory to 700.
35
57
  * Fix fetching of user id when user has no releases.
36
58
 
37
- === 0.4.2 / 2007-05-21:
59
+ === 0.4.2 / 2007-05-21
38
60
 
39
61
  * Fix for windoze users (spaces in path).
40
62
  * Added check for extant release.
41
63
  * Added default hash for first-time releases.
42
64
 
43
- === 0.4.1 / 2007-03-08:
65
+ === 0.4.1 / 2007-03-08
44
66
 
45
67
  * Verify that login succeeded and warn against if not (prolly should raise).
46
68
  * Print a friendly error if you have the wrong package id.
47
69
  * Handle upload error in add_release a bit better.
48
70
 
49
- === 0.4.0 / 2007-01-09:
71
+ === 0.4.0 / 2007-01-09
50
72
 
51
73
  * config.yml split and moved to user-config.yml (up to the user to do).
52
74
  * auto-config.yml now generated via config command.
@@ -57,17 +79,17 @@
57
79
  * scrape_config no longer takes a user param. Use opts to specify.
58
80
  * scrape_project, add_project, add/remove_release now save automatically.
59
81
 
60
- === 0.3.2 / 2006-11-29:
82
+ === 0.3.2 / 2006-11-29
61
83
 
62
84
  * Fixed file uploads for windows.
63
85
  * Correctly scrape releases with funky characters.
64
86
 
65
- === 0.3.1 / 2006-10-24:
87
+ === 0.3.1 / 2006-10-24
66
88
 
67
89
  * Added SSL login.
68
90
  * Added yet more debugging output if $DEBUG.
69
91
 
70
- === 0.3.0 / 2006-09-30:
92
+ === 0.3.0 / 2006-09-30
71
93
 
72
94
  * Added more debugging output if $DEBUG
73
95
  * Added news posting.
@@ -75,11 +97,11 @@
75
97
  * add_release now returns release_id
76
98
  * Fixed config scraper to include '-' in names.
77
99
 
78
- === 0.2.1 / 2006-09-14:
100
+ === 0.2.1 / 2006-09-14
79
101
 
80
102
  * Gemspec was too loose about packaging. Now using manifest.
81
103
 
82
- === 0.2.0 / 2006-09-13:
104
+ === 0.2.0 / 2006-09-13
83
105
 
84
106
  * Split original script into script and library.
85
107
  * Added tests for library.
data/Manifest.txt CHANGED
@@ -5,7 +5,5 @@ Rakefile
5
5
  bin/rubyforge
6
6
  lib/rubyforge.rb
7
7
  lib/rubyforge/client.rb
8
- lib/rubyforge/cookie_manager.rb
9
8
  test/test_rubyforge.rb
10
9
  test/test_rubyforge_client.rb
11
- test/test_rubyforge_cookie_manager.rb
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
@@ -35,7 +32,7 @@ A script which automates a limited set of rubyforge operations.
35
32
 
36
33
  (The MIT License)
37
34
 
38
- Copyright (c) 2006-2009 Ryan Davis, Eric Hodel, Ara T Howard.
35
+ Copyright (c) Ryan Davis, Eric Hodel, Ara T Howard.
39
36
 
40
37
  Permission is hereby granted, free of charge, to any person obtaining
41
38
  a copy of this software and associated documentation files (the
data/Rakefile CHANGED
@@ -1,29 +1,28 @@
1
1
  # -*- ruby -*-
2
2
 
3
- begin
4
- require 'hoe'
5
- rescue LoadError
6
- abort "ERROR: This Rakefile is only useful with hoe installed.
7
- If you're trying to install the rubyforge library,
8
- please install it via rubygems."
9
- end
10
-
11
- $:.unshift 'lib'
3
+ require 'rubygems'
4
+ require 'hoe'
5
+ require 'json'
12
6
 
13
7
  abort "you _must_ install this gem to release it" if
14
8
  ENV['VERSION'] && ENV['VERSION'] != RubyForge::VERSION
15
9
 
16
- Hoe.new("rubyforge", RubyForge::VERSION) do |rubyforge|
17
- rubyforge.rubyforge_name = "codeforpeople"
18
- rubyforge.need_tar = false
10
+ Hoe.plugin :email
19
11
 
20
- rubyforge.developer('Ryan Davis', 'ryand-ruby@zenspider.com')
21
- rubyforge.developer('Eric Hodel', 'drbrain@segment7.net')
22
- rubyforge.developer('Ara T Howard', 'ara.t.howard@gmail.com')
12
+ Hoe.spec "rubyforge" do
13
+ developer 'Ryan Davis', 'ryand-ruby@zenspider.com'
14
+ developer 'Eric Hodel', 'drbrain@segment7.net'
15
+ developer 'Ara T Howard', 'ara.t.howard@gmail.com'
16
+ developer 'Tom Copeland', 'tom@infoether.com'
23
17
 
24
- rubyforge.multiruby_skip << "rubinius"
18
+ multiruby_skip << "rubinius"
19
+
20
+ self.rubyforge_name = "codeforpeople"
21
+ self.need_tar = false
25
22
  end
26
23
 
24
+ task :postrelease => :announce
25
+
27
26
  task :backup do
28
27
  Dir.chdir File.expand_path("~/.rubyforge") do
29
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 } login && #{ PROGRAM } create_package codeforpeople.com traits
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 } login && #{ PROGRAM } add_release 1024 1242 0.8.0 traits-0.8.0.gem
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 requires screen scraping to see of an operation
101
- succeeded since 200 is returned from rubyforge even for failed operations
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
@@ -136,10 +125,10 @@ EOL
136
125
  mode = ARGV.shift
137
126
 
138
127
  opts = GetoptLong::new(
139
- [ "--help" , "-h" , GetoptLong::REQUIRED_ARGUMENT ],
128
+ [ "--help" , "-h" , GetoptLong::NO_ARGUMENT ],
129
+ [ "--force" , "-F" , GetoptLong::NO_ARGUMENT ],
140
130
  [ "--username" , "-u" , GetoptLong::REQUIRED_ARGUMENT ],
141
131
  [ "--password" , "-p" , GetoptLong::REQUIRED_ARGUMENT ],
142
- [ "--cookie_jar" , "-C" , GetoptLong::REQUIRED_ARGUMENT ],
143
132
  [ "--is_private" , "-P" , GetoptLong::REQUIRED_ARGUMENT ],
144
133
  [ "--release_date" , "-r" , GetoptLong::REQUIRED_ARGUMENT ],
145
134
  [ "--type_id" , "-t" , GetoptLong::REQUIRED_ARGUMENT ],
@@ -170,10 +159,6 @@ when %r/names/
170
159
  rf = rubyforge.autoconfig
171
160
  puts "groups : #{rf["group_ids"].keys.sort.join(", ")}"
172
161
  puts "packages: #{rf["package_ids"].keys.sort.join(", ")}"
173
- when %r/login/
174
- rubyforge.login
175
- when %r/logout/
176
- rubyforge.logout
177
162
  when %r/create_package/
178
163
  page, msg = "/frs/admin/index.php", "post_content"
179
164
 
@@ -184,9 +169,15 @@ when %r/create_package/
184
169
 
185
170
  group_id = Integer(group_id) rescue group_id
186
171
 
187
- rubyforge.login
188
-
189
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
190
181
  when %r/delete_package/
191
182
  group_id, package_id = ARGV
192
183
 
@@ -196,8 +187,6 @@ when %r/delete_package/
196
187
  group_id = Integer(group_id) rescue group_id
197
188
  package_id = Integer(package_id) rescue package_id
198
189
 
199
- rubyforge.login
200
-
201
190
  rubyforge.delete_package group_id, package_id
202
191
  when %r/add_release/
203
192
  group_id, package_id, release_name, userfile = ARGV
@@ -210,8 +199,6 @@ when %r/add_release/
210
199
  group_id = Integer(group_id) rescue group_id
211
200
  package_id = Integer(package_id) rescue package_id
212
201
 
213
- rubyforge.login
214
-
215
202
  rubyforge.add_release group_id, package_id, release_name, userfile
216
203
  when %r/add_file/
217
204
  group_id, package_id, release_id, userfile = ARGV
@@ -225,8 +212,6 @@ when %r/add_file/
225
212
  package_id = Integer(package_id) rescue package_id
226
213
  release_id = Integer(release_id) rescue release_id
227
214
 
228
- rubyforge.login
229
-
230
215
  rubyforge.add_file group_id, package_id, release_id, userfile
231
216
  else
232
217
  abort USAGE
@@ -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
- century = Time.now.year / 100 * 100
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
@@ -21,7 +21,7 @@ class Net::HTTP
21
21
  alias :old_use_ssl= :use_ssl=
22
22
  def use_ssl= flag
23
23
  self.old_use_ssl = flag
24
- @ssl_context.tmp_dh_callback = proc {}
24
+ @ssl_context.tmp_dh_callback = proc {} if @ssl_context
25
25
  end
26
26
  end unless Net::HTTP.public_instance_methods.include? "old_use_ssl="
27
27
 
@@ -32,45 +32,41 @@ 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
- @agent_class = Net::HTTP
37
- end
38
-
39
- def cookie_store
40
- @cookie_manager
41
- end
42
-
43
- def cookie_store=(path)
44
- @cookie_manager = CookieManager.load(path)
35
+ if proxy
36
+ begin
37
+ proxy_uri = URI.parse(proxy)
38
+ @agent_class = Net::HTTP::Proxy(proxy_uri.host,proxy_uri.port)
39
+ rescue URI::InvalidURIError
40
+ end
41
+ end
42
+ @agent_class ||= Net::HTTP
45
43
  end
46
44
 
47
- def post_content(uri, form = {}, headers = {})
45
+ def post_content(uri, form = {}, headers = {}, userconfig = nil)
48
46
  uri = URI.parse(uri) unless uri.is_a?(URI)
49
47
  request = agent_class::Post.new(uri.request_uri)
50
- execute(request, uri, form, headers)
48
+ execute(request, uri, form, headers, userconfig)
51
49
  end
52
50
 
53
- def get_content(uri, query = {}, headers = {})
51
+ def get_content(uri, query = {}, headers = {}, userconfig = nil)
54
52
  uri = URI.parse(uri) unless uri.is_a?(URI)
55
53
  request = agent_class::Get.new(uri.request_uri)
56
- execute(request, uri, query, headers)
54
+ execute(request, uri, query, headers, userconfig)
57
55
  end
58
56
 
59
- def execute(request, uri, parameters = {}, headers = {})
57
+ def execute(request, uri, parameters = {}, headers = {}, userconfig = nil)
60
58
  {
61
59
  'content-type' => 'application/x-www-form-urlencoded'
62
60
  }.merge(headers).each { |k,v| request[k] = v }
63
61
 
64
- @cookie_manager[uri].each { |k,v|
65
- request['Cookie'] = v.to_s
66
- } if @cookie_manager[uri]
67
-
68
62
  http = agent_class.new( uri.host, uri.port )
69
63
 
70
- if uri.scheme == 'https'
71
- http.use_ssl = true
72
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
64
+ if uri.scheme == 'https' && uri.host !~ /localhost/
65
+ http.use_ssl = true
66
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
73
67
  end
68
+
69
+ request.basic_auth(userconfig["username"], userconfig["password"])
74
70
 
75
71
  request_data = case request['Content-Type']
76
72
  when /boundary=(.*)$/
@@ -81,13 +77,6 @@ class RubyForge
81
77
  request['Content-Length'] = request_data.length.to_s
82
78
 
83
79
  response = http.request(request, request_data)
84
- (response.get_fields('Set-Cookie') || []).each do |raw_cookie|
85
- WEBrick::Cookie.parse_set_cookies(raw_cookie).each { |baked_cookie|
86
- baked_cookie.domain ||= url.host
87
- baked_cookie.path ||= url.path
88
- @cookie_manager.add(uri, baked_cookie)
89
- }
90
- end
91
80
 
92
81
  return response.body if response.class <= Net::HTTPSuccess
93
82
 
@@ -131,8 +120,5 @@ class RubyForge
131
120
  }.compact.join('&')
132
121
  end
133
122
 
134
- def save_cookie_store
135
- @cookie_manager.save!
136
- end
137
123
  end
138
124
  end