maxcdn 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +6 -3
- data/README.md +10 -1
- data/lib/maxcdn.rb +10 -25
- data/lib/maxcdn/version.rb +1 -1
- data/maxcdn.gemspec +3 -2
- data/test/maxcdn_test.rb +1 -2
- metadata +22 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c94f389d66d158ba77d68022369bfc8c913ca04a
|
4
|
+
data.tar.gz: 91ca67962bbb188f27a81dbfb7f96c96cf1b831c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae8140863edc58d8ac5f8d4af47d5af918d8e1f75f7b392e40cec9d5330a0252605b2dc1586d0eb7cf7bb9f63a73c8351493412d3b9b4894ca73e2329e4e14c5
|
7
|
+
data.tar.gz: ce93ce746a2bc04633a5d14b5f4bb77115959c190146ebe1fef0bded5df2b5c8c93b886130bbd275de3717e4b47f79a01348db64955c91b023402d72e7389aa6
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -29,7 +29,7 @@ require 'maxcdn'
|
|
29
29
|
api = MaxCDN::Client.new("myalias", "consumer_key", "consumer_secret")
|
30
30
|
|
31
31
|
####
|
32
|
-
# Turn on debugging
|
32
|
+
# Turn on debugging outputs
|
33
33
|
#
|
34
34
|
# api.debug = true
|
35
35
|
|
@@ -98,6 +98,15 @@ bundle exec ruby ./test/integration.rb # requires host's IP be whitelisted
|
|
98
98
|
|
99
99
|
# Change Log
|
100
100
|
|
101
|
+
##### 0.3.0
|
102
|
+
|
103
|
+
* Replace CurbFu with Faraday (#10).
|
104
|
+
|
105
|
+
##### 0.2.1
|
106
|
+
|
107
|
+
* Upgrade signet gem to allow for use with the faraday 0.9.x series (#7).
|
108
|
+
* See https://rubygems.org/gems/maxcdn/versions/0.2.1 for gem.
|
109
|
+
|
101
110
|
##### 0.1.5
|
102
111
|
|
103
112
|
* Issue #4: Fixing purge files by array to return a hash of status results.
|
data/lib/maxcdn.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require "signet/oauth_1/client"
|
2
|
-
require "curb-fu"
|
3
2
|
require "json"
|
4
3
|
require "ext/hash"
|
5
4
|
require "pp" # for debug
|
@@ -49,46 +48,32 @@ module MaxCDN
|
|
49
48
|
request = @request_signer.generate_authenticated_request(req_opts)
|
50
49
|
|
51
50
|
# crazyness for headers
|
52
|
-
headers = options
|
51
|
+
headers = {"Content-Type" => options[:body] ? "application/json" : "application/x-www-form-urlencoded"}
|
52
|
+
headers.case_indifferent_merge(options.delete(:headers) || {})
|
53
53
|
headers["User-Agent"] = "Ruby MaxCDN API Client"
|
54
54
|
|
55
|
-
# because CurbFu overwrites 'content-type' header, strip it
|
56
|
-
# to set it later
|
57
|
-
content_type = headers.case_indifferent_delete("Content-Type") || (options[:body] ? "application/json" : "application/x-www-form-urlencoded")
|
58
|
-
|
59
55
|
# merge headers with request headers
|
60
56
|
request.headers.case_indifferent_merge(headers)
|
61
57
|
|
62
58
|
begin
|
63
|
-
|
64
|
-
|
65
|
-
:
|
66
|
-
|
67
|
-
|
68
|
-
CurbFu.debug = debug
|
69
|
-
|
70
|
-
response = CurbFu.send method, curb_opts, request.body do |curb|
|
71
|
-
curb.verbose = debug
|
72
|
-
|
73
|
-
# Because CurbFu overwrites the content-type header passed
|
74
|
-
# to it. so we'll be setting our own.
|
75
|
-
#
|
76
|
-
# First, remove any existing 'Content-Type' header.
|
77
|
-
curb.headers.case_indifferent_delete("Content-Type")
|
59
|
+
url, path = req_opts[:uri].match(%r"^(https://[^/]+)(/.+)$")[1, 2]
|
60
|
+
conn = Faraday.new(:url => url) do |faraday|
|
61
|
+
faraday.adapter :net_http_persistent
|
62
|
+
end
|
78
63
|
|
79
|
-
|
80
|
-
|
64
|
+
response = conn.send(method, path) do |req|
|
65
|
+
req.headers = request.headers
|
66
|
+
req.body = request.body
|
81
67
|
end
|
82
68
|
|
83
69
|
return response if options[:debug_request]
|
84
70
|
pp response if debug
|
85
71
|
|
86
72
|
response_json = JSON.load(response.body)
|
87
|
-
|
88
73
|
return response_json if options[:debug_json]
|
89
74
|
pp response_json if debug
|
90
75
|
|
91
|
-
unless response.success?
|
76
|
+
unless response.success?
|
92
77
|
error_message = response_json["error"]["message"]
|
93
78
|
raise MaxCDN::APIException.new("#{response.status}: #{error_message}")
|
94
79
|
end
|
data/lib/maxcdn/version.rb
CHANGED
data/maxcdn.gemspec
CHANGED
@@ -13,6 +13,7 @@ Gem::Specification.new do |gem|
|
|
13
13
|
gem.email = "joshua@mervine.net"
|
14
14
|
gem.authors = ["Joshua P. Mervine"]
|
15
15
|
gem.add_dependency 'json' if RUBY_VERSION.start_with? "1.8"
|
16
|
-
gem.add_dependency 'signet', '~> 0.
|
17
|
-
gem.add_dependency '
|
16
|
+
gem.add_dependency 'signet', '~> 0.7'
|
17
|
+
gem.add_dependency 'faraday', '~> 0.9'
|
18
|
+
gem.add_dependency 'net-http-persistent', '~> 2.9'
|
18
19
|
end
|
data/test/maxcdn_test.rb
CHANGED
@@ -15,7 +15,6 @@ expected_headers = {
|
|
15
15
|
'Authorization' => /.+/,
|
16
16
|
'Cache-Control' => /.+/,
|
17
17
|
'Content-Type' => "application/json",
|
18
|
-
'Expect' => /.*/,
|
19
18
|
'User-Agent' => "Ruby MaxCDN API Client"
|
20
19
|
}
|
21
20
|
|
@@ -101,7 +100,7 @@ class Client < Minitest::Test
|
|
101
100
|
|
102
101
|
def test__response_as_json_debug_request
|
103
102
|
res = @max._response_as_json("post", "zones/pull.json", { :body => true, :debug_request => true }, { "foo"=> "bar", "bar" => "foo" })
|
104
|
-
assert_equal(
|
103
|
+
assert_equal(Faraday::Response, res.class)
|
105
104
|
end
|
106
105
|
|
107
106
|
def test_custom_header
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: maxcdn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua P. Mervine
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: signet
|
@@ -16,28 +16,42 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: '0.7'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: '0.7'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: faraday
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: '0.9'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: '0.9'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: net-http-persistent
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.9'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.9'
|
41
55
|
description: A Rest Client For MaxCDN Rest Web Services
|
42
56
|
email: joshua@mervine.net
|
43
57
|
executables: []
|
@@ -83,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
97
|
version: '0'
|
84
98
|
requirements: []
|
85
99
|
rubyforge_project:
|
86
|
-
rubygems_version: 2.
|
100
|
+
rubygems_version: 2.5.1
|
87
101
|
signing_key:
|
88
102
|
specification_version: 4
|
89
103
|
summary: A Rest Client For MaxCDN Rest Web Services
|