Class: Fog::CDN::Rackspace::Mock
- Inherits:
-
Rackspace::Service
- Object
- Rackspace::Service
- Fog::CDN::Rackspace::Mock
- Includes:
- Base
- Defined in:
- lib/fog/rackspace/cdn.rb,
lib/fog/rackspace/requests/cdn/delete_object.rb,
lib/fog/rackspace/requests/cdn/put_container.rb,
lib/fog/rackspace/requests/cdn/get_containers.rb,
lib/fog/rackspace/requests/cdn/head_container.rb,
lib/fog/rackspace/requests/cdn/post_container.rb
Constant Summary
Constants included from Base
Class Method Summary collapse
Instance Method Summary collapse
- #data ⇒ Object
- #delete_object(container, object) ⇒ Object
- #get_containers(options = {}) ⇒ Object
- #head_container(container) ⇒ Object
-
#initialize(options = {}) ⇒ Mock
constructor
A new instance of Mock.
- #post_container(name, options = {}) ⇒ Object
- #purge(object) ⇒ Object
- #put_container(name, options = {}) ⇒ Object
- #reset_data ⇒ Object
Methods included from Base
#endpoint_uri, #publish_container, #region, #service_name, #urls
Methods inherited from Rackspace::Service
#authenticate, #endpoint_uri, #region, #service_name
Constructor Details
#initialize(options = {}) ⇒ Mock
Returns a new instance of Mock.
81 82 83 |
# File 'lib/fog/rackspace/cdn.rb', line 81 def initialize(={}) @rackspace_username = [:rackspace_username] end |
Class Method Details
.data ⇒ Object
71 72 73 74 75 |
# File 'lib/fog/rackspace/cdn.rb', line 71 def self.data @data ||= Hash.new do |hash, key| hash[key] = {} end end |
.reset ⇒ Object
77 78 79 |
# File 'lib/fog/rackspace/cdn.rb', line 77 def self.reset @data = nil end |
Instance Method Details
#data ⇒ Object
85 86 87 |
# File 'lib/fog/rackspace/cdn.rb', line 85 def data self.class.data[@rackspace_username] end |
#delete_object(container, object) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/fog/rackspace/requests/cdn/delete_object.rb', line 23 def delete_object(container, object) response = Excon::Response.new response.status = 204 response.headers = { "Content-Length"=>"0", "Date"=>"Fri, 01 Feb 2013 21:34:33 GMT", "X-Trans-Id"=>"tx860f26bd76284a849384c0a467767b57" } response.body = "" response end |
#get_containers(options = {}) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/fog/rackspace/requests/cdn/get_containers.rb', line 32 def get_containers( = {}) response = Excon::Response.new response.status = 200 response.headers = { "Content-Length"=>"4402", "Date"=>"Fri, 01 Feb 2013 21:16:54 GMT", "Content-Type"=>"application/json", "X-Trans-Id"=>"tx6c79ea47300941c49f2291b4d47d4ef5" } response.body = [ { "log_retention"=>false, "cdn_ios_uri"=>"http://a590286a323fec6aed22-d1e9259b2132e81da48ed3e1e802ef22.iosr.cf1.rackcdn.com", "ttl"=>3600, "cdn_enabled"=>true, "cdn_streaming_uri"=>"http://168e307d41afe64f1a62-d1e9259b2132e81da48ed3e1e802ef22.r2.stream.cf1.rackcdn.com", "name"=>"brown", "cdn_uri"=>"http://6e8f4bf5125c9c2e4e3a-d1e9259b2132e81da48ed3e1e802ef22.r2.cf1.rackcdn.com", "cdn_ssl_uri"=>"https://f83cb7d39e0b9ff9581b-d1e9259b2132e81da48ed3e1e802ef22.ssl.cf1.rackcdn.com" }, { "log_retention"=>false, "cdn_ios_uri"=>"http://b141f80caedd02158f10-cf33674d895dc8b8e6e5207fdbd5cae4.iosr.cf1.rackcdn.com", "ttl"=>5000, "cdn_enabled"=>false, "cdn_streaming_uri"=>"http://ea5feee96b8087a3d5e5-cf33674d895dc8b8e6e5207fdbd5cae4.r72.stream.cf1.rackcdn.com", "name"=>"fogcontainertests", "cdn_uri"=>"http://0115a9de56617a5d5473-cf33674d895dc8b8e6e5207fdbd5cae4.r72.cf1.rackcdn.com", "cdn_ssl_uri"=>"https://a5df8bd8a418ca88061e-cf33674d895dc8b8e6e5207fdbd5cae4.ssl.cf1.rackcdn.com" } ] response end |
#head_container(container) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/fog/rackspace/requests/cdn/head_container.rb', line 34 def head_container(container) raise Fog::Storage::Rackspace::NotFound.new "#{container} not found" unless container == 'fogcontainertests' response = Excon::Response.new response.status = 204 response.headers = { "X-Cdn-Uri"=>"http://e4bbc22477d80eaf22bd-ca4e4e61e477bbd430e1f5b9dc9a19f5.r53.cf1.rackcdn.com", "X-Cdn-Ios-Uri"=>"http://3c10ef49037f74416445-ca4e4e61e477bbd430e1f5b9dc9a19f5.iosr.cf1.rackcdn.com", "X-Cdn-Ssl-Uri"=>"https://b722b8ee248259c37901-ca4e4e61e477bbd430e1f5b9dc9a19f5.ssl.cf1.rackcdn.com", "X-Log-Retention"=>"False", "X-Cdn-Enabled"=>"True", "Content-Length"=>"0", "Date"=>"Fri, 01 Feb 2013 21:25:57 GMT", "X-Cdn-Streaming-Uri"=>"http://b82027c64cb4dd03670a-ca4e4e61e477bbd430e1f5b9dc9a19f5.r53.stream.cf1.rackcdn.com", "X-Ttl"=>"259200", "X-Trans-Id"=>"txca40ffd0412943608bb3e9656c8b81ef" } response.body = "" response end |
#post_container(name, options = {}) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/fog/rackspace/requests/cdn/post_container.rb', line 31 def post_container(name, = {}) raise Fog::Storage::Rackspace::NotFound.new "#{name} not found" unless name == 'fogcontainertests' response = Excon::Response.new response.status = 202 response.headers = { "X-Cdn-Uri"=>"http://e4bbc22477d80eaf22bd-ca4e4e61e477bbd430e1f5b9dc9a19f5.r53.cf1.rackcdn.com", "X-Cdn-Ios-Uri"=>"http://3c10ef49037f74416445-ca4e4e61e477bbd430e1f5b9dc9a19f5.iosr.cf1.rackcdn.com", "X-Cdn-Ssl-Uri"=>"https://b722b8ee248259c37901-ca4e4e61e477bbd430e1f5b9dc9a19f5.ssl.cf1.rackcdn.com", "Content-Length"=>"58", "Date"=>"Fri, 01 Feb 2013 21:31:30 GMT", "Content-Type"=>"text/plain; charset=UTF-8", "X-Cdn-Streaming-Uri"=>"http://b82027c64cb4dd03670a-ca4e4e61e477bbd430e1f5b9dc9a19f5.r53.stream.cf1.rackcdn.com", "X-Trans-Id"=>"tx4a3206e63dfc446bb5b60e34a62f749d" } response.body = "202 Accepted\n\nThe request is accepted for processing.\n\n " response end |
#purge(object) ⇒ Object
89 90 91 92 |
# File 'lib/fog/rackspace/cdn.rb', line 89 def purge(object) return true if object.is_a? Fog::Storage::Rackspace::File raise Fog::Errors::NotImplemented.new("#{object.class} does not support CDN purging") if object end |
#put_container(name, options = {}) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/fog/rackspace/requests/cdn/put_container.rb', line 31 def put_container(name, = {}) response = Excon::Response.new response.status = 201 response.headers = { "X-Cdn-Uri"=>"http://e4bbc22477d80eaf22bd-ca4e4e61e477bbd430e1f5b9dc9a19f5.r53.cf1.rackcdn.com", "X-Cdn-Ios-Uri"=>"http://3c10ef49037f74416445-ca4e4e61e477bbd430e1f5b9dc9a19f5.iosr.cf1.rackcdn.com", "X-Cdn-Ssl-Uri"=>"https://b722b8ee248259c37901-ca4e4e61e477bbd430e1f5b9dc9a19f5.ssl.cf1.rackcdn.com", "Content-Length"=>"18", "Date"=>"Fri, 01 Feb 2013 21:21:45 GMT", "Content-Type"=>"text/plain; charset=UTF-8", "X-Cdn-Streaming-Uri"=>"http://b82027c64cb4dd03670a-ca4e4e61e477bbd430e1f5b9dc9a19f5.r53.stream.cf1.rackcdn.com", "X-Trans-Id"=>"tx1b41ec63189f4862baa65e0c08711772" } response.body = "201 Created\n\n\n\n " response end |
#reset_data ⇒ Object
94 95 96 |
# File 'lib/fog/rackspace/cdn.rb', line 94 def reset_data self.class.data.delete(@rackspace_username) end |