reggie 0.0.0 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +8 -1
- data/VERSION +1 -1
- data/lib/reggie.rb +48 -0
- data/reggie.gemspec +64 -0
- data/spec/fixtures/reggie/cache_management.yml +307 -0
- data/spec/fixtures/reggie/new.yml +143 -0
- data/spec/reggie_spec.rb +77 -3
- data/spec/spec_helper.rb +15 -2
- metadata +28 -25
data/Gemfile
CHANGED
@@ -5,10 +5,17 @@ source "http://rubygems.org"
|
|
5
5
|
|
6
6
|
# Add dependencies to develop your gem here.
|
7
7
|
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
|
9
|
+
gem "rest-client"
|
10
|
+
|
8
11
|
group :development do
|
9
12
|
gem "rspec", "~> 2.8.0"
|
10
13
|
gem "rdoc", "~> 3.12"
|
11
14
|
gem "bundler", "~> 1.0.0"
|
12
15
|
gem "jeweler", "~> 1.8.3"
|
13
|
-
|
16
|
+
end
|
17
|
+
|
18
|
+
group :test do
|
19
|
+
gem "webmock"
|
20
|
+
gem "vcr"
|
14
21
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.1.0
|
data/lib/reggie.rb
CHANGED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'rest_client'
|
3
|
+
|
4
|
+
class Reggie
|
5
|
+
attr_accessor :customer_id, :token
|
6
|
+
|
7
|
+
def initialize(args)
|
8
|
+
@customer_id = args[:customer_id]
|
9
|
+
@token = args[:token]
|
10
|
+
|
11
|
+
@base_uri = "https://api.edgecast.com/v2/mcc/customers"
|
12
|
+
@valid = false
|
13
|
+
|
14
|
+
begin
|
15
|
+
response = RestClient.get "#{@base_uri}/#{@customer_id}/compression",
|
16
|
+
:authorization => @token,
|
17
|
+
:accept => :json
|
18
|
+
@valid = true if response.code == 200
|
19
|
+
rescue => e
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def valid?
|
24
|
+
@valid
|
25
|
+
end
|
26
|
+
|
27
|
+
def load(image_url)
|
28
|
+
begin
|
29
|
+
response = RestClient.put "#{@base_uri}/#{@customer_id}/edge/load",
|
30
|
+
{:MediaPath => image_url, :MediaType => 8}.to_json,
|
31
|
+
:authorization => @token,
|
32
|
+
:content_type => :json,
|
33
|
+
:accept => :json
|
34
|
+
rescue => e
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def purge(image_url)
|
39
|
+
begin
|
40
|
+
response = RestClient.put "#{@base_uri}/#{@customer_id}/edge/purge",
|
41
|
+
{:MediaPath => image_url, :MediaType => 8}.to_json,
|
42
|
+
:authorization => @token,
|
43
|
+
:content_type => :json,
|
44
|
+
:accept => :json
|
45
|
+
rescue => e
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/reggie.gemspec
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{reggie}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Jimmy Huang"]
|
12
|
+
s.date = %q{2012-03-27}
|
13
|
+
s.description = %q{A Ruby wrapper for a caching API}
|
14
|
+
s.email = %q{jimmy.huang@duragility.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".rspec",
|
22
|
+
"Gemfile",
|
23
|
+
"LICENSE.txt",
|
24
|
+
"README.rdoc",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"lib/reggie.rb",
|
28
|
+
"reggie.gemspec",
|
29
|
+
"spec/fixtures/reggie/cache_management.yml",
|
30
|
+
"spec/fixtures/reggie/new.yml",
|
31
|
+
"spec/reggie_spec.rb",
|
32
|
+
"spec/spec_helper.rb"
|
33
|
+
]
|
34
|
+
s.homepage = %q{http://github.com/yhuang/reggie}
|
35
|
+
s.licenses = ["MIT"]
|
36
|
+
s.require_paths = ["lib"]
|
37
|
+
s.rubygems_version = %q{1.4.2}
|
38
|
+
s.summary = %q{A Ruby wrapper for a caching API}
|
39
|
+
|
40
|
+
if s.respond_to? :specification_version then
|
41
|
+
s.specification_version = 3
|
42
|
+
|
43
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
44
|
+
s.add_runtime_dependency(%q<rest-client>, [">= 0"])
|
45
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
|
46
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
47
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
48
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
|
49
|
+
else
|
50
|
+
s.add_dependency(%q<rest-client>, [">= 0"])
|
51
|
+
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
52
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
53
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
54
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
55
|
+
end
|
56
|
+
else
|
57
|
+
s.add_dependency(%q<rest-client>, [">= 0"])
|
58
|
+
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
59
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
60
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
61
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
@@ -0,0 +1,307 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: put
|
5
|
+
uri: https://api.edgecast.com/v2/mcc/customers/CUSTOMER_ID/edge/load
|
6
|
+
body:
|
7
|
+
string: "{\"MediaType\":8,\"MediaPath\":\"http://img.bleacherreport.net/img/slides/photos/002/037/135/137267039_crop_exact.jpg?w=650&h=440&q=85\"}"
|
8
|
+
headers:
|
9
|
+
Accept:
|
10
|
+
- application/json
|
11
|
+
Authorization:
|
12
|
+
- TOKEN
|
13
|
+
Content-Length:
|
14
|
+
- "131"
|
15
|
+
Accept-Encoding:
|
16
|
+
- gzip, deflate
|
17
|
+
Content-Type:
|
18
|
+
- application/json
|
19
|
+
response:
|
20
|
+
status:
|
21
|
+
code: 200
|
22
|
+
message: OK
|
23
|
+
headers:
|
24
|
+
Server:
|
25
|
+
- Microsoft-IIS/7.5
|
26
|
+
Date:
|
27
|
+
- Tue, 27 Mar 2012 16:41:27 GMT
|
28
|
+
Content-Length:
|
29
|
+
- "0"
|
30
|
+
X-Aspnet-Version:
|
31
|
+
- 4.0.30319
|
32
|
+
X-Powered-By:
|
33
|
+
- ASP.NET
|
34
|
+
Cache-Control:
|
35
|
+
- private
|
36
|
+
body:
|
37
|
+
string: ""
|
38
|
+
http_version:
|
39
|
+
recorded_at: Tue, 27 Mar 2012 16:42:37 GMT
|
40
|
+
- request:
|
41
|
+
method: put
|
42
|
+
uri: https://api.edgecast.com/v2/mcc/customers/CUSTOMER_ID/edge/load
|
43
|
+
body:
|
44
|
+
string: "{\"MediaType\":8,\"MediaPath\":\"http://img.bleacherreport.net/img/slides/photos/002/037/135/XXX_crop_exact.jpg?w=650&h=440&q=85\"}"
|
45
|
+
headers:
|
46
|
+
Accept:
|
47
|
+
- application/json
|
48
|
+
Authorization:
|
49
|
+
- TOKEN
|
50
|
+
Content-Length:
|
51
|
+
- "125"
|
52
|
+
Accept-Encoding:
|
53
|
+
- gzip, deflate
|
54
|
+
Content-Type:
|
55
|
+
- application/json
|
56
|
+
response:
|
57
|
+
status:
|
58
|
+
code: 200
|
59
|
+
message: OK
|
60
|
+
headers:
|
61
|
+
Server:
|
62
|
+
- Microsoft-IIS/7.5
|
63
|
+
Date:
|
64
|
+
- Tue, 27 Mar 2012 16:41:27 GMT
|
65
|
+
Content-Length:
|
66
|
+
- "0"
|
67
|
+
X-Aspnet-Version:
|
68
|
+
- 4.0.30319
|
69
|
+
X-Powered-By:
|
70
|
+
- ASP.NET
|
71
|
+
Cache-Control:
|
72
|
+
- private
|
73
|
+
body:
|
74
|
+
string: ""
|
75
|
+
http_version:
|
76
|
+
recorded_at: Tue, 27 Mar 2012 16:42:38 GMT
|
77
|
+
- request:
|
78
|
+
method: put
|
79
|
+
uri: https://api.edgecast.com/v2/mcc/customers/CUSTOMER_ID/edge/load
|
80
|
+
body:
|
81
|
+
string: "{\"MediaType\":8,\"MediaPath\":\"\"}"
|
82
|
+
headers:
|
83
|
+
Accept:
|
84
|
+
- application/json
|
85
|
+
Authorization:
|
86
|
+
- TOKEN
|
87
|
+
Content-Length:
|
88
|
+
- "30"
|
89
|
+
Accept-Encoding:
|
90
|
+
- gzip, deflate
|
91
|
+
Content-Type:
|
92
|
+
- application/json
|
93
|
+
response:
|
94
|
+
status:
|
95
|
+
code: 400
|
96
|
+
message: Bad Request
|
97
|
+
headers:
|
98
|
+
Server:
|
99
|
+
- Microsoft-IIS/7.5
|
100
|
+
Date:
|
101
|
+
- Tue, 27 Mar 2012 16:41:28 GMT
|
102
|
+
Content-Length:
|
103
|
+
- "63"
|
104
|
+
X-Aspnet-Version:
|
105
|
+
- 4.0.30319
|
106
|
+
X-Powered-By:
|
107
|
+
- ASP.NET
|
108
|
+
Content-Type:
|
109
|
+
- application/json; charset=utf-8
|
110
|
+
Cache-Control:
|
111
|
+
- private
|
112
|
+
body:
|
113
|
+
string: "{\"Message\":\"MediaPath: Path is required for this media type. \"}"
|
114
|
+
http_version:
|
115
|
+
recorded_at: Tue, 27 Mar 2012 16:42:38 GMT
|
116
|
+
- request:
|
117
|
+
method: put
|
118
|
+
uri: https://api.edgecast.com/v2/mcc/customers/CUSTOMER_ID/edge/load
|
119
|
+
body:
|
120
|
+
string: "{\"MediaType\":8,\"MediaPath\":\"http://www.amazon.com\"}"
|
121
|
+
headers:
|
122
|
+
Accept:
|
123
|
+
- application/json
|
124
|
+
Authorization:
|
125
|
+
- TOKEN
|
126
|
+
Content-Length:
|
127
|
+
- "51"
|
128
|
+
Accept-Encoding:
|
129
|
+
- gzip, deflate
|
130
|
+
Content-Type:
|
131
|
+
- application/json
|
132
|
+
response:
|
133
|
+
status:
|
134
|
+
code: 400
|
135
|
+
message: Bad Request
|
136
|
+
headers:
|
137
|
+
Server:
|
138
|
+
- Microsoft-IIS/7.5
|
139
|
+
Date:
|
140
|
+
- Tue, 27 Mar 2012 16:41:28 GMT
|
141
|
+
Content-Length:
|
142
|
+
- "183"
|
143
|
+
X-Aspnet-Version:
|
144
|
+
- 4.0.30319
|
145
|
+
X-Powered-By:
|
146
|
+
- ASP.NET
|
147
|
+
Content-Type:
|
148
|
+
- application/json; charset=utf-8
|
149
|
+
Cache-Control:
|
150
|
+
- private
|
151
|
+
body:
|
152
|
+
string: "{\"Message\":\"Invalid strPath parameter. Please double check the path to make sure it is valid. Also check that the media type id represents the correct platform for the path given.\"}"
|
153
|
+
http_version:
|
154
|
+
recorded_at: Tue, 27 Mar 2012 16:42:39 GMT
|
155
|
+
- request:
|
156
|
+
method: put
|
157
|
+
uri: https://api.edgecast.com/v2/mcc/customers/CUSTOMER_ID/edge/purge
|
158
|
+
body:
|
159
|
+
string: "{\"MediaType\":8,\"MediaPath\":\"http://img.bleacherreport.net/img/slides/photos/002/037/135/137267039_crop_exact.jpg?w=650&h=440&q=85\"}"
|
160
|
+
headers:
|
161
|
+
Accept:
|
162
|
+
- application/json
|
163
|
+
Authorization:
|
164
|
+
- TOKEN
|
165
|
+
Content-Length:
|
166
|
+
- "131"
|
167
|
+
Accept-Encoding:
|
168
|
+
- gzip, deflate
|
169
|
+
Content-Type:
|
170
|
+
- application/json
|
171
|
+
response:
|
172
|
+
status:
|
173
|
+
code: 200
|
174
|
+
message: OK
|
175
|
+
headers:
|
176
|
+
Server:
|
177
|
+
- Microsoft-IIS/7.5
|
178
|
+
Date:
|
179
|
+
- Tue, 27 Mar 2012 16:41:29 GMT
|
180
|
+
Content-Length:
|
181
|
+
- "0"
|
182
|
+
X-Aspnet-Version:
|
183
|
+
- 4.0.30319
|
184
|
+
X-Powered-By:
|
185
|
+
- ASP.NET
|
186
|
+
Cache-Control:
|
187
|
+
- private
|
188
|
+
body:
|
189
|
+
string: ""
|
190
|
+
http_version:
|
191
|
+
recorded_at: Tue, 27 Mar 2012 16:42:39 GMT
|
192
|
+
- request:
|
193
|
+
method: put
|
194
|
+
uri: https://api.edgecast.com/v2/mcc/customers/CUSTOMER_ID/edge/purge
|
195
|
+
body:
|
196
|
+
string: "{\"MediaType\":8,\"MediaPath\":\"http://img.bleacherreport.net/img/slides/photos/002/037/135/XXX_crop_exact.jpg?w=650&h=440&q=85\"}"
|
197
|
+
headers:
|
198
|
+
Accept:
|
199
|
+
- application/json
|
200
|
+
Authorization:
|
201
|
+
- TOKEN
|
202
|
+
Content-Length:
|
203
|
+
- "125"
|
204
|
+
Accept-Encoding:
|
205
|
+
- gzip, deflate
|
206
|
+
Content-Type:
|
207
|
+
- application/json
|
208
|
+
response:
|
209
|
+
status:
|
210
|
+
code: 200
|
211
|
+
message: OK
|
212
|
+
headers:
|
213
|
+
Server:
|
214
|
+
- Microsoft-IIS/7.5
|
215
|
+
Date:
|
216
|
+
- Tue, 27 Mar 2012 16:41:29 GMT
|
217
|
+
Content-Length:
|
218
|
+
- "0"
|
219
|
+
X-Aspnet-Version:
|
220
|
+
- 4.0.30319
|
221
|
+
X-Powered-By:
|
222
|
+
- ASP.NET
|
223
|
+
Cache-Control:
|
224
|
+
- private
|
225
|
+
body:
|
226
|
+
string: ""
|
227
|
+
http_version:
|
228
|
+
recorded_at: Tue, 27 Mar 2012 16:42:40 GMT
|
229
|
+
- request:
|
230
|
+
method: put
|
231
|
+
uri: https://api.edgecast.com/v2/mcc/customers/CUSTOMER_ID/edge/purge
|
232
|
+
body:
|
233
|
+
string: "{\"MediaType\":8,\"MediaPath\":\"\"}"
|
234
|
+
headers:
|
235
|
+
Accept:
|
236
|
+
- application/json
|
237
|
+
Authorization:
|
238
|
+
- TOKEN
|
239
|
+
Content-Length:
|
240
|
+
- "30"
|
241
|
+
Accept-Encoding:
|
242
|
+
- gzip, deflate
|
243
|
+
Content-Type:
|
244
|
+
- application/json
|
245
|
+
response:
|
246
|
+
status:
|
247
|
+
code: 400
|
248
|
+
message: Bad Request
|
249
|
+
headers:
|
250
|
+
Server:
|
251
|
+
- Microsoft-IIS/7.5
|
252
|
+
Date:
|
253
|
+
- Tue, 27 Mar 2012 16:41:30 GMT
|
254
|
+
Content-Length:
|
255
|
+
- "63"
|
256
|
+
X-Aspnet-Version:
|
257
|
+
- 4.0.30319
|
258
|
+
X-Powered-By:
|
259
|
+
- ASP.NET
|
260
|
+
Content-Type:
|
261
|
+
- application/json; charset=utf-8
|
262
|
+
Cache-Control:
|
263
|
+
- private
|
264
|
+
body:
|
265
|
+
string: "{\"Message\":\"MediaPath: Path is required for this media type. \"}"
|
266
|
+
http_version:
|
267
|
+
recorded_at: Tue, 27 Mar 2012 16:42:41 GMT
|
268
|
+
- request:
|
269
|
+
method: put
|
270
|
+
uri: https://api.edgecast.com/v2/mcc/customers/CUSTOMER_ID/edge/purge
|
271
|
+
body:
|
272
|
+
string: "{\"MediaType\":8,\"MediaPath\":\"http://www.amazon.com\"}"
|
273
|
+
headers:
|
274
|
+
Accept:
|
275
|
+
- application/json
|
276
|
+
Authorization:
|
277
|
+
- TOKEN
|
278
|
+
Content-Length:
|
279
|
+
- "51"
|
280
|
+
Accept-Encoding:
|
281
|
+
- gzip, deflate
|
282
|
+
Content-Type:
|
283
|
+
- application/json
|
284
|
+
response:
|
285
|
+
status:
|
286
|
+
code: 400
|
287
|
+
message: Bad Request
|
288
|
+
headers:
|
289
|
+
Server:
|
290
|
+
- Microsoft-IIS/7.5
|
291
|
+
Date:
|
292
|
+
- Tue, 27 Mar 2012 16:41:30 GMT
|
293
|
+
Content-Length:
|
294
|
+
- "183"
|
295
|
+
X-Aspnet-Version:
|
296
|
+
- 4.0.30319
|
297
|
+
X-Powered-By:
|
298
|
+
- ASP.NET
|
299
|
+
Content-Type:
|
300
|
+
- application/json; charset=utf-8
|
301
|
+
Cache-Control:
|
302
|
+
- private
|
303
|
+
body:
|
304
|
+
string: "{\"Message\":\"Invalid strPath parameter. Please double check the path to make sure it is valid. Also check that the media type id represents the correct platform for the path given.\"}"
|
305
|
+
http_version:
|
306
|
+
recorded_at: Tue, 27 Mar 2012 16:42:41 GMT
|
307
|
+
recorded_with: VCR 2.0.0
|
@@ -0,0 +1,143 @@
|
|
1
|
+
---
|
2
|
+
recorded_with: VCR 2.0.0
|
3
|
+
http_interactions:
|
4
|
+
- request:
|
5
|
+
method: get
|
6
|
+
uri: https://api.edgecast.com/v2/mcc/customers/CUSTOMER_ID/compression
|
7
|
+
body:
|
8
|
+
string: ""
|
9
|
+
headers:
|
10
|
+
Authorization:
|
11
|
+
- TOKEN
|
12
|
+
Accept:
|
13
|
+
- application/json
|
14
|
+
Accept-Encoding:
|
15
|
+
- gzip, deflate
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Content-Type:
|
22
|
+
- application/json; charset=utf-8
|
23
|
+
X-Aspnet-Version:
|
24
|
+
- 4.0.30319
|
25
|
+
X-Powered-By:
|
26
|
+
- ASP.NET
|
27
|
+
Server:
|
28
|
+
- Microsoft-IIS/7.5
|
29
|
+
Date:
|
30
|
+
- Tue, 27 Mar 2012 16:39:23 GMT
|
31
|
+
Cache-Control:
|
32
|
+
- private
|
33
|
+
Content-Length:
|
34
|
+
- "133"
|
35
|
+
body:
|
36
|
+
string: "[{\"MediaTypeId\":8,\"Status\":1,\"ContentTypes\":[\"text\\/plain\",\"text\\/html\",\"text\\/css\",\"application\\/x-javascript\",\"text\\/javascript\"]}]"
|
37
|
+
http_version:
|
38
|
+
recorded_at: Tue, 27 Mar 2012 16:40:34 GMT
|
39
|
+
- request:
|
40
|
+
method: get
|
41
|
+
uri: https://api.edgecast.com/v2/mcc/customers/XXXX/compression
|
42
|
+
body:
|
43
|
+
string: ""
|
44
|
+
headers:
|
45
|
+
Authorization:
|
46
|
+
- invalid
|
47
|
+
Accept:
|
48
|
+
- application/json
|
49
|
+
Accept-Encoding:
|
50
|
+
- gzip, deflate
|
51
|
+
response:
|
52
|
+
status:
|
53
|
+
code: 403
|
54
|
+
message: Forbidden
|
55
|
+
headers:
|
56
|
+
Content-Type:
|
57
|
+
- application/json; charset=utf-8
|
58
|
+
X-Aspnet-Version:
|
59
|
+
- 4.0.30319
|
60
|
+
X-Powered-By:
|
61
|
+
- ASP.NET
|
62
|
+
Server:
|
63
|
+
- Microsoft-IIS/7.5
|
64
|
+
Date:
|
65
|
+
- Tue, 27 Mar 2012 16:39:24 GMT
|
66
|
+
Cache-Control:
|
67
|
+
- private
|
68
|
+
Content-Length:
|
69
|
+
- "26"
|
70
|
+
body:
|
71
|
+
string: "{\"Message\":\"Invalid User\"}"
|
72
|
+
http_version:
|
73
|
+
recorded_at: Tue, 27 Mar 2012 16:40:34 GMT
|
74
|
+
- request:
|
75
|
+
method: get
|
76
|
+
uri: https://api.edgecast.com/v2/mcc/customers/XXXX/compression
|
77
|
+
body:
|
78
|
+
string: ""
|
79
|
+
headers:
|
80
|
+
Authorization:
|
81
|
+
- valid
|
82
|
+
Accept:
|
83
|
+
- application/json
|
84
|
+
Accept-Encoding:
|
85
|
+
- gzip, deflate
|
86
|
+
response:
|
87
|
+
status:
|
88
|
+
code: 403
|
89
|
+
message: Forbidden
|
90
|
+
headers:
|
91
|
+
Content-Type:
|
92
|
+
- application/json; charset=utf-8
|
93
|
+
X-Aspnet-Version:
|
94
|
+
- 4.0.30319
|
95
|
+
X-Powered-By:
|
96
|
+
- ASP.NET
|
97
|
+
Server:
|
98
|
+
- Microsoft-IIS/7.5
|
99
|
+
Date:
|
100
|
+
- Tue, 27 Mar 2012 16:39:24 GMT
|
101
|
+
Cache-Control:
|
102
|
+
- private
|
103
|
+
Content-Length:
|
104
|
+
- "26"
|
105
|
+
body:
|
106
|
+
string: "{\"Message\":\"Invalid User\"}"
|
107
|
+
http_version:
|
108
|
+
recorded_at: Tue, 27 Mar 2012 16:40:35 GMT
|
109
|
+
- request:
|
110
|
+
method: get
|
111
|
+
uri: https://api.edgecast.com/v2/mcc/customers/XXXX/compression
|
112
|
+
body:
|
113
|
+
string: ""
|
114
|
+
headers:
|
115
|
+
Authorization:
|
116
|
+
- invalid
|
117
|
+
Accept:
|
118
|
+
- application/json
|
119
|
+
Accept-Encoding:
|
120
|
+
- gzip, deflate
|
121
|
+
response:
|
122
|
+
status:
|
123
|
+
code: 403
|
124
|
+
message: Forbidden
|
125
|
+
headers:
|
126
|
+
Content-Type:
|
127
|
+
- application/json; charset=utf-8
|
128
|
+
X-Aspnet-Version:
|
129
|
+
- 4.0.30319
|
130
|
+
X-Powered-By:
|
131
|
+
- ASP.NET
|
132
|
+
Server:
|
133
|
+
- Microsoft-IIS/7.5
|
134
|
+
Date:
|
135
|
+
- Tue, 27 Mar 2012 16:39:24 GMT
|
136
|
+
Cache-Control:
|
137
|
+
- private
|
138
|
+
Content-Length:
|
139
|
+
- "26"
|
140
|
+
body:
|
141
|
+
string: "{\"Message\":\"Invalid User\"}"
|
142
|
+
http_version:
|
143
|
+
recorded_at: Tue, 27 Mar 2012 16:40:35 GMT
|
data/spec/reggie_spec.rb
CHANGED
@@ -1,7 +1,81 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
|
3
|
-
describe
|
4
|
-
|
5
|
-
|
3
|
+
describe Reggie do
|
4
|
+
context "new" do
|
5
|
+
before :all do
|
6
|
+
VCR.insert_cassette 'new', :record => :new_episodes
|
7
|
+
end
|
8
|
+
|
9
|
+
after :all do
|
10
|
+
VCR.eject_cassette
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "with valid customer ID and valid authorization token" do
|
14
|
+
it "should return valid Reggie object" do
|
15
|
+
Reggie.new(:customer_id => EDGECAST_ACCOUNT[:customer_id], :token => EDGECAST_ACCOUNT[:token]).valid?.should be_true
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "with valid customer ID and invalid authorization token" do
|
20
|
+
it "should return invalid Reggie object" do
|
21
|
+
Reggie.new(:customer_id => "XXXX", :token => "invalid").valid?.should be_false
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "with invalid customer ID and valid authorization token" do
|
26
|
+
it "should return invalid Reggie object" do
|
27
|
+
Reggie.new(:customer_id => "XXXX", :token => "valid").valid?.should be_false
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "with invalid customer ID and invalid authorization token" do
|
32
|
+
it "should return invalid Reggie object" do
|
33
|
+
Reggie.new(:customer_id => "XXXX", :token => "invalid").valid?.should be_false
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context "Cache Management" do
|
39
|
+
before :all do
|
40
|
+
@reg = Reggie.new(:customer_id => EDGECAST_ACCOUNT[:customer_id], :token => EDGECAST_ACCOUNT[:token])
|
41
|
+
@urls = {
|
42
|
+
:empty => "",
|
43
|
+
:non_existent => "http://img.bleacherreport.net/img/slides/photos/002/037/135/XXX_crop_exact.jpg?w=650&h=440&q=85",
|
44
|
+
:valid => "http://img.bleacherreport.net/img/slides/photos/002/037/135/137267039_crop_exact.jpg?w=650&h=440&q=85",
|
45
|
+
:wrong_domain => "http://www.amazon.com",
|
46
|
+
}
|
47
|
+
|
48
|
+
VCR.insert_cassette 'cache_management', :record => :new_episodes
|
49
|
+
end
|
50
|
+
|
51
|
+
after :all do
|
52
|
+
VCR.eject_cassette
|
53
|
+
end
|
54
|
+
|
55
|
+
[:load, :purge].each do |method|
|
56
|
+
describe "#{method} valid cached image" do
|
57
|
+
it "should return a 200 response" do
|
58
|
+
@reg.send(method, @urls[:valid]).code.should == 200
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe "#{method} non-existent cached image" do
|
63
|
+
it "should return a 200 response" do
|
64
|
+
@reg.send(method, @urls[:non_existent]).code.should == 200
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe "#{method} empty URL" do
|
69
|
+
it "should return a RestClient::BadRequest" do
|
70
|
+
@reg.send(method, @urls[:empty]).should be_a RestClient::BadRequest
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "#{method} image from wrong domain" do
|
75
|
+
it "should return a RestClient::BadRequest" do
|
76
|
+
@reg.send(method, @urls[:wrong_domain]).should be_a RestClient::BadRequest
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
6
80
|
end
|
7
81
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,12 +1,25 @@
|
|
1
1
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
2
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
3
|
require 'rspec'
|
4
|
+
require 'webmock/rspec'
|
5
|
+
require 'vcr'
|
4
6
|
require 'reggie'
|
5
7
|
|
6
8
|
# Requires supporting files with custom matchers and macros, etc,
|
7
9
|
# in ./support/ and its subdirectories.
|
8
|
-
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
10
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
9
11
|
|
10
12
|
RSpec.configure do |config|
|
11
|
-
|
12
13
|
end
|
14
|
+
|
15
|
+
EDGECAST_ACCOUNT = {
|
16
|
+
:customer_id => 'REPLACE_ME',
|
17
|
+
:token => 'REPLACE_ME'
|
18
|
+
}
|
19
|
+
|
20
|
+
VCR.configure do |config|
|
21
|
+
config.cassette_library_dir = 'spec/fixtures/reggie'
|
22
|
+
config.filter_sensitive_data('CUSTOMER_ID') { EDGECAST_ACCOUNT[:customer_id] }
|
23
|
+
config.filter_sensitive_data('TOKEN') { EDGECAST_ACCOUNT[:token] }
|
24
|
+
config.hook_into :webmock
|
25
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reggie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.0
|
10
|
+
version: 0.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jimmy Huang
|
@@ -15,14 +15,28 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-03-
|
18
|
+
date: 2012-03-27 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
prerelease: false
|
23
|
+
name: rest-client
|
24
|
+
type: :runtime
|
25
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ">="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
hash: 3
|
31
|
+
segments:
|
32
|
+
- 0
|
33
|
+
version: "0"
|
34
|
+
requirement: *id001
|
21
35
|
- !ruby/object:Gem::Dependency
|
22
36
|
prerelease: false
|
23
37
|
name: rspec
|
24
38
|
type: :development
|
25
|
-
version_requirements: &
|
39
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
26
40
|
none: false
|
27
41
|
requirements:
|
28
42
|
- - ~>
|
@@ -33,12 +47,12 @@ dependencies:
|
|
33
47
|
- 8
|
34
48
|
- 0
|
35
49
|
version: 2.8.0
|
36
|
-
requirement: *
|
50
|
+
requirement: *id002
|
37
51
|
- !ruby/object:Gem::Dependency
|
38
52
|
prerelease: false
|
39
53
|
name: rdoc
|
40
54
|
type: :development
|
41
|
-
version_requirements: &
|
55
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
42
56
|
none: false
|
43
57
|
requirements:
|
44
58
|
- - ~>
|
@@ -48,12 +62,12 @@ dependencies:
|
|
48
62
|
- 3
|
49
63
|
- 12
|
50
64
|
version: "3.12"
|
51
|
-
requirement: *
|
65
|
+
requirement: *id003
|
52
66
|
- !ruby/object:Gem::Dependency
|
53
67
|
prerelease: false
|
54
68
|
name: bundler
|
55
69
|
type: :development
|
56
|
-
version_requirements: &
|
70
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
57
71
|
none: false
|
58
72
|
requirements:
|
59
73
|
- - ~>
|
@@ -64,12 +78,12 @@ dependencies:
|
|
64
78
|
- 0
|
65
79
|
- 0
|
66
80
|
version: 1.0.0
|
67
|
-
requirement: *
|
81
|
+
requirement: *id004
|
68
82
|
- !ruby/object:Gem::Dependency
|
69
83
|
prerelease: false
|
70
84
|
name: jeweler
|
71
85
|
type: :development
|
72
|
-
version_requirements: &
|
86
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
73
87
|
none: false
|
74
88
|
requirements:
|
75
89
|
- - ~>
|
@@ -80,20 +94,6 @@ dependencies:
|
|
80
94
|
- 8
|
81
95
|
- 3
|
82
96
|
version: 1.8.3
|
83
|
-
requirement: *id004
|
84
|
-
- !ruby/object:Gem::Dependency
|
85
|
-
prerelease: false
|
86
|
-
name: rcov
|
87
|
-
type: :development
|
88
|
-
version_requirements: &id005 !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
|
-
requirements:
|
91
|
-
- - ">="
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
hash: 3
|
94
|
-
segments:
|
95
|
-
- 0
|
96
|
-
version: "0"
|
97
97
|
requirement: *id005
|
98
98
|
description: A Ruby wrapper for a caching API
|
99
99
|
email: jimmy.huang@duragility.com
|
@@ -113,6 +113,9 @@ files:
|
|
113
113
|
- Rakefile
|
114
114
|
- VERSION
|
115
115
|
- lib/reggie.rb
|
116
|
+
- reggie.gemspec
|
117
|
+
- spec/fixtures/reggie/cache_management.yml
|
118
|
+
- spec/fixtures/reggie/new.yml
|
116
119
|
- spec/reggie_spec.rb
|
117
120
|
- spec/spec_helper.rb
|
118
121
|
has_rdoc: true
|