maxcdn 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -0
- data/BENCHMARKS.md +8 -8
- data/README.md +6 -0
- data/VERSION +1 -1
- data/lib/maxcdn.rb +26 -6
- data/lib/maxcdn/version.rb +1 -1
- data/test/integration.rb +2 -1
- data/test/maxcdn_test.rb +9 -9
- metadata +4 -4
data/.gitignore
CHANGED
data/BENCHMARKS.md
CHANGED
@@ -10,11 +10,11 @@ Running benchmarks as follows in order:
|
|
10
10
|
maxcdn.purge('ZONEID', [ 'FILE1','FILE2' ])
|
11
11
|
|
12
12
|
user system total real
|
13
|
-
get : 0.050000 0.070000 0.120000 ( 1.
|
14
|
-
get : 0.
|
15
|
-
post : 0.020000 0.
|
16
|
-
put : 0.
|
17
|
-
delete: 0.020000 0.000000 0.020000 (
|
18
|
-
purge : 0.
|
19
|
-
purge : 0.020000 0.000000 0.020000 (
|
20
|
-
purge : 0.030000 0.
|
13
|
+
get : 0.050000 0.070000 0.120000 ( 1.026412)
|
14
|
+
get : 0.010000 0.000000 0.010000 ( 0.636914)
|
15
|
+
post : 0.020000 0.010000 0.030000 ( 11.083888)
|
16
|
+
put : 0.010000 0.000000 0.010000 ( 1.240014)
|
17
|
+
delete: 0.020000 0.000000 0.020000 ( 6.846295)
|
18
|
+
purge : 0.010000 0.010000 0.020000 ( 11.578944)
|
19
|
+
purge : 0.020000 0.000000 0.020000 ( 0.956149)
|
20
|
+
purge : 0.030000 0.000000 0.030000 ( 1.870104)
|
data/README.md
CHANGED
@@ -12,6 +12,8 @@ Do you like building cool stuff? Do APIs keep you up at night? We're looking fo
|
|
12
12
|
gem install maxcdn
|
13
13
|
```
|
14
14
|
|
15
|
+
> Requires Ruby 1.9.2+ (see: [Travis](https://travis-ci.org/MaxCDN/ruby-maxcdn) for passing Ruby versions.)
|
16
|
+
|
15
17
|
#### With Bundler
|
16
18
|
|
17
19
|
```
|
@@ -96,6 +98,10 @@ bundle exec ruby ./test/integration.rb # requires host's IP be whitelisted
|
|
96
98
|
|
97
99
|
# Change Log
|
98
100
|
|
101
|
+
##### 0.1.4
|
102
|
+
|
103
|
+
* Fixing bug where purging files purges entire zone.
|
104
|
+
|
99
105
|
##### 0.1.3
|
100
106
|
|
101
107
|
* Requested changes for debugging and development support. (See issue #2).
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.1.4
|
data/lib/maxcdn.rb
CHANGED
@@ -99,20 +99,40 @@ module MaxCDN
|
|
99
99
|
response_json
|
100
100
|
end
|
101
101
|
|
102
|
-
[ :post, :
|
102
|
+
[ :post, :put ].each do |method|
|
103
103
|
define_method(method) do |uri, data={}, options={}|
|
104
|
-
options[:body] ||= true
|
104
|
+
options[:body] ||= true
|
105
|
+
self._response_as_json method.to_s, uri, options, data
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
[ :get, :delete ].each do |method|
|
110
|
+
define_method(method) do |uri, data={}, options={}|
|
111
|
+
options[:body] = false
|
105
112
|
self._response_as_json method.to_s, uri, options, data
|
106
113
|
end
|
107
114
|
end
|
108
115
|
|
109
116
|
def purge zone_id, file_or_files=nil, options={}
|
110
|
-
|
111
|
-
return self.delete("/zones/pull.json/#{zone_id}/cache",
|
112
|
-
|
117
|
+
if file_or_files.nil?
|
118
|
+
return self.delete("/zones/pull.json/#{zone_id}/cache", {}, options)
|
119
|
+
end
|
120
|
+
|
121
|
+
if file_or_files.is_a?(String)
|
122
|
+
return self.delete("/zones/pull.json/#{zone_id}/cache", { "files" => file_or_files }, options)
|
123
|
+
end
|
124
|
+
|
125
|
+
if file_or_files.is_a?(Array)
|
126
|
+
return file_or_files.map do |file|
|
127
|
+
self.delete("/zones/pull.json/#{zone_id}/cache", { "files" => file }, options)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
if file_or_files.is_a?(Hash) and (file_or_files.has_key(:files) or file_or_files.has_key("files"))
|
132
|
+
return self.delete("/zones/pull.json/#{zone_id}/cache", { "files" => file_or_files }, options)
|
113
133
|
end
|
114
134
|
|
115
|
-
|
135
|
+
raise MaxCDN::APIException.new("Invalid file_or_files argument for delete method.")
|
116
136
|
end
|
117
137
|
end
|
118
138
|
end
|
data/lib/maxcdn/version.rb
CHANGED
data/test/integration.rb
CHANGED
@@ -56,7 +56,8 @@ class Client < Minitest::Test
|
|
56
56
|
popularfiles = @max.get("reports/popularfiles.json")["data"]["popularfiles"]
|
57
57
|
assert_equal 200, @max.purge(zone, popularfiles[0]["uri"])["code"], "purge file"
|
58
58
|
|
59
|
-
|
59
|
+
files = [popularfiles[0]["uri"], popularfiles[1]["uri"]]
|
60
|
+
assert_equal [{"code"=>200},{"code"=>200}], @max.purge(zone, files), "purge files"
|
60
61
|
end
|
61
62
|
end
|
62
63
|
|
data/test/maxcdn_test.rb
CHANGED
@@ -28,21 +28,21 @@ stub_request(:put, host+"/account.json")
|
|
28
28
|
.with(:body => "foo=bar", :headers => expected_headers)
|
29
29
|
.to_return(:body => '{"foo":"bar"}')
|
30
30
|
|
31
|
-
|
32
|
-
|
31
|
+
# requests without :body
|
32
|
+
expected_headers['Content-Type'] = "application/x-www-form-urlencoded"
|
33
|
+
stub_request(:get, host+"/account.json")
|
34
|
+
.with(:headers => expected_headers)
|
33
35
|
.to_return(:body => '{"foo":"bar"}')
|
34
36
|
|
35
|
-
stub_request(:delete, host+"/zones/pull.json/12345/cache")
|
36
|
-
.with(:
|
37
|
+
stub_request(:delete, host+"/zones/pull.json/12345/cache?files=foo.txt")
|
38
|
+
.with(:headers => expected_headers)
|
37
39
|
.to_return(:body => '{"foo":"bar"}')
|
38
40
|
|
39
|
-
stub_request(:delete, host+"/zones/pull.json/12345/cache")
|
41
|
+
stub_request(:delete, host+"/zones/pull.json/12345/cache?files=bar.txt")
|
40
42
|
.with(:headers => expected_headers)
|
41
43
|
.to_return(:body => '{"foo":"bar"}')
|
42
44
|
|
43
|
-
|
44
|
-
expected_headers['Content-Type'] = "application/x-www-form-urlencoded"
|
45
|
-
stub_request(:get, host+"/account.json")
|
45
|
+
stub_request(:delete, host+"/zones/pull.json/12345/cache")
|
46
46
|
.with(:headers => expected_headers)
|
47
47
|
.to_return(:body => '{"foo":"bar"}')
|
48
48
|
|
@@ -138,7 +138,7 @@ class Client < Minitest::Test
|
|
138
138
|
end
|
139
139
|
|
140
140
|
def test_purge_files
|
141
|
-
assert_equal({ "foo" => "bar" }, @max.purge(12345, [ "foo.txt", "bar.txt" ]))
|
141
|
+
assert_equal([{ "foo" => "bar" },{ "foo" => "bar" }], @max.purge(12345, [ "foo.txt", "bar.txt" ]))
|
142
142
|
end
|
143
143
|
end
|
144
144
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: maxcdn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-02-
|
12
|
+
date: 2014-02-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: signet
|
@@ -83,7 +83,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
83
83
|
version: '0'
|
84
84
|
segments:
|
85
85
|
- 0
|
86
|
-
hash:
|
86
|
+
hash: 545417652511611192
|
87
87
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
88
|
none: false
|
89
89
|
requirements:
|
@@ -92,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
92
|
version: '0'
|
93
93
|
segments:
|
94
94
|
- 0
|
95
|
-
hash:
|
95
|
+
hash: 545417652511611192
|
96
96
|
requirements: []
|
97
97
|
rubyforge_project:
|
98
98
|
rubygems_version: 1.8.23
|