Permalink
Browse files

Extract configuration/connection/errors into their own files

  • Loading branch information...
1 parent 9f97dfc commit f9860251f4810ecd219e7fb97399e1c6a4a96516 @jayzes committed Jan 31, 2012
Showing with 70 additions and 52 deletions.
  1. +4 −52 lib/akamai.rb
  2. +29 −0 lib/akamai/configuration.rb
  3. +28 −0 lib/akamai/connection.rb
  4. +9 −0 lib/akamai/errors.rb
View
@@ -1,7 +1,11 @@
require 'tempfile'
require 'net/ftp'
require 'soap/wsdlDriver'
+
require 'akamai/version'
+require 'akamai/errors'
+require 'akamai/configuration'
+require 'akamai/connection'
module Akamai
class << self
@@ -18,58 +22,6 @@ def self.connection
@connection ||= Connection.new(configuration)
end
- class Configuration
- attr_accessor :cachecontrol_username,
- :cachecontrol_password,
- :cachecontrol_domain,
- :cachecontrol_purge_action,
- :netstorage_username,
- :netstorage_password,
- :netstorage_ftp_host,
- :netstorage_public_host,
- :netstorage_basedir,
- :wsdl_url
-
- def initialize(args = {})
- self.wsdl_url = 'http://ccuapi.akamai.com/ccuapi-axis.wsdl'
- self.cachecontrol_domain = "production"
- self.cachecontrol_purge_action = "remove"
-
- for key, val in args
- send("#{key}=".to_sym, val)
- end
- end
-
- end
-
- class Connection
- attr_accessor :config
-
- def initialize(args = {})
- @config = args.kind_of?(Configuration) ? args : Configuration.new(args)
- end
-
- def driver
- return @driver if @driver
-
- @driver = SOAP::WSDLDriverFactory.new(config.wsdl_url).create_rpc_driver
- @driver.options['protocol.http.ssl_config.verify_mode'] = OpenSSL::SSL::VERIFY_NONE
- @driver.options["protocol.http.basic_auth"] << [config.wsdl_url, config.cachecontrol_username, config.cachecontrol_password]
- @driver
- end
-
- def purge(*urls)
- result = driver.purgeRequest(config.cachecontrol_username, config.cachecontrol_password, '', ["domain=#{config.cachecontrol_domain}", "action=#{config.cachecontrol_purge_action}"], urls)
- raise PurgeError, result.inspect unless result.resultCode == '100'
- true
- end
-
- class Error < StandardError
- end
- class PurgeError < StandardError
- end
- end
-
def self.purge(*urls)
connection.purge(*urls)
end
@@ -0,0 +1,29 @@
+module Akamai
+
+ class Configuration
+
+ attr_accessor :cachecontrol_username,
+ :cachecontrol_password,
+ :cachecontrol_domain,
+ :cachecontrol_purge_action,
+ :netstorage_username,
+ :netstorage_password,
+ :netstorage_ftp_host,
+ :netstorage_public_host,
+ :netstorage_basedir,
+ :wsdl_url
+
+ def initialize(args = {})
+ self.wsdl_url = 'http://ccuapi.akamai.com/ccuapi-axis.wsdl'
+ self.cachecontrol_domain = "production"
+ self.cachecontrol_purge_action = "remove"
+
+ for key, val in args
+ send("#{key}=".to_sym, val)
+ end
+
+ end
+
+ end
+
+end
View
@@ -0,0 +1,28 @@
+module Akamai
+
+ class Connection
+
+ attr_accessor :config
+
+ def initialize(args = {})
+ @config = args.kind_of?(Configuration) ? args : Configuration.new(args)
+ end
+
+ def driver
+ return @driver if @driver
+
+ @driver = SOAP::WSDLDriverFactory.new(config.wsdl_url).create_rpc_driver
+ @driver.options['protocol.http.ssl_config.verify_mode'] = OpenSSL::SSL::VERIFY_NONE
+ @driver.options["protocol.http.basic_auth"] << [config.wsdl_url, config.cachecontrol_username, config.cachecontrol_password]
+ @driver
+ end
+
+ def purge(*urls)
+ result = driver.purgeRequest(config.cachecontrol_username, config.cachecontrol_password, '', ["domain=#{config.cachecontrol_domain}", "action=#{config.cachecontrol_purge_action}"], urls)
+ raise PurgeError, result.inspect unless result.resultCode == '100'
+ true
+ end
+
+ end
+
+end
View
@@ -0,0 +1,9 @@
+module Akamai
+
+ class Error < StandardError
+ end
+
+ class PurgeError < StandardError
+ end
+
+end

0 comments on commit f986025

Please sign in to comment.