Module: Akamai
- Defined in:
- lib/akamai.rb
Defined Under Namespace
Classes: Configuration
Class Attribute Summary collapse
-
.configuration ⇒ Object
Returns the value of attribute configuration.
Class Method Summary collapse
Class Attribute Details
.configuration ⇒ Object
Returns the value of attribute configuration.
7 8 9 |
# File 'lib/akamai.rb', line 7 def configuration @configuration end |
Class Method Details
.configure {|configuration| ... } ⇒ Object
10 11 12 13 |
# File 'lib/akamai.rb', line 10 def self.configure self.configuration ||= Configuration.new yield(configuration) end |
.purge(*urls) ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/akamai.rb', line 36 def self.purge(*urls) config = self.configuration driver = SOAP::WSDLDriverFactory.new(config.wsdl_url).create_rpc_driver driver.['protocol.http.ssl_config.verify_mode'] = OpenSSL::SSL::VERIFY_NONE driver.["protocol.http.basic_auth"] << [config.wsdl_url, config.cachecontrol_username, config.cachecontrol_password] result = driver.purgeRequest(config.cachecontrol_username, config.cachecontrol_password, '', ["domain=#{config.cachecontrol_domain}", "action=#{config.cachecontrol_purge_action}"], urls) return result.resultCode == '100' end |
.put(location, filename) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/akamai.rb', line 45 def self.put(location, filename) Tempfile.open(filename) do |tempfile| # write to the tempfile tempfile.write(yield) tempfile.flush puts "Tempfile generated for #{filename} at #{tempfile.path}." ftp = Net::FTP::new(self.configuration.netstorage_ftp_host) ftp.passive = true ftp.login(self.configuration.netstorage_username, self.configuration.netstorage_password) ftp.chdir(self.configuration.netstorage_basedir) if self.configuration.netstorage_basedir ftp.chdir(self.configuration.location) ftp.put(tempfile.path, "#{filename}.new") ftp.delete(filename) unless ftp.ls(filename) ftp.rename("#{filename}.new", filename) ftp.close puts "Akamai upload completed for #{filename}." tempfile.close puts "Generated file deleted from tmp." puts "Sending purge request" purge_result = purge("http://#{self.configuration.netstorage_public_host}/#{location}/#{filename}") puts "Purge request #{ self.configuration.purge_result ? 'was successful' : 'failed' }." end end |