lib/cloudfiles.rb in cloudfiles-1.4.10 vs lib/cloudfiles.rb in cloudfiles-1.4.11

- old
+ new

@@ -1,29 +1,34 @@ #!/usr/bin/env ruby -# +# # == Cloud Files API # ==== Connects Ruby Applications to Rackspace's {Cloud Files service}[http://www.rackspacecloud.com/cloud_hosting_products/files] # Initial work by Major Hayden <major.hayden@rackspace.com> -# -# Subsequent work by H. Wade Minter <minter@lunenburg.org> # +# Subsequent work by H. Wade Minter <minter@lunenburg.org> and Dan Prince <dan.prince@rackspace.com> +# # See COPYING for license information. -# Copyright (c) 2009, Rackspace US, Inc. +# Copyright (c) 2011, Rackspace US, Inc. # ---- -# +# # === Documentation & Examples -# To begin reviewing the available methods and examples, peruse the README file, or begin by looking at documentation for the +# To begin reviewing the available methods and examples, peruse the README file, or begin by looking at documentation for the # CloudFiles::Connection class. # # The CloudFiles class is the base class. Not much of note happens here. -# To create a new CloudFiles connection, use the CloudFiles::Connection.new('user_name', 'api_key') method. +# To create a new CloudFiles connection, use the CloudFiles::Connection.new(:username => 'user_name', :api_key => 'api_key') method. + module CloudFiles + AUTH_USA = "https://auth.api.rackspacecloud.com/v1.0" + AUTH_UK = "https://lon.auth.api.rackspacecloud.com/v1.0" + VERSION = IO.read(File.dirname(__FILE__) + '/../VERSION') require 'net/http' require 'net/https' require 'rexml/document' + require 'cgi' require 'uri' require 'digest/md5' require 'time' require 'rubygems' require 'mime/types' @@ -32,16 +37,24 @@ require "jcode" $KCODE = 'u' end $:.unshift(File.dirname(__FILE__)) + require 'cloudfiles/exception' require 'cloudfiles/authentication' require 'cloudfiles/connection' require 'cloudfiles/container' require 'cloudfiles/storage_object' def self.lines(str) (str.respond_to?(:lines) ? str.lines : str).to_a.map { |x| x.chomp } + end + + # CGI.escape, but without special treatment on spaces + def self.escape(str) + str.gsub(/([^a-zA-Z0-9_.-]+)/) do + '%' + $1.unpack('H2' * $1.bytesize).join('%').upcase + end end end