rubyforge 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt ADDED
@@ -0,0 +1,20 @@
1
+ == Version History
2
+
3
+ * 0.3.1 / 2006-10-24:
4
+ * Added SSL login.
5
+ * Added yet more debugging output if $DEBUG.
6
+ * 0.3.0 / 2006-09-30:
7
+ * Added more debugging output if $DEBUG
8
+ * Added news posting.
9
+ * Added multiple file release to add_release (uses add_file for extras).
10
+ * add_release now returns release_id
11
+ * Fixed config scraper to include '-' in names.
12
+ * 0.2.1 / 2006-09-14:
13
+ * Gemspec was too loose about packaging. Now using manifest.
14
+ * 0.2.0 / 2006-09-13:
15
+ * Split original script into script and library.
16
+ * Added tests for library.
17
+ * Refactored heavily.
18
+ * Added "config" command to scrape group/project/release ids from rubyforge.
19
+ * Added "names" command to help pick groups and projects.
20
+ * Added "add_file" command to add a file to an existing release.
data/Manifest.txt ADDED
@@ -0,0 +1,11 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README
4
+ Rakefile
5
+ bin/rubyforge
6
+ install.rb
7
+ lib/http-access2.rb
8
+ lib/http-access2/cookie.rb
9
+ lib/http-access2/http.rb
10
+ lib/rubyforge.rb
11
+ test/test_rubyforge.rb
data/README ADDED
@@ -0,0 +1,18 @@
1
+ == Synopsis
2
+
3
+ rubyforge [options]* mode [mode_args]*
4
+
5
+ == Description
6
+
7
+ A simplistic script which automates a limited set of rubyforge operations
8
+
9
+ == Modes
10
+
11
+ run 'rubyforge help' for complete usage
12
+
13
+ == Notes
14
+
15
+ * don't forget to login! logging in will store a cookie in your
16
+ .rubyforge directory which expires after a time. always run the
17
+ login command before any operation that requires authentication,
18
+ such as uploading a package.
data/Rakefile ADDED
@@ -0,0 +1,91 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rake'
4
+ require 'rake/testtask'
5
+ require 'rake/rdoctask'
6
+ require 'rake/gempackagetask'
7
+ require 'rake/contrib/sshpublisher'
8
+ require 'rbconfig'
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
44
+ end
45
+
46
+ desc 'Build Gem'
47
+ Rake::GemPackageTask.new gem do |pkg|
48
+ pkg.need_tar = true
49
+ end
50
+
51
+ desc 'Run tests'
52
+ task :default => :test
53
+
54
+ desc 'Run tests'
55
+ Rake::TestTask.new :test do |t|
56
+ t.libs << 'test'
57
+ t.warning = true
58
+ end
59
+
60
+ desc 'Generate RDoc'
61
+ Rake::RDocTask.new :rdoc do |rd|
62
+ rd.rdoc_dir = 'doc'
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["**/*~"]
88
+ end
89
+
90
+ # vim:syntax=ruby
91
+
data/install.rb ADDED
@@ -0,0 +1,174 @@
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
+
data/lib/rubyforge.rb CHANGED
@@ -25,7 +25,7 @@ end
25
25
  class RubyForge
26
26
 
27
27
  # :stopdoc:
28
- VERSION = "0.3.0"
28
+ VERSION = "0.3.1"
29
29
  HOME = ENV["HOME"] || ENV["HOMEPATH"] || File::expand_path("~")
30
30
  RUBYFORGE_D = File::join HOME, ".rubyforge"
31
31
  CONFIG_F = File::join RUBYFORGE_D, "config.yml"
@@ -44,6 +44,8 @@ class RubyForge
44
44
  @config = test(?e, config) ? IO::read(config) : CONFIG
45
45
  @config = YAML.load(@config).merge(opts)
46
46
 
47
+ @uri = URI.parse @config['uri']
48
+
47
49
  raise "no <username>" unless @config["username"]
48
50
  raise "no <password>" unless @config["password"]
49
51
  raise "no <cookie_jar>" unless @config["cookie_jar"]
@@ -59,7 +61,9 @@ class RubyForge
59
61
  end
60
62
 
61
63
  def login
62
- page = "/account/login.php"
64
+ page = @uri + "/account/login.php"
65
+ page.scheme = 'https'
66
+ page = URI.parse page.to_s # set SSL port correctly
63
67
 
64
68
  username = @config["username"]
65
69
  password = @config["password"]
@@ -261,16 +265,17 @@ class RubyForge
261
265
 
262
266
  def run(page, form, extheader={}) # :nodoc:
263
267
  client = HTTPAccess2::Client::new ENV["HTTP_PROXY"]
264
- client.debug_dev = STDERR if ENV["RUBYFORGE_DEBUG"] || ENV["DEBUG"]
268
+ client.debug_dev = STDERR if ENV["RUBYFORGE_DEBUG"] || ENV["DEBUG"] || $DEBUG
265
269
  client.set_cookie_store @config["cookie_jar"]
270
+ client.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE
266
271
 
267
272
  # HACK to fix http-access2 redirect bug/feature
268
273
  client.redirect_uri_callback = lambda do |res|
269
274
  page = res.header['location'].first
270
- page =~ %r/http/ ? page : "#{ @config['uri'] }/#{ page }"
275
+ page =~ %r/http/ ? page : @uri + page
271
276
  end
272
277
 
273
- uri = File.join(@config['uri'], page)
278
+ uri = @uri + page
274
279
  if $DEBUG then
275
280
  puts "client.post_content #{uri.inspect}, #{form.inspect}, #{extheader.inspect}"
276
281
  end
@@ -53,7 +53,7 @@ class TestRubyForge < Test::Unit::TestCase
53
53
  @rubyforge.config['password'] = p
54
54
  @rubyforge.login
55
55
 
56
- util_run('/account/login.php',
56
+ util_run('https://rubyforge.org/account/login.php',
57
57
  'form_pw' => p,
58
58
  'form_loginname' => u,
59
59
  'return_to' => '',
@@ -230,7 +230,7 @@ class TestRubyForge < Test::Unit::TestCase
230
230
  client = @rubyforge.client
231
231
  assert client.form.delete("userfile")
232
232
 
233
- assert_equal 'http://rubyforge.org/frs/admin/qrs.php', client.url
233
+ assert_equal 'http://rubyforge.org/frs/admin/qrs.php', client.url.to_s
234
234
  assert_equal form, client.form
235
235
  assert_equal extheader, client.headers
236
236
  end
@@ -245,7 +245,7 @@ class TestRubyForge < Test::Unit::TestCase
245
245
  form_result = @rubyforge.form
246
246
  assert form_result.delete("userfile") unless extheader.empty?
247
247
 
248
- assert_equal page, @rubyforge.page
248
+ assert_equal page, @rubyforge.page.to_s
249
249
  assert_equal form, form_result
250
250
  assert_equal extheader, @rubyforge.extheader
251
251
  end
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.0
2
+ rubygems_version: 0.8.99
3
3
  specification_version: 1
4
4
  name: rubyforge
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.3.0
7
- date: 2006-10-03 00:00:00 -07:00
6
+ version: 0.3.1
7
+ date: 2006-10-24 00:00:00 -07:00
8
8
  summary: A simplistic script which automates a limited set of rubyforge operations
9
9
  require_paths:
10
10
  - lib
@@ -29,7 +29,12 @@ post_install_message:
29
29
  authors:
30
30
  - Ara T. Howard
31
31
  files:
32
+ - History.txt
33
+ - Manifest.txt
34
+ - README
35
+ - Rakefile
32
36
  - bin/rubyforge
37
+ - install.rb
33
38
  - lib/http-access2.rb
34
39
  - lib/http-access2/cookie.rb
35
40
  - lib/http-access2/http.rb