Class: Reap::Hosts::Rubyforge
- Defined in:
- lib/reap/hosts/rubyforge.rb
Overview
Rubyforge
Interface with the RubyForge hosting service. Supports the following tasks:
-
release - Upload release packages.
-
announce - Post news announcement.
-
touch - Test connection.
TODO: Handle publish tasks to upload website files (currently this is handled separately)
Constant Summary collapse
- DOMAIN =
"rubyforge.org"
- COOKIEJAR =
File::join(Dir.tmpdir, 'reap', 'cookie.dat')
- REPORT =
/<h\d><span style="color:red">(.*?)<\/span><\/h\d>/
Instance Attribute Summary collapse
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#group_id ⇒ Object
Project’s group id number.
-
#unixname ⇒ Object
Project unixname.
-
#uri ⇒ Object
readonly
URI = http:// + domain name TODO Deal with https, and possible other protocols too.
-
#username ⇒ Object
Username to use for project account.
-
#version ⇒ Object
Project name.
Attributes inherited from Tool
Instance Method Summary collapse
-
#announce(options) ⇒ Object
Submit a news item.
-
#commands ⇒ Object
What commands does this host support.
- #cookie_jar ⇒ Object
-
#initialize(project, options = {}) ⇒ Rubyforge
constructor
New RubyForge object.
-
#login ⇒ Object
Login to website.
-
#logout ⇒ Object
Logout of website.
-
#release(options) ⇒ Object
Upload release packages to hosting service.
-
#siteroot ⇒ Object
Website location on server.
-
#touch(options = {}) ⇒ Object
Touch base with server – login and logout.
Methods inherited from Host
#announce_confirm?, factory, inherited, #inspect, register, registry, #release_confirm?
Methods inherited from Tool
#debug?, #dryrun?, #force?, from_project, #metadata, #trace?, #verbose?
Methods included from Utilities
#ask, #bin?, #cd, #command_paths, #compress, #dir!, #dir?, directory!, directory?, #email, exist!, exist?, #exists!, #exists?, #file!, #fileutils, #glob, #list_option, #multiglob, #multiglob_r, #out_of_date?, path!, path?, #read, #rm_r, #safe?, #sh, #stage, #stage_manifest, #status, #write, #ziputils
Constructor Details
#initialize(project, options = {}) ⇒ Rubyforge
New RubyForge object.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/reap/hosts/rubyforge.rb', line 51 def initialize(project, ={}) = .rekey super(project, ) @domain = [:domain] || DOMAIN @uri = URI.parse("http://" + domain) @username = [:username] || ENV['RUBYFORGE_USERNAME'] @password = [:password] || ENV['RUBYFORGE_PASSWORD'] @unixname = [:project] || project..unixname @version = project..version @group_id = [:group] || [:group_id] || [:groupid] @package_ids = {} @release_ids = {} @file_ids = {} project.mkdir_p(File.dirname(COOKIEJAR)) #load_project end |
Instance Attribute Details
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
47 48 49 |
# File 'lib/reap/hosts/rubyforge.rb', line 47 def domain @domain end |
#group_id ⇒ Object
Project’s group id number.
101 102 103 |
# File 'lib/reap/hosts/rubyforge.rb', line 101 def group_id @group_id end |
#unixname ⇒ Object
Project unixname.
95 96 97 |
# File 'lib/reap/hosts/rubyforge.rb', line 95 def unixname @unixname end |
#uri ⇒ Object (readonly)
URI = http:// + domain name TODO Deal with https, and possible other protocols too.
41 42 43 |
# File 'lib/reap/hosts/rubyforge.rb', line 41 def uri @uri end |
#username ⇒ Object
Username to use for project account.
45 46 47 |
# File 'lib/reap/hosts/rubyforge.rb', line 45 def username @username end |
#version ⇒ Object
Project name.
98 99 100 |
# File 'lib/reap/hosts/rubyforge.rb', line 98 def version @version end |
Instance Method Details
#announce(options) ⇒ Object
Submit a news item.
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 |
# File 'lib/reap/hosts/rubyforge.rb', line 331 def announce() = .rekey if file = [:file] text = File.read(file).strip i = text.index("\n") subject = text[0...i].strip = text[i..-1].strip else subject = [:subject] = [:message] || [:body] end if dryrun? puts "announce-rubyforge: #{subject}" else post_news(subject, ) puts "News item posted!" end end |
#commands ⇒ Object
What commands does this host support.
90 91 92 |
# File 'lib/reap/hosts/rubyforge.rb', line 90 def commands %w{ touch release publish post } end |
#cookie_jar ⇒ Object
77 78 79 |
# File 'lib/reap/hosts/rubyforge.rb', line 77 def COOKIEJAR end |
#login ⇒ Object
Login to website.
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/reap/hosts/rubyforge.rb', line 108 def login # :yield: load_project_cached page = @uri + "/account/login.php" page.scheme = 'https' page = URI.parse(page.to_s) # set SSL port correctly form = { "return_to" => "", "form_loginname" => username, "form_pw" => password, "login" => "Login with SSL" } html = http_post(page, form) if not html[/Personal Page/] puts "Login failed." re1 = Regexp.escape(%{<h2 style="color:red">}) re2 = Regexp.escape(%{</h2>}) html[/#{re1}(.*?)#{re2}/] raise $1 else @printed_project_name ||= (puts "Project: #{unixname}"; true) end if block_given? begin yield ensure logout end end end |
#logout ⇒ Object
Logout of website.
144 145 146 147 148 |
# File 'lib/reap/hosts/rubyforge.rb', line 144 def logout page = "/account/logout.php" form = {} http_post(page, form) end |
#release(options) ⇒ Object
Upload release packages to hosting service.
This task releases files to RubyForge –it should work with other GForge instaces or SourceForge clones too.
While defaults are nice, you may want a little more control. You can specify additional attributes:
files package files to release.
exclude Package formats to exclude from files.
(from those created by pack)
unixname Project name on host.
package Package to which this release belongs (defaults to project)
release Release name (default is version number)
version Version of release
date Date of release (defaults to Time.now)
processor Processor/Architecture (any, i386, PPC, etc.)
is_public Public release? (defualts to true)
changelog Change log file
notelog Release notes file
The release option can be a template by using %s in the string. The version number of your project will be sub’d in for the %s. This saves you from having to update the release name before every release.
– What about releasing a pacman PKGBUILD? ++
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 |
# File 'lib/reap/hosts/rubyforge.rb', line 189 def release() = .rekey version = [:version] || .version changelog = [:changelog] notelog = [:notelog] unixname = [:unixname] || unixname() package = [:package] || unixname() release = [:release] || version() name = [:name] || package files = [:file] || [] date = [:date] || Time::now.strftime('%Y-%m-%d %H:%M') processor = [:processor] || 'Any' store = [:store] || 'pkg' is_public = [:is_public].nil? ? true : [:is_public] raise ArgumentError, "missing unixname" unless unixname raise ArgumentError, "missing package" unless package raise ArgumentError, "missing release" unless release if files.empty? files = Dir[File.join(store, '*')].select do |file| /#{version}[.]/ =~ file end #files = Dir.glob(File.join(store,"#{name}-#{version}*")) end files = files.select{ |f| File.file?(f) } abort "No package files." if files.empty? files.each do |file| abort "Not a file -- #{file}" unless File.exist?(file) puts "Release file: #{file}" end # which package types #rtypes = [ 'tgz', 'tbz', 'tar.gz', 'tar.bz2', 'deb', 'gem', 'ebuild', 'zip' ] #rtypes -= exclude #rtypes = rtypes.collect{ |rt| Regexp.escape( rt ) } #re_rtypes = Regexp.new('[.](' << rtypes.join('|') << ')$') puts "Releasing #{package} #{release}..." #unless options['quiet'] login do raise ArgumentError, "missing group_id" unless group_id unless package_id = package?(package) if dryrun? puts "Package '#{package}' does not exist." puts "Create package #{package}." abort "Cannot continue in dryrun mode." else #unless options['force'] q = "Package '#{package}' does not exist. Create?" a = ask(q, 'yN') abort "Task canceled." unless ['y', 'yes', 'okay'].include?(a.downcase) #end puts "Creating package #{package}..." create_package(package, is_public) unless package_id = package?(package) raise "Package creation failed." end end end if release_id = release?(release, package_id) #unless options[:force] if dryrun? puts "Release #{release} already exists." else q = "Release #{release} already exists. Re-release?" a = ask(q, 'yN') abort "Task canceled." unless ['y', 'yes', 'okay'].include?(a.downcase) #puts "Use -f option to force re-release." #return end files.each do |file| fname = File.basename(file) if file_id = file?(fname, package) if dryrun? puts "Remove file #{fname}." else puts "Removing file #{fname}..." remove_file(file_id, release_id, package_id) end end if dryrun? puts "Add file #{fname}." else puts "Adding file #{fname}..." add_file(file, release_id, package_id, processor) end end else if dryrun? puts "Add release #{release}." else puts "Adding release #{release}..." add_release(release, package_id, files, :processor => processor, :release_date => date, :release_changes => changelog, :release_notes => notelog, :preformatted => '1' ) unless release_id = release?(release, package_id) raise "Release creation failed." end end #files.each do |file| # puts "Added file #{File.basename(file)}." #end end end puts "Release complete!" unless dryrun? end |
#siteroot ⇒ Object
Website location on server.
84 85 86 |
# File 'lib/reap/hosts/rubyforge.rb', line 84 def siteroot "/var/www/gforge-projects" end |
#touch(options = {}) ⇒ Object
Touch base with server – login and logout.
152 153 154 155 156 157 |
# File 'lib/reap/hosts/rubyforge.rb', line 152 def touch(={}) login puts "Group ID: #{group_id}" puts "Login/Logout successful." logout end |