rubyforge 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.cvsignore +2 -0
- data/History.txt +13 -1
- data/Manifest.txt +2 -2
- data/{README → README.txt} +6 -7
- data/Rakefile +18 -81
- data/bin/rubyforge +25 -22
- data/lib/rubyforge.rb +117 -74
- data/test/test_rubyforge.rb +37 -18
- metadata +12 -10
- data/install.rb +0 -174
data/.cvsignore
ADDED
data/History.txt
CHANGED
@@ -1,19 +1,31 @@
|
|
1
|
-
|
1
|
+
* 0.4.0 / 2007-01-09:
|
2
|
+
* config.yml split and moved to user-config.yml (up to the user to do).
|
3
|
+
* auto-config.yml now generated via config command.
|
4
|
+
* @config renamed to @userconfig.
|
5
|
+
* @config["rubyforge"] moved to @autoconfig.
|
6
|
+
* Added save_autoconfig.
|
7
|
+
* Pulled scrape_project from scrape_config.
|
8
|
+
* scrape_config no longer takes a user param. Use opts to specify.
|
9
|
+
* scrape_project, add_project, add/remove_release now save automatically.
|
2
10
|
|
3
11
|
* 0.3.2 / 2006-11-29:
|
4
12
|
* Fixed file uploads for windows.
|
5
13
|
* Correctly scrape releases with funky characters.
|
14
|
+
|
6
15
|
* 0.3.1 / 2006-10-24:
|
7
16
|
* Added SSL login.
|
8
17
|
* Added yet more debugging output if $DEBUG.
|
18
|
+
|
9
19
|
* 0.3.0 / 2006-09-30:
|
10
20
|
* Added more debugging output if $DEBUG
|
11
21
|
* Added news posting.
|
12
22
|
* Added multiple file release to add_release (uses add_file for extras).
|
13
23
|
* add_release now returns release_id
|
14
24
|
* Fixed config scraper to include '-' in names.
|
25
|
+
|
15
26
|
* 0.2.1 / 2006-09-14:
|
16
27
|
* Gemspec was too loose about packaging. Now using manifest.
|
28
|
+
|
17
29
|
* 0.2.0 / 2006-09-13:
|
18
30
|
* Split original script into script and library.
|
19
31
|
* Added tests for library.
|
data/Manifest.txt
CHANGED
data/{README → README.txt}
RENAMED
@@ -6,13 +6,12 @@
|
|
6
6
|
|
7
7
|
A simplistic script which automates a limited set of rubyforge operations
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
* don't forget to login! logging in will store a cookie in your
|
9
|
+
* Run 'rubyforge help' for complete usage.
|
10
|
+
* Setup: For first time users AND upgrades to 0.4.0:
|
11
|
+
* rubyforge setup
|
12
|
+
* edit ~/.rubyforge/user-config.yml
|
13
|
+
* rubyforge config
|
14
|
+
* Don't forget to login! logging in will store a cookie in your
|
16
15
|
.rubyforge directory which expires after a time. always run the
|
17
16
|
login command before any operation that requires authentication,
|
18
17
|
such as uploading a package.
|
data/Rakefile
CHANGED
@@ -1,91 +1,28 @@
|
|
1
1
|
# -*- ruby -*-
|
2
2
|
|
3
|
-
|
4
|
-
require '
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
$: << 'lib'
|
11
|
-
require './lib/rubyforge.rb'
|
12
|
-
|
13
|
-
require 'rubygems'
|
14
|
-
|
15
|
-
gem = Gem::Specification::new do |spec|
|
16
|
-
spec.name = 'rubyforge'
|
17
|
-
spec.version = RubyForge::VERSION
|
18
|
-
spec.platform = Gem::Platform::RUBY
|
19
|
-
|
20
|
-
spec.summary = File.read("README").split(/\n\n+/)[3]
|
21
|
-
spec.description = spec.summary # TODO: improve
|
22
|
-
|
23
|
-
spec.files = File.readlines("Manifest.txt").map { |l| l.chomp }
|
24
|
-
spec.executables = spec.files.grep(/^bin/).map { |f| File::basename f }
|
25
|
-
|
26
|
-
spec.has_rdoc = true
|
27
|
-
spec.test_suite_file = "test/test_rubyforge.rb"
|
28
|
-
|
29
|
-
spec.author = "Ara T. Howard"
|
30
|
-
spec.email = "ara.t.howard@noaa.gov"
|
31
|
-
spec.homepage = "http://codeforpeople.com/lib/ruby/rubyforge/"
|
32
|
-
|
33
|
-
if $DEBUG then
|
34
|
-
puts "#{spec.name} #{spec.version}"
|
35
|
-
puts
|
36
|
-
puts "bin = #{spec.executable.sort.inspect}"
|
37
|
-
puts
|
38
|
-
puts "** summary:"
|
39
|
-
puts spec.summary
|
40
|
-
puts
|
41
|
-
puts "** description:"
|
42
|
-
puts spec.description
|
43
|
-
end
|
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."
|
44
9
|
end
|
45
10
|
|
46
|
-
|
47
|
-
|
48
|
-
pkg.need_tar = true
|
49
|
-
end
|
11
|
+
Object.send :remove_const, :RubyForge if defined? RubyForge
|
12
|
+
require './lib/rubyforge.rb'
|
50
13
|
|
51
|
-
|
52
|
-
|
14
|
+
Hoe.new("rubyforge", RubyForge::VERSION) do |p|
|
15
|
+
p.rubyforge_name = "codeforpeople"
|
16
|
+
p.url = "http://rubyforge.org/projects/codeforpeople"
|
17
|
+
p.author = ['Ara T Howard', 'Ryan Davis', 'Eric Hodel']
|
18
|
+
p.need_tar = false
|
53
19
|
|
54
|
-
|
55
|
-
|
56
|
-
t.libs << 'test'
|
57
|
-
t.warning = true
|
58
|
-
end
|
20
|
+
changes = p.paragraphs_of("History.txt", 1).first
|
21
|
+
summary, *description = p.paragraphs_of("README.txt", 3, 3..4)
|
59
22
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
rd.rdoc_files.add 'README', 'History.txt', "lib/rubyforge.rb"
|
64
|
-
rd.main = 'README'
|
65
|
-
rd.options << "-t codeforpeople's rubyforge-#{RubyForge::VERSION} Documentation"
|
66
|
-
end
|
67
|
-
|
68
|
-
desc 'Upload RDoc to RubyForge'
|
69
|
-
task :upload => :rdoc do
|
70
|
-
user = "#{ENV['USER']}@rubyforge.org"
|
71
|
-
project = '/var/www/gforge-projects/codeforpeople/rubyforge'
|
72
|
-
local_dir = 'doc'
|
73
|
-
pub = Rake::SshDirPublisher.new user, project, local_dir
|
74
|
-
pub.upload
|
75
|
-
end
|
76
|
-
|
77
|
-
task :deploy => [:clean, :package] do |t|
|
78
|
-
version = ENV["VERSION"] or abort "Must supply VERSION=x.y.z"
|
79
|
-
puts "Releasing #{version}"
|
80
|
-
rf = RubyForge.new
|
81
|
-
rf.login
|
82
|
-
rf.add_release 'codeforpeople', 'rubyforge', version, "pkg/rubyforge-#{version}.tgz", "pkg/rubyforge-#{version}.gem"
|
83
|
-
end
|
84
|
-
|
85
|
-
desc 'Clean up'
|
86
|
-
task :clean => [ :clobber_rdoc, :clobber_package ] do
|
87
|
-
rm_f Dir["**/*~"]
|
23
|
+
p.changes = changes
|
24
|
+
p.summary = summary
|
25
|
+
p.description = description.join("\n\n")
|
88
26
|
end
|
89
27
|
|
90
28
|
# vim:syntax=ruby
|
91
|
-
|
data/bin/rubyforge
CHANGED
@@ -16,7 +16,7 @@ SYNOPSIS
|
|
16
16
|
|
17
17
|
DESCRIPTION
|
18
18
|
|
19
|
-
simplistic script which automates a limited set of rubyforge operations
|
19
|
+
simplistic script which automates a limited set of rubyforge operations
|
20
20
|
|
21
21
|
MODES
|
22
22
|
|
@@ -27,12 +27,13 @@ MODES
|
|
27
27
|
example :
|
28
28
|
#{ PROGRAM } setup
|
29
29
|
|
30
|
-
config()
|
31
|
-
Helps you populate your config.yml file by scraping rubyforge and
|
30
|
+
config([project])
|
31
|
+
Helps you populate your auto-config.yml file by scraping rubyforge and
|
32
32
|
getting your groups, projects, and releases.
|
33
33
|
|
34
34
|
example :
|
35
35
|
#{ PROGRAM } config
|
36
|
+
#{ PROGRAM } config myproject
|
36
37
|
|
37
38
|
names()
|
38
39
|
Prints out the names of your configured groups and projects.
|
@@ -63,8 +64,8 @@ MODES
|
|
63
64
|
example :
|
64
65
|
#{ PROGRAM } add_release codeforpeople.com traits 0.8.0 traits-0.8.0.gem
|
65
66
|
#{ PROGRAM } add_release codeforpeople.com traits 0.8.0 traits-0.8.0.tgz
|
66
|
-
#{ PROGRAM } add_release 1024 1242 0.8.0 traits-0.8.0.gem
|
67
|
-
#{ PROGRAM } login && #{ PROGRAM } add_release 1024 1242 0.8.0 traits-0.8.0.gem
|
67
|
+
#{ 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
|
68
69
|
|
69
70
|
add_file(group_id, package_id, release_id, userfile)
|
70
71
|
add a file to an existing release under the specified group_id,
|
@@ -73,7 +74,7 @@ MODES
|
|
73
74
|
example :
|
74
75
|
#{ PROGRAM } add_file codeforpeople.com traits 0.8.0 traits-0.8.0.gem
|
75
76
|
#{ PROGRAM } add_file codeforpeople.com traits 0.8.0 traits-0.8.0.tgz
|
76
|
-
#{ PROGRAM } add_file 1024 1242 0.8.0 traits-0.8.0.gem
|
77
|
+
#{ PROGRAM } add_file 1024 1242 0.8.0 traits-0.8.0.gem
|
77
78
|
|
78
79
|
delete_package(group_id, package_name)
|
79
80
|
deletes a package and all its files.
|
@@ -135,17 +136,17 @@ EOL
|
|
135
136
|
mode = ARGV.shift
|
136
137
|
|
137
138
|
opts = GetoptLong::new(
|
138
|
-
[ "--help" , "-h" , GetoptLong::REQUIRED_ARGUMENT ] ,
|
139
|
-
[ "--config" , "-c" , GetoptLong::REQUIRED_ARGUMENT ] ,
|
140
|
-
[ "--username" , "-u" , GetoptLong::REQUIRED_ARGUMENT ] ,
|
141
|
-
[ "--password" , "-p" , GetoptLong::REQUIRED_ARGUMENT ] ,
|
142
|
-
[ "--cookie_jar" , "-C" , GetoptLong::REQUIRED_ARGUMENT ] ,
|
139
|
+
[ "--help" , "-h" , GetoptLong::REQUIRED_ARGUMENT ] ,
|
140
|
+
[ "--config" , "-c" , GetoptLong::REQUIRED_ARGUMENT ] ,
|
141
|
+
[ "--username" , "-u" , GetoptLong::REQUIRED_ARGUMENT ] ,
|
142
|
+
[ "--password" , "-p" , GetoptLong::REQUIRED_ARGUMENT ] ,
|
143
|
+
[ "--cookie_jar" , "-C" , GetoptLong::REQUIRED_ARGUMENT ] ,
|
143
144
|
[ "--is_private" , "-P" , GetoptLong::REQUIRED_ARGUMENT ],
|
144
|
-
[ "--release_date" , "-r" , GetoptLong::REQUIRED_ARGUMENT ] ,
|
145
|
-
[ "--type_id" , "-t" , GetoptLong::REQUIRED_ARGUMENT ] ,
|
146
|
-
[ "--processor_id" , "-o" , GetoptLong::REQUIRED_ARGUMENT ] ,
|
147
|
-
[ "--release_notes" , "-n" , GetoptLong::REQUIRED_ARGUMENT ] ,
|
148
|
-
[ "--release_changes" , "-a" , GetoptLong::REQUIRED_ARGUMENT ] ,
|
145
|
+
[ "--release_date" , "-r" , GetoptLong::REQUIRED_ARGUMENT ] ,
|
146
|
+
[ "--type_id" , "-t" , GetoptLong::REQUIRED_ARGUMENT ] ,
|
147
|
+
[ "--processor_id" , "-o" , GetoptLong::REQUIRED_ARGUMENT ] ,
|
148
|
+
[ "--release_notes" , "-n" , GetoptLong::REQUIRED_ARGUMENT ] ,
|
149
|
+
[ "--release_changes" , "-a" , GetoptLong::REQUIRED_ARGUMENT ] ,
|
149
150
|
[ "--preformatted" , "-f" , GetoptLong::NO_ARGUMENT ]
|
150
151
|
).enum_for.inject({}){|h,kv| h.update kv.first.delete('-') => kv.last}
|
151
152
|
|
@@ -159,18 +160,20 @@ when %r/help/
|
|
159
160
|
when %r/setup/
|
160
161
|
rubyforge.setup
|
161
162
|
when %r/config/
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
163
|
+
project = ARGV.shift
|
164
|
+
if project then
|
165
|
+
rubyforge.scrape_project(project)
|
166
|
+
else
|
167
|
+
rubyforge.scrape_config
|
168
|
+
end
|
166
169
|
when %r/names/
|
167
|
-
rf = rubyforge.
|
170
|
+
rf = rubyforge.autoconfig
|
168
171
|
puts "groups : #{rf["group_ids"].keys.sort.join(", ")}"
|
169
172
|
puts "packages: #{rf["package_ids"].keys.sort.join(", ")}"
|
170
173
|
when %r/login/
|
171
174
|
rubyforge.login
|
172
175
|
when %r/create_package/
|
173
|
-
page, msg = "/frs/admin/index.php", "post_content"
|
176
|
+
page, msg = "/frs/admin/index.php", "post_content"
|
174
177
|
|
175
178
|
group_id, package_name = ARGV
|
176
179
|
|
data/lib/rubyforge.rb
CHANGED
@@ -4,6 +4,7 @@ require 'enumerator'
|
|
4
4
|
require 'fileutils'
|
5
5
|
require 'http-access2'
|
6
6
|
require 'yaml'
|
7
|
+
require 'open-uri'
|
7
8
|
|
8
9
|
$TESTING = false unless defined? $TESTING
|
9
10
|
|
@@ -25,10 +26,10 @@ end
|
|
25
26
|
class RubyForge
|
26
27
|
|
27
28
|
# :stopdoc:
|
28
|
-
VERSION = "0.
|
29
|
+
VERSION = "0.4.0"
|
29
30
|
HOME = ENV["HOME"] || ENV["HOMEPATH"] || File::expand_path("~")
|
30
31
|
RUBYFORGE_D = File::join HOME, ".rubyforge"
|
31
|
-
CONFIG_F = File::join RUBYFORGE_D, "config.yml"
|
32
|
+
CONFIG_F = File::join RUBYFORGE_D, "user-config.yml"
|
32
33
|
COOKIE_F = File::join RUBYFORGE_D, "cookie.dat"
|
33
34
|
|
34
35
|
# We must use __FILE__ instead of DATA because this is now a library
|
@@ -38,85 +39,116 @@ class RubyForge
|
|
38
39
|
attr_reader :client if $TESTING
|
39
40
|
# :startdoc:
|
40
41
|
|
41
|
-
attr_reader :
|
42
|
+
attr_reader :userconfig, :autoconfig
|
42
43
|
|
43
|
-
def initialize(
|
44
|
-
@
|
45
|
-
@
|
44
|
+
def initialize(userconfig=CONFIG_F, opts={})
|
45
|
+
@userconfig = test(?e, userconfig) ? IO::read(userconfig) : CONFIG
|
46
|
+
@userconfig = YAML.load(@userconfig).merge(opts)
|
47
|
+
dir, file = File.split(userconfig)
|
48
|
+
@autoconfig_path = File.join(dir, file.sub(/^user/, 'auto'))
|
49
|
+
@autoconfig = test(?e, @autoconfig_path) ? YAML.load_file(@autoconfig_path) : YAML.load(CONFIG)["rubyforge"]
|
46
50
|
|
47
|
-
@uri = URI.parse @
|
51
|
+
@uri = URI.parse @userconfig['uri']
|
48
52
|
|
49
|
-
raise "no <username>" unless @
|
50
|
-
raise "no <password>" unless @
|
51
|
-
raise "no <cookie_jar>" unless @
|
53
|
+
raise "no <username>" unless @userconfig["username"]
|
54
|
+
raise "no <password>" unless @userconfig["password"]
|
55
|
+
raise "no <cookie_jar>" unless @userconfig["cookie_jar"]
|
52
56
|
end
|
53
57
|
|
54
58
|
def setup
|
55
59
|
FileUtils::mkdir_p RUBYFORGE_D unless test ?d, RUBYFORGE_D
|
56
|
-
test ?e, CONFIG_F and FileUtils::mv CONFIG_F, "#{ CONFIG_F }.bak"
|
57
|
-
|
60
|
+
test ?e, CONFIG_F and FileUtils::mv CONFIG_F, "#{ CONFIG_F }.bak"
|
61
|
+
config = CONFIG[/\A.*(?=^\# AUTOCONFIG)/m]
|
62
|
+
open(CONFIG_F, "w") { |f| f.write config }
|
58
63
|
FileUtils::touch COOKIE_F
|
59
64
|
edit = (ENV["EDITOR"] || ENV["EDIT"] || "vi") + " #{ CONFIG_F }"
|
60
65
|
system edit or puts "edit #{ CONFIG_F }"
|
61
66
|
end
|
62
67
|
|
63
|
-
def
|
64
|
-
|
65
|
-
|
66
|
-
|
68
|
+
def save_autoconfig
|
69
|
+
File.open(@autoconfig_path, "w") do |file|
|
70
|
+
YAML.dump @autoconfig, file
|
71
|
+
end
|
72
|
+
end
|
67
73
|
|
68
|
-
|
69
|
-
|
74
|
+
def scrape_config
|
75
|
+
username = @userconfig['username']
|
70
76
|
|
71
|
-
|
72
|
-
"
|
73
|
-
|
74
|
-
"form_pw" => password,
|
75
|
-
"login" => "Login"
|
76
|
-
}
|
77
|
+
%w(group package release).each do |type|
|
78
|
+
@autoconfig["#{type}_ids"].clear
|
79
|
+
end
|
77
80
|
|
78
|
-
|
81
|
+
puts "Getting #{username}"
|
82
|
+
html = URI.parse("http://rubyforge.org/users/#{username}/index.html").read
|
83
|
+
projects = html.scan(%r%/projects/([^/]+)/%).flatten
|
84
|
+
puts "Fetching #{projects.size} projects"
|
85
|
+
projects.each do |project|
|
86
|
+
next if project == "support"
|
87
|
+
scrape_project(project)
|
88
|
+
end
|
79
89
|
end
|
80
90
|
|
81
|
-
def
|
82
|
-
require 'open-uri'
|
83
|
-
|
91
|
+
def scrape_project(project)
|
84
92
|
data = {
|
85
93
|
"group_ids" => {},
|
86
94
|
"package_ids" => {},
|
87
95
|
"release_ids" => Hash.new { |h,k| h[k] = {} },
|
88
96
|
}
|
89
97
|
|
90
|
-
|
91
|
-
html.scan(%r%/projects/([^/]+)/%).flatten.each do |project|
|
92
|
-
next if project == "support"
|
93
|
-
html = URI.parse("http://rubyforge.org/projects/#{project}/index.html").read
|
98
|
+
puts "Updating #{project}"
|
94
99
|
|
100
|
+
unless data["group_ids"].has_key? project then
|
101
|
+
html = URI.parse("http://rubyforge.org/projects/#{project}/index.html").read
|
95
102
|
group_id = html[/(frs|tracker)\/\?group_id=\d+/][/\d+/].to_i
|
96
103
|
data["group_ids"][project] = group_id
|
104
|
+
end
|
105
|
+
|
106
|
+
group_id = data["group_ids"][project]
|
97
107
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
end
|
108
|
+
html = URI.parse("http://rubyforge.org/frs/?group_id=#{group_id}").read
|
109
|
+
|
110
|
+
package = nil
|
111
|
+
html.scan(/<h3>[^<]+|release_id=\d+">[^>]+|filemodule_id=\d+/).each do |s|
|
112
|
+
case s
|
113
|
+
when /<h3>([^<]+)/ then
|
114
|
+
package = $1.strip
|
115
|
+
when /release_id=(\d+)">([^<]+)/ then
|
116
|
+
data["release_ids"][package][$2] = $1.to_i
|
117
|
+
when /filemodule_id=(\d+)/ then
|
118
|
+
data["package_ids"][package] = $1.to_i
|
110
119
|
end
|
111
120
|
end
|
112
|
-
|
121
|
+
|
122
|
+
data.each do |key, val|
|
123
|
+
@autoconfig[key].merge! val
|
124
|
+
end
|
125
|
+
|
126
|
+
save_autoconfig
|
127
|
+
end
|
128
|
+
|
129
|
+
def login
|
130
|
+
page = @uri + "/account/login.php"
|
131
|
+
page.scheme = 'https'
|
132
|
+
page = URI.parse page.to_s # set SSL port correctly
|
133
|
+
|
134
|
+
username = @userconfig["username"]
|
135
|
+
password = @userconfig["password"]
|
136
|
+
|
137
|
+
form = {
|
138
|
+
"return_to" => "",
|
139
|
+
"form_loginname" => username,
|
140
|
+
"form_pw" => password,
|
141
|
+
"login" => "Login"
|
142
|
+
}
|
143
|
+
|
144
|
+
run page, form
|
113
145
|
end
|
114
146
|
|
115
147
|
def create_package(group_id, package_name)
|
116
148
|
page = "/frs/admin/index.php"
|
117
149
|
|
118
150
|
group_id = lookup "group", group_id
|
119
|
-
is_private = @
|
151
|
+
is_private = @userconfig["is_private"]
|
120
152
|
is_public = is_private ? 0 : 1
|
121
153
|
|
122
154
|
form = {
|
@@ -128,6 +160,9 @@ class RubyForge
|
|
128
160
|
}
|
129
161
|
|
130
162
|
run page, form
|
163
|
+
|
164
|
+
group_name = @autoconfig["group_ids"].invert[group_id]
|
165
|
+
scrape_project(group_name)
|
131
166
|
end
|
132
167
|
|
133
168
|
##
|
@@ -163,6 +198,11 @@ class RubyForge
|
|
163
198
|
"submit" => "Delete",
|
164
199
|
}
|
165
200
|
|
201
|
+
package_name = @autoconfig["package_ids"].invert[package_id]
|
202
|
+
@autoconfig["package_ids"].delete package_name
|
203
|
+
@autoconfig["release_ids"].delete package_name
|
204
|
+
save_autoconfig
|
205
|
+
|
166
206
|
run page, form
|
167
207
|
end
|
168
208
|
|
@@ -170,15 +210,15 @@ class RubyForge
|
|
170
210
|
userfile = files.shift
|
171
211
|
page = "/frs/admin/qrs.php"
|
172
212
|
|
173
|
-
group_id
|
174
|
-
package_id
|
175
|
-
userfile
|
176
|
-
release_date
|
177
|
-
type_id
|
178
|
-
processor_id
|
179
|
-
release_notes
|
180
|
-
release_changes = @
|
181
|
-
preformatted
|
213
|
+
group_id = lookup "group", group_id
|
214
|
+
package_id = lookup "package", package_id
|
215
|
+
userfile = open userfile, 'rb'
|
216
|
+
release_date = @userconfig["release_date"]
|
217
|
+
type_id = @userconfig["type_id"]
|
218
|
+
processor_id = @userconfig["processor_id"]
|
219
|
+
release_notes = @userconfig["release_notes"]
|
220
|
+
release_changes = @userconfig["release_changes"]
|
221
|
+
preformatted = @userconfig["preformatted"]
|
182
222
|
|
183
223
|
release_date ||= Time::now.strftime("%Y-%m-%d %H:%M")
|
184
224
|
|
@@ -219,6 +259,11 @@ class RubyForge
|
|
219
259
|
add_file(group_id, package_id, release_id, file)
|
220
260
|
end
|
221
261
|
|
262
|
+
package_name = @autoconfig["package_ids"].invert[package_id]
|
263
|
+
raise "unknown package name for #{package_id}" if package_name.nil?
|
264
|
+
@autoconfig["release_ids"][package_name][release_name] = release_id
|
265
|
+
save_autoconfig
|
266
|
+
|
222
267
|
release_id
|
223
268
|
end
|
224
269
|
|
@@ -232,12 +277,12 @@ class RubyForge
|
|
232
277
|
# add_file(1024, 1242, "0.8.0", "traits-0.8.0.gem")
|
233
278
|
|
234
279
|
def add_file(group_name, package_name, release_name, userfile)
|
235
|
-
page
|
236
|
-
type_id
|
237
|
-
group_id
|
238
|
-
package_id
|
239
|
-
release_id
|
240
|
-
processor_id = @
|
280
|
+
page = '/frs/admin/editrelease.php'
|
281
|
+
type_id = @userconfig["type_id"]
|
282
|
+
group_id = lookup "group", group_name
|
283
|
+
package_id = lookup "package", package_name
|
284
|
+
release_id = (Integer === release_name) ? release_name : lookup("release", package_name)[release_name]
|
285
|
+
processor_id = @userconfig["processor_id"]
|
241
286
|
|
242
287
|
page = "/frs/admin/editrelease.php?group_id=#{group_id}&release_id=#{release_id}&package_id=#{package_id}"
|
243
288
|
|
@@ -255,7 +300,7 @@ class RubyForge
|
|
255
300
|
"processor_id" => processor_id,
|
256
301
|
"userfile" => userfile,
|
257
302
|
"submit" => "Add This File"
|
258
|
-
|
303
|
+
}
|
259
304
|
|
260
305
|
boundary = Array::new(8){ "%2.2d" % rand(42) }.join('__')
|
261
306
|
boundary = "multipart/form-data; boundary=___#{ boundary }___"
|
@@ -266,11 +311,11 @@ class RubyForge
|
|
266
311
|
def run(page, form, extheader={}) # :nodoc:
|
267
312
|
client = HTTPAccess2::Client::new ENV["HTTP_PROXY"]
|
268
313
|
client.debug_dev = STDERR if ENV["RUBYFORGE_DEBUG"] || ENV["DEBUG"] || $DEBUG
|
269
|
-
client.set_cookie_store @
|
314
|
+
client.set_cookie_store @userconfig["cookie_jar"]
|
270
315
|
client.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
271
316
|
|
272
317
|
# HACK to fix http-access2 redirect bug/feature
|
273
|
-
client.redirect_uri_callback = lambda do |res|
|
318
|
+
client.redirect_uri_callback = lambda do |res|
|
274
319
|
page = res.header['location'].first
|
275
320
|
page =~ %r/http/ ? page : @uri + page
|
276
321
|
end
|
@@ -280,7 +325,7 @@ class RubyForge
|
|
280
325
|
puts "client.post_content #{uri.inspect}, #{form.inspect}, #{extheader.inspect}"
|
281
326
|
end
|
282
327
|
|
283
|
-
response = client.post_content uri, form, extheader
|
328
|
+
response = client.post_content uri, form, extheader
|
284
329
|
|
285
330
|
@client = client if $TESTING
|
286
331
|
|
@@ -299,8 +344,8 @@ class RubyForge
|
|
299
344
|
def lookup(type, val) # :nodoc:
|
300
345
|
unless Fixnum === val then
|
301
346
|
key = val.to_s
|
302
|
-
val = @
|
303
|
-
raise "no <#{type}_id> configured for <#{ key }>" unless val
|
347
|
+
val = @autoconfig["#{type}_ids"][key]
|
348
|
+
raise "no <#{type}_id> configured for <#{ key }>" unless val
|
304
349
|
end
|
305
350
|
val
|
306
351
|
end
|
@@ -314,19 +359,17 @@ __END__
|
|
314
359
|
#
|
315
360
|
# this must be your username
|
316
361
|
#
|
317
|
-
username : username
|
362
|
+
username : username
|
318
363
|
#
|
319
364
|
# this must be your password
|
320
365
|
#
|
321
|
-
password : password
|
366
|
+
password : password
|
322
367
|
#
|
323
|
-
# defaults for some values
|
368
|
+
# defaults for some values
|
324
369
|
#
|
325
|
-
cookie_jar : #{ COOKIE_F }
|
370
|
+
cookie_jar : #{ COOKIE_F }
|
326
371
|
is_private : false
|
327
|
-
#
|
328
|
-
# server side rubyforge configuration
|
329
|
-
#
|
372
|
+
# AUTOCONFIG:
|
330
373
|
rubyforge :
|
331
374
|
#
|
332
375
|
# map your group names to their rubyforge ids
|
data/test/test_rubyforge.rb
CHANGED
@@ -6,13 +6,18 @@ require 'rubyforge'
|
|
6
6
|
class FakeRubyForge < RubyForge
|
7
7
|
HTML = "blah blah <form action=\"/frs/admin/editrelease.php?group_id=440&release_id=6948&package_id=491\" method=\"post\"> blah blah"
|
8
8
|
|
9
|
-
attr_accessor :page, :form, :extheader, :requests
|
9
|
+
attr_accessor :page, :form, :extheader, :requests, :scrape
|
10
10
|
def run(page, form, extheader={})
|
11
11
|
@page, @form, @extheader = page, form, extheader
|
12
12
|
@requests ||= []
|
13
13
|
@requests << { :url => page, :form => form, :headers => extheader }
|
14
14
|
HTML
|
15
15
|
end
|
16
|
+
|
17
|
+
def scrape_project(proj)
|
18
|
+
@scrape ||= []
|
19
|
+
@scrape << proj
|
20
|
+
end
|
16
21
|
end
|
17
22
|
|
18
23
|
class HTTPAccess2::Client
|
@@ -31,6 +36,11 @@ class TestRubyForge < Test::Unit::TestCase
|
|
31
36
|
util_new FakeRubyForge
|
32
37
|
end
|
33
38
|
|
39
|
+
def teardown
|
40
|
+
@rubyforge.autoconfig.replace @old_autoconfig
|
41
|
+
@rubyforge.save_autoconfig
|
42
|
+
end
|
43
|
+
|
34
44
|
def test_initialize_bad
|
35
45
|
assert_raise RuntimeError do
|
36
46
|
RubyForge.new(RubyForge::CONFIG_F, "username" => nil)
|
@@ -49,8 +59,8 @@ class TestRubyForge < Test::Unit::TestCase
|
|
49
59
|
|
50
60
|
def test_login
|
51
61
|
u, p = 'fooby', 's3kr3t'
|
52
|
-
@rubyforge.
|
53
|
-
@rubyforge.
|
62
|
+
@rubyforge.userconfig['username'] = u
|
63
|
+
@rubyforge.userconfig['password'] = p
|
54
64
|
@rubyforge.login
|
55
65
|
|
56
66
|
util_run('https://rubyforge.org/account/login.php',
|
@@ -77,7 +87,6 @@ class TestRubyForge < Test::Unit::TestCase
|
|
77
87
|
end
|
78
88
|
|
79
89
|
def test_delete_package_package_name
|
80
|
-
@rubyforge.config["rubyforge"]["package_ids"]["woot_pkg"] = 666
|
81
90
|
@rubyforge.delete_package(42, "woot_pkg")
|
82
91
|
util_delete_package
|
83
92
|
end
|
@@ -89,7 +98,6 @@ class TestRubyForge < Test::Unit::TestCase
|
|
89
98
|
end
|
90
99
|
|
91
100
|
def test_delete_package_group_name
|
92
|
-
@rubyforge.config["rubyforge"]["group_ids"]["seattlerb"] = 42
|
93
101
|
@rubyforge.delete_package("seattlerb", 666)
|
94
102
|
util_delete_package
|
95
103
|
end
|
@@ -101,14 +109,13 @@ class TestRubyForge < Test::Unit::TestCase
|
|
101
109
|
end
|
102
110
|
|
103
111
|
def test_add_file
|
104
|
-
@rubyforge.
|
105
|
-
@rubyforge.
|
106
|
-
@rubyforge.
|
107
|
-
@rubyforge.config["rubyforge"]["release_ids"]["ringy_dingy"]["1.2.3"] = 43
|
112
|
+
@rubyforge.autoconfig["package_ids"]["ringy_dingy"] = 314
|
113
|
+
@rubyforge.autoconfig["release_ids"]["ringy_dingy"] ||= {}
|
114
|
+
@rubyforge.autoconfig["release_ids"]["ringy_dingy"]["1.2.3"] = 43
|
108
115
|
|
109
116
|
@rubyforge.add_file('seattlerb', 'ringy_dingy', '1.2.3', __FILE__)
|
110
117
|
|
111
|
-
util_run('/frs/admin/editrelease.php?group_id=
|
118
|
+
util_run('/frs/admin/editrelease.php?group_id=42&release_id=43&package_id=314',
|
112
119
|
{ "step2" => 1,
|
113
120
|
"type_id" => 9999,
|
114
121
|
"processor_id" => 8000,
|
@@ -142,7 +149,7 @@ class TestRubyForge < Test::Unit::TestCase
|
|
142
149
|
"submit" => "Add This File"},
|
143
150
|
:headers => {"content-type"=> "multipart/form-data; boundary=___23__06__24__24__12__01__38__39___"}})
|
144
151
|
expected = [add_release, add_file]
|
145
|
-
|
152
|
+
|
146
153
|
result = @rubyforge.requests
|
147
154
|
result.each do |r|
|
148
155
|
r[:form].delete "userfile"
|
@@ -155,7 +162,7 @@ class TestRubyForge < Test::Unit::TestCase
|
|
155
162
|
@rubyforge.post_news("seattlerb", "my summary", "my news")
|
156
163
|
|
157
164
|
util_run("/news/submit.php",
|
158
|
-
"group_id" =>
|
165
|
+
"group_id" => 42,
|
159
166
|
"post_changes" => "y",
|
160
167
|
"details" => "my news",
|
161
168
|
"summary" => "my summary",
|
@@ -163,7 +170,6 @@ class TestRubyForge < Test::Unit::TestCase
|
|
163
170
|
end
|
164
171
|
|
165
172
|
def test_add_release_package_name
|
166
|
-
@rubyforge.config["rubyforge"]["package_ids"]["woot_pkg"] = 666
|
167
173
|
@rubyforge.add_release(42, "woot_pkg", '1.2.3', __FILE__)
|
168
174
|
util_add_release
|
169
175
|
end
|
@@ -175,7 +181,6 @@ class TestRubyForge < Test::Unit::TestCase
|
|
175
181
|
end
|
176
182
|
|
177
183
|
def test_add_release_group_name
|
178
|
-
@rubyforge.config["rubyforge"]["group_ids"]["seattlerb"] = 42
|
179
184
|
@rubyforge.add_release("seattlerb", 666, '1.2.3', __FILE__)
|
180
185
|
util_add_release
|
181
186
|
end
|
@@ -197,8 +202,8 @@ class TestRubyForge < Test::Unit::TestCase
|
|
197
202
|
end
|
198
203
|
|
199
204
|
def test_lookup_name
|
200
|
-
@rubyforge.
|
201
|
-
assert_equal
|
205
|
+
@rubyforge.autoconfig["package_ids"]["ringy_dingy"] = 314
|
206
|
+
assert_equal 314, @rubyforge.lookup("package", "ringy_dingy")
|
202
207
|
end
|
203
208
|
|
204
209
|
def test_lookup_undefined
|
@@ -237,8 +242,22 @@ class TestRubyForge < Test::Unit::TestCase
|
|
237
242
|
|
238
243
|
def util_new(klass)
|
239
244
|
@rubyforge = klass.new
|
240
|
-
@
|
241
|
-
|
245
|
+
@old_autoconfig = @rubyforge.autoconfig.dup
|
246
|
+
|
247
|
+
data = { # REFACTOR
|
248
|
+
"group_ids" => {},
|
249
|
+
"package_ids" => {},
|
250
|
+
"release_ids" => Hash.new { |h,k| h[k] = {} },
|
251
|
+
"type_ids" => {},
|
252
|
+
"processor_ids" => {"Any"=>8000},
|
253
|
+
}
|
254
|
+
|
255
|
+
@rubyforge.autoconfig.replace data
|
256
|
+
|
257
|
+
@rubyforge.userconfig["release_date"] = "today"
|
258
|
+
@rubyforge.autoconfig["type_ids"][".rb"] = 9999
|
259
|
+
@rubyforge.autoconfig["group_ids"]["seattlerb"] = 42
|
260
|
+
@rubyforge.autoconfig["package_ids"]["woot_pkg"] = 666
|
242
261
|
end
|
243
262
|
|
244
263
|
def util_run(page, form={}, extheader={})
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.0.
|
2
|
+
rubygems_version: 0.9.0.9
|
3
3
|
specification_version: 1
|
4
4
|
name: rubyforge
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date:
|
6
|
+
version: 0.4.0
|
7
|
+
date: 2007-01-10 00:00:00 -05:00
|
8
8
|
summary: A simplistic script which automates a limited set of rubyforge operations
|
9
9
|
require_paths:
|
10
10
|
- lib
|
11
|
-
email:
|
12
|
-
homepage: http://
|
13
|
-
rubyforge_project:
|
14
|
-
description: A simplistic script which automates a limited set of rubyforge operations
|
11
|
+
email: ryand-ruby@zenspider.com
|
12
|
+
homepage: http://rubyforge.org/projects/codeforpeople
|
13
|
+
rubyforge_project: codeforpeople
|
14
|
+
description: "A simplistic script which automates a limited set of rubyforge operations * Run 'rubyforge help' for complete usage. * Setup: For first time users AND upgrades to 0.4.0: * rubyforge setup * edit ~/.rubyforge/user-config.yml * rubyforge config * Don't forget to login! logging in will store a cookie in your .rubyforge directory which expires after a time. always run the login command before any operation that requires authentication, such as uploading a package."
|
15
15
|
autorequire:
|
16
16
|
default_executable:
|
17
17
|
bindir: bin
|
@@ -27,14 +27,16 @@ signing_key:
|
|
27
27
|
cert_chain:
|
28
28
|
post_install_message:
|
29
29
|
authors:
|
30
|
-
- Ara T
|
30
|
+
- Ara T Howard
|
31
|
+
- Ryan Davis
|
32
|
+
- Eric Hodel
|
31
33
|
files:
|
34
|
+
- .cvsignore
|
32
35
|
- History.txt
|
33
36
|
- Manifest.txt
|
34
|
-
- README
|
37
|
+
- README.txt
|
35
38
|
- Rakefile
|
36
39
|
- bin/rubyforge
|
37
|
-
- install.rb
|
38
40
|
- lib/http-access2.rb
|
39
41
|
- lib/http-access2/cookie.rb
|
40
42
|
- lib/http-access2/http.rb
|
data/install.rb
DELETED
@@ -1,174 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require 'rbconfig'
|
3
|
-
require 'find'
|
4
|
-
require 'ftools'
|
5
|
-
require 'tempfile'
|
6
|
-
include Config
|
7
|
-
|
8
|
-
LIBDIR = "lib"
|
9
|
-
LIBDIR_MODE = 0644
|
10
|
-
|
11
|
-
BINDIR = "bin"
|
12
|
-
BINDIR_MODE = 0755
|
13
|
-
|
14
|
-
|
15
|
-
$srcdir = CONFIG["srcdir"]
|
16
|
-
$version = CONFIG["MAJOR"]+"."+CONFIG["MINOR"]
|
17
|
-
$libdir = File.join(CONFIG["libdir"], "ruby", $version)
|
18
|
-
$archdir = File.join($libdir, CONFIG["arch"])
|
19
|
-
$site_libdir = $:.find {|x| x =~ /site_ruby$/}
|
20
|
-
$bindir = CONFIG["bindir"] || CONFIG['BINDIR']
|
21
|
-
$ruby_install_name = CONFIG['ruby_install_name'] || CONFIG['RUBY_INSTALL_NAME'] || 'ruby'
|
22
|
-
$ruby_ext = CONFIG['EXEEXT'] || ''
|
23
|
-
$ruby = File.join($bindir, ($ruby_install_name + $ruby_ext))
|
24
|
-
|
25
|
-
if !$site_libdir
|
26
|
-
$site_libdir = File.join($libdir, "site_ruby")
|
27
|
-
elsif $site_libdir !~ %r/#{Regexp.quote($version)}/
|
28
|
-
$site_libdir = File.join($site_libdir, $version)
|
29
|
-
end
|
30
|
-
|
31
|
-
def install_rb(srcdir=nil, destdir=nil, mode=nil, bin=nil)
|
32
|
-
#{{{
|
33
|
-
path = []
|
34
|
-
dir = []
|
35
|
-
Find.find(srcdir) do |f|
|
36
|
-
next unless FileTest.file?(f)
|
37
|
-
next if (f = f[srcdir.length+1..-1]) == nil
|
38
|
-
next if (/CVS$/ =~ File.dirname(f))
|
39
|
-
path.push f
|
40
|
-
dir |= [File.dirname(f)]
|
41
|
-
end
|
42
|
-
for f in dir
|
43
|
-
next if f == "."
|
44
|
-
next if f == "CVS"
|
45
|
-
File::makedirs(File.join(destdir, f))
|
46
|
-
end
|
47
|
-
for f in path
|
48
|
-
next if (/\~$/ =~ f)
|
49
|
-
next if (/^\./ =~ File.basename(f))
|
50
|
-
unless bin
|
51
|
-
File::install(File.join(srcdir, f), File.join(destdir, f), mode, true)
|
52
|
-
else
|
53
|
-
from = File.join(srcdir, f)
|
54
|
-
to = File.join(destdir, f)
|
55
|
-
shebangify(from) do |sf|
|
56
|
-
$deferr.print from, " -> ", File::catname(from, to), "\n"
|
57
|
-
$deferr.printf "chmod %04o %s\n", mode, to
|
58
|
-
File::install(sf, to, mode, false)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
#}}}
|
63
|
-
end
|
64
|
-
def shebangify f
|
65
|
-
#{{{
|
66
|
-
open(f) do |fd|
|
67
|
-
buf = fd.read 42
|
68
|
-
if buf =~ %r/^\s*#\s*!.*ruby/o
|
69
|
-
ftmp = Tempfile::new("#{ $$ }_#{ File::basename(f) }")
|
70
|
-
begin
|
71
|
-
fd.rewind
|
72
|
-
ftmp.puts "#!#{ $ruby }"
|
73
|
-
while((buf = fd.read(8192)))
|
74
|
-
ftmp.write buf
|
75
|
-
end
|
76
|
-
ftmp.close
|
77
|
-
yield ftmp.path
|
78
|
-
ensure
|
79
|
-
ftmp.close!
|
80
|
-
end
|
81
|
-
else
|
82
|
-
yield f
|
83
|
-
end
|
84
|
-
end
|
85
|
-
#}}}
|
86
|
-
end
|
87
|
-
def ARGV.switch
|
88
|
-
#{{{
|
89
|
-
return nil if self.empty?
|
90
|
-
arg = self.shift
|
91
|
-
return nil if arg == '--'
|
92
|
-
if arg =~ /^-(.)(.*)/
|
93
|
-
return arg if $1 == '-'
|
94
|
-
raise 'unknown switch "-"' if $2.index('-')
|
95
|
-
self.unshift "-#{$2}" if $2.size > 0
|
96
|
-
"-#{$1}"
|
97
|
-
else
|
98
|
-
self.unshift arg
|
99
|
-
nil
|
100
|
-
end
|
101
|
-
#}}}
|
102
|
-
end
|
103
|
-
def ARGV.req_arg
|
104
|
-
#{{{
|
105
|
-
self.shift || raise('missing argument')
|
106
|
-
#}}}
|
107
|
-
end
|
108
|
-
def linkify d
|
109
|
-
#--{{{
|
110
|
-
if test ?d, d
|
111
|
-
versioned = Dir[ File::join(d, "*-[0-9].[0-9].[0-9].rb") ]
|
112
|
-
versioned.each{|v| File::copy v, v.gsub(%r/\-[\d\.]+\.rb$/,'.rb')}
|
113
|
-
end
|
114
|
-
#--}}}
|
115
|
-
end
|
116
|
-
|
117
|
-
|
118
|
-
#
|
119
|
-
# main program
|
120
|
-
#
|
121
|
-
|
122
|
-
libdir = $site_libdir
|
123
|
-
bindir = $bindir
|
124
|
-
no_linkify = false
|
125
|
-
help = false
|
126
|
-
|
127
|
-
usage = <<-usage
|
128
|
-
#{ File::basename $0 }
|
129
|
-
-d, --destdir <destdir>
|
130
|
-
-l, --libdir <libdir>
|
131
|
-
-b, --bindir <bindir>
|
132
|
-
-r, --ruby <ruby>
|
133
|
-
-n, --no_linkify
|
134
|
-
-h, --help
|
135
|
-
usage
|
136
|
-
|
137
|
-
begin
|
138
|
-
while switch = ARGV.switch
|
139
|
-
case switch
|
140
|
-
when '-d', '--destdir'
|
141
|
-
libdir = ARGV.req_arg
|
142
|
-
when '-l', '--libdir'
|
143
|
-
libdir = ARGV.req_arg
|
144
|
-
when '-b', '--bindir'
|
145
|
-
bindir = ARGV.req_arg
|
146
|
-
when '-r', '--ruby'
|
147
|
-
$ruby = ARGV.req_arg
|
148
|
-
when '-n', '--no_linkify'
|
149
|
-
no_linkify = true
|
150
|
-
when '-h', '--help'
|
151
|
-
help = true
|
152
|
-
else
|
153
|
-
raise "unknown switch #{switch.dump}"
|
154
|
-
end
|
155
|
-
end
|
156
|
-
rescue
|
157
|
-
STDERR.puts $!.to_s
|
158
|
-
STDERR.puts usage
|
159
|
-
exit 1
|
160
|
-
end
|
161
|
-
|
162
|
-
if help
|
163
|
-
STDOUT.puts usage
|
164
|
-
exit
|
165
|
-
end
|
166
|
-
|
167
|
-
unless no_linkify
|
168
|
-
linkify('lib')
|
169
|
-
linkify('bin')
|
170
|
-
end
|
171
|
-
|
172
|
-
install_rb(LIBDIR, libdir, LIBDIR_MODE)
|
173
|
-
install_rb(BINDIR, bindir, BINDIR_MODE, bin=true)
|
174
|
-
|