akamai 0.0.5 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,21 +1,5 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
-
21
- ## PROJECT::SPECIFIC
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ .idea
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in akamai.gemspec
4
+ gemspec
@@ -1,6 +1,6 @@
1
1
  = akamai
2
2
 
3
- Description goes here.
3
+ Very simple utility library for scripting Akamai NetStorage FTP and WAA purge operations
4
4
 
5
5
  == Note on Patches/Pull Requests
6
6
 
data/Rakefile CHANGED
@@ -1,53 +1 @@
1
- require 'rubygems'
2
- require 'rake'
3
-
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "akamai"
8
- gem.summary = %Q{Simple library for interacting with Akamai NetStorage and EdgeSuite caches}
9
- gem.description = %Q{Simple library for interacting with Akamai NetStorage and EdgeSuite caches}
10
- gem.email = "jay.zeschin@factorylabs.com"
11
- gem.homepage = "http://github.com/jayzes/akamai"
12
- gem.authors = ["Jay Zeschin"]
13
- gem.add_dependency "soap4r", ">= 0"
14
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
- end
16
- Jeweler::GemcutterTasks.new
17
- rescue LoadError
18
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
19
- end
20
-
21
- require 'rake/testtask'
22
- Rake::TestTask.new(:test) do |test|
23
- test.libs << 'lib' << 'test'
24
- test.pattern = 'test/**/test_*.rb'
25
- test.verbose = true
26
- end
27
-
28
- begin
29
- require 'rcov/rcovtask'
30
- Rcov::RcovTask.new do |test|
31
- test.libs << 'test'
32
- test.pattern = 'test/**/test_*.rb'
33
- test.verbose = true
34
- end
35
- rescue LoadError
36
- task :rcov do
37
- abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
38
- end
39
- end
40
-
41
- task :test => :check_dependencies
42
-
43
- task :default => :test
44
-
45
- require 'rake/rdoctask'
46
- Rake::RDocTask.new do |rdoc|
47
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
-
49
- rdoc.rdoc_dir = 'rdoc'
50
- rdoc.title = "akamai #{version}"
51
- rdoc.rdoc_files.include('README*')
52
- rdoc.rdoc_files.include('lib/**/*.rb')
53
- end
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "akamai/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "akamai"
7
+ s.version = Akamai::VERSION
8
+ s.authors = ["Jay Zeschin"]
9
+ s.email = ["jay@zeschin.org"]
10
+ s.homepage = "https://github.com/jayzes/akamai"
11
+ s.summary = %Q{Simple library for interacting with Akamai NetStorage and EdgeSuite caches}
12
+ s.description = %Q{Simple library for interacting with Akamai NetStorage and EdgeSuite caches}
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ s.require_paths = ["lib"]
18
+
19
+ # specify any dependencies here; for example:
20
+ s.add_development_dependency "rake"
21
+ # s.add_runtime_dependency "rest-client"
22
+ end
@@ -2,9 +2,15 @@ require 'tempfile'
2
2
  require 'net/ftp'
3
3
  require 'soap/wsdlDriver'
4
4
 
5
+ require 'akamai/version'
6
+ require 'akamai/errors'
7
+ require 'akamai/configuration'
8
+ require 'akamai/connection'
9
+
5
10
  module Akamai
6
11
  class << self
7
12
  attr_accessor :configuration
13
+ attr_writer :connection
8
14
  end
9
15
 
10
16
  def self.configure
@@ -12,30 +18,13 @@ module Akamai
12
18
  yield(configuration)
13
19
  end
14
20
 
15
- class Configuration
16
-
17
- attr_accessor :cachecontrol_username,
18
- :cachecontrol_password,
19
- :netstorage_username,
20
- :netstorage_password,
21
- :netstorage_ftp_host,
22
- :netstorage_public_host,
23
- :netstorage_basedir,
24
- :wsdl_url
25
-
26
- def initialize
27
- self.wsdl_url = 'http://ccuapi.akamai.com/ccuapi-axis.wsdl'
28
- end
29
-
21
+ def self.connection
22
+ @connection ||= Connection.new(configuration)
30
23
  end
31
-
24
+
32
25
  def self.purge(*urls)
33
- driver = SOAP::WSDLDriverFactory.new(self.configuration.wsdl_url).create_rpc_driver
34
- driver.options['protocol.http.ssl_config.verify_mode'] = OpenSSL::SSL::VERIFY_NONE
35
- driver.options["protocol.http.basic_auth"] << [self.configuration.wsdl_url, self.configuration.cachecontrol_username, self.configuration.cachecontrol_password]
36
- result = driver.purgeRequest(self.configuration.cachecontrol_username, self.configuration.cachecontrol_password, '', [], urls)
37
- return result.resultCode == '100'
38
- end
26
+ connection.purge(*urls)
27
+ end
39
28
 
40
29
  def self.put(location, filename)
41
30
  Tempfile.open(filename) do |tempfile|
@@ -0,0 +1,30 @@
1
+ module Akamai
2
+
3
+ class Configuration
4
+
5
+ attr_accessor :cachecontrol_username,
6
+ :cachecontrol_password,
7
+ :cachecontrol_domain,
8
+ :cachecontrol_purge_action,
9
+ :cachecontrol_email_notification,
10
+ :netstorage_username,
11
+ :netstorage_password,
12
+ :netstorage_ftp_host,
13
+ :netstorage_public_host,
14
+ :netstorage_basedir,
15
+ :wsdl_url
16
+
17
+ def initialize(args = {})
18
+ self.wsdl_url = 'http://ccuapi.akamai.com/ccuapi-axis.wsdl'
19
+ self.cachecontrol_domain = "production"
20
+ self.cachecontrol_purge_action = "remove"
21
+
22
+ for key, val in args
23
+ send("#{key}=".to_sym, val)
24
+ end
25
+
26
+ end
27
+
28
+ end
29
+
30
+ end
@@ -0,0 +1,30 @@
1
+ module Akamai
2
+
3
+ class Connection
4
+
5
+ attr_accessor :config
6
+
7
+ def initialize(args = {})
8
+ @config = args.kind_of?(Configuration) ? args : Configuration.new(args)
9
+ end
10
+
11
+ def driver
12
+ return @driver if @driver
13
+
14
+ @driver = SOAP::WSDLDriverFactory.new(config.wsdl_url).create_rpc_driver
15
+ @driver.options['protocol.http.ssl_config.verify_mode'] = OpenSSL::SSL::VERIFY_NONE
16
+ @driver.options["protocol.http.basic_auth"] << [config.wsdl_url, config.cachecontrol_username, config.cachecontrol_password]
17
+ @driver
18
+ end
19
+
20
+ def purge(*urls)
21
+ opts = ["domain=#{config.cachecontrol_domain}", "action=#{config.cachecontrol_purge_action}"]
22
+ opts << "email-notification=#{config.cachecontrol_email_notification}" if config.cachecontrol_email_notification
23
+ result = driver.purgeRequest(config.cachecontrol_username, config.cachecontrol_password, '', opts, urls)
24
+ raise PurgeError, result.inspect unless result.resultCode == '100'
25
+ true
26
+ end
27
+
28
+ end
29
+
30
+ end
@@ -0,0 +1,9 @@
1
+ module Akamai
2
+
3
+ class Error < StandardError
4
+ end
5
+
6
+ class PurgeError < StandardError
7
+ end
8
+
9
+ end
@@ -0,0 +1,3 @@
1
+ module Akamai
2
+ VERSION = "0.2"
3
+ end
metadata CHANGED
@@ -1,74 +1,77 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: akamai
3
- version: !ruby/object:Gem::Version
4
- version: 0.0.5
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.2'
5
+ prerelease:
5
6
  platform: ruby
6
- authors:
7
+ authors:
7
8
  - Jay Zeschin
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
-
12
- date: 2010-02-10 00:00:00 -07:00
13
- default_executable:
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: soap4r
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: "0"
24
- version:
12
+ date: 2012-06-21 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  description: Simple library for interacting with Akamai NetStorage and EdgeSuite caches
26
- email: jay.zeschin@factorylabs.com
31
+ email:
32
+ - jay@zeschin.org
27
33
  executables: []
28
-
29
34
  extensions: []
30
-
31
- extra_rdoc_files:
32
- - LICENSE
33
- - README.rdoc
34
- files:
35
+ extra_rdoc_files: []
36
+ files:
35
37
  - .document
36
38
  - .gitignore
39
+ - Gemfile
37
40
  - LICENSE
38
41
  - README.rdoc
39
42
  - Rakefile
40
- - VERSION
43
+ - akamai.gemspec
41
44
  - lib/akamai.rb
45
+ - lib/akamai/configuration.rb
46
+ - lib/akamai/connection.rb
47
+ - lib/akamai/errors.rb
48
+ - lib/akamai/version.rb
42
49
  - test/helper.rb
43
50
  - test/test_akamai.rb
44
- has_rdoc: true
45
- homepage: http://github.com/jayzes/akamai
51
+ homepage: https://github.com/jayzes/akamai
46
52
  licenses: []
47
-
48
53
  post_install_message:
49
- rdoc_options:
50
- - --charset=UTF-8
51
- require_paths:
54
+ rdoc_options: []
55
+ require_paths:
52
56
  - lib
53
- required_ruby_version: !ruby/object:Gem::Requirement
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- version: "0"
58
- version:
59
- required_rubygems_version: !ruby/object:Gem::Requirement
60
- requirements:
61
- - - ">="
62
- - !ruby/object:Gem::Version
63
- version: "0"
64
- version:
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
65
69
  requirements: []
66
-
67
70
  rubyforge_project:
68
- rubygems_version: 1.3.5
71
+ rubygems_version: 1.8.23
69
72
  signing_key:
70
73
  specification_version: 3
71
74
  summary: Simple library for interacting with Akamai NetStorage and EdgeSuite caches
72
- test_files:
75
+ test_files:
73
76
  - test/helper.rb
74
77
  - test/test_akamai.rb
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.0.5