akamai-pavlos 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Jay Zeschin
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,17 @@
1
+ = akamai
2
+
3
+ Description goes here.
4
+
5
+ == Note on Patches/Pull Requests
6
+
7
+ * Fork the project.
8
+ * Make your feature addition or bug fix.
9
+ * Add tests for it. This is important so I don't break it in a
10
+ future version unintentionally.
11
+ * Commit, do not mess with rakefile, version, or history.
12
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
13
+ * Send me a pull request. Bonus points for topic branches.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2009 Jay Zeschin. See LICENSE for details.
@@ -0,0 +1,53 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "akamai-pavlos"
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 = "paul.hieromnimon@gmail.com"
11
+ gem.homepage = "http://github.com/pavlos/akamai"
12
+ gem.authors = ["Paul Hieromnimon"]
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
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,77 @@
1
+ require 'tempfile'
2
+ require 'net/ftp'
3
+ require 'soap/wsdlDriver'
4
+
5
+ module Akamai
6
+ class << self
7
+ attr_accessor :configuration
8
+ end
9
+
10
+ def self.configure
11
+ self.configuration ||= Configuration.new
12
+ yield(configuration)
13
+ end
14
+
15
+ class Configuration
16
+
17
+ attr_accessor :cachecontrol_username,
18
+ :cachecontrol_password,
19
+ :cachecontrol_domain,
20
+ :cachecontrol_purge_action,
21
+ :netstorage_username,
22
+ :netstorage_password,
23
+ :netstorage_ftp_host,
24
+ :netstorage_public_host,
25
+ :netstorage_basedir,
26
+ :wsdl_url
27
+
28
+ def initialize
29
+ self.wsdl_url = 'http://ccuapi.akamai.com/ccuapi-axis.wsdl'
30
+ self.cachecontrol_domain = "production"
31
+ self.cachecontrol_purge_action = "remove"
32
+ end
33
+
34
+ end
35
+
36
+ def self.purge(*urls)
37
+ config = self.configuration
38
+ driver = SOAP::WSDLDriverFactory.new(config.wsdl_url).create_rpc_driver
39
+ driver.options['protocol.http.ssl_config.verify_mode'] = OpenSSL::SSL::VERIFY_NONE
40
+ driver.options["protocol.http.basic_auth"] << [config.wsdl_url, config.cachecontrol_username, config.cachecontrol_password]
41
+ result = driver.purgeRequest(config.cachecontrol_username, config.cachecontrol_password, '', ["domain=#{config.cachecontrol_domain}", "action=#{config.cachecontrol_purge_action}"], urls)
42
+ return result.resultCode == '100'
43
+ end
44
+
45
+ def self.put(location, filename)
46
+ Tempfile.open(filename) do |tempfile|
47
+
48
+ # write to the tempfile
49
+ tempfile.write(yield)
50
+ tempfile.flush
51
+
52
+ puts "Tempfile generated for #{filename} at #{tempfile.path}."
53
+
54
+ ftp = Net::FTP::new(self.configuration.netstorage_ftp_host)
55
+ ftp.passive = true
56
+
57
+ ftp.login(self.configuration.netstorage_username, self.configuration.netstorage_password)
58
+ ftp.chdir(self.configuration.netstorage_basedir) if self.configuration.netstorage_basedir
59
+ ftp.chdir(self.configuration.location)
60
+
61
+ ftp.put(tempfile.path, "#{filename}.new")
62
+ ftp.delete(filename) unless ftp.ls(filename)
63
+ ftp.rename("#{filename}.new", filename)
64
+ ftp.close
65
+
66
+ puts "Akamai upload completed for #{filename}."
67
+
68
+ tempfile.close
69
+ puts "Generated file deleted from tmp."
70
+
71
+ puts "Sending purge request"
72
+ purge_result = purge("http://#{self.configuration.netstorage_public_host}/#{location}/#{filename}")
73
+ puts "Purge request #{ self.configuration.purge_result ? 'was successful' : 'failed' }."
74
+ end
75
+ end
76
+
77
+ end
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'akamai'
8
+
9
+ class Test::Unit::TestCase
10
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestAkamai < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: akamai-pavlos
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Paul Hieromnimon
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-12-21 00:00:00 -08:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: soap4r
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ description: Simple library for interacting with Akamai NetStorage and EdgeSuite caches
36
+ email: paul.hieromnimon@gmail.com
37
+ executables: []
38
+
39
+ extensions: []
40
+
41
+ extra_rdoc_files:
42
+ - LICENSE
43
+ - README.rdoc
44
+ files:
45
+ - .document
46
+ - LICENSE
47
+ - README.rdoc
48
+ - Rakefile
49
+ - VERSION
50
+ - lib/akamai.rb
51
+ - test/helper.rb
52
+ - test/test_akamai.rb
53
+ has_rdoc: true
54
+ homepage: http://github.com/pavlos/akamai
55
+ licenses: []
56
+
57
+ post_install_message:
58
+ rdoc_options: []
59
+
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ hash: 3
68
+ segments:
69
+ - 0
70
+ version: "0"
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ hash: 3
77
+ segments:
78
+ - 0
79
+ version: "0"
80
+ requirements: []
81
+
82
+ rubyforge_project:
83
+ rubygems_version: 1.4.2
84
+ signing_key:
85
+ specification_version: 3
86
+ summary: Simple library for interacting with Akamai NetStorage and EdgeSuite caches
87
+ test_files: []
88
+