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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d567c5be45aad2ecdd920d497b14745ec925bec8
4
- data.tar.gz: f3dfe98f23eb417f021b3b040f0390683dcfac00
3
+ metadata.gz: c94f389d66d158ba77d68022369bfc8c913ca04a
4
+ data.tar.gz: 91ca67962bbb188f27a81dbfb7f96c96cf1b831c
5
5
  SHA512:
6
- metadata.gz: a11ce6b0f103a2ba7d0ed2922346658dabbc340d16e133c64d42ecc9fea508ac58801660f7f25d6e22d1ddf0d420789b314a9aafc4d7d1614e1e0ca4a8515b0a
7
- data.tar.gz: 36d70193078ab28a413f199074958bef2338afb0493ec3221259d1c7d45135c95bef8dad77e2405c104b346d674930ffd8b1f5e901133be379528e68053d3fb5
6
+ metadata.gz: ae8140863edc58d8ac5f8d4af47d5af918d8e1f75f7b392e40cec9d5330a0252605b2dc1586d0eb7cf7bb9f63a73c8351493412d3b9b4894ca73e2329e4e14c5
7
+ data.tar.gz: ce93ce746a2bc04633a5d14b5f4bb77115959c190146ebe1fef0bded5df2b5c8c93b886130bbd275de3717e4b47f79a01348db64955c91b023402d72e7389aa6
@@ -1,6 +1,9 @@
1
1
  language: ruby
2
2
  script: bundle exec rake test
3
+ sudo: false
4
+ before_install:
5
+ - gem update bundler
3
6
  rvm:
4
- - 1.9.3
5
- - 2.1.2
6
- - 2.2.1
7
+ - 1
8
+ - 2
9
+ - 3
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 for underlying Curl::Easy and CurbFu modules
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.
@@ -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.delete(:headers) || {}
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
- curb_opts = {
64
- :url => req_opts[:uri],
65
- :headers => request.headers
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
- # Second, set 'Content-Type' to our desired value.
80
- curb.headers["Content-Type"] = content_type
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? or response.redirect?
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
@@ -1,3 +1,3 @@
1
1
  module MaxCDN
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -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.5.1'
17
- gem.add_dependency 'curb-fu', '~> 0.6.2'
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
@@ -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(CurbFu::Response::Base, res.class)
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.2.1
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: 2015-05-20 00:00:00.000000000 Z
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.5.1
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.5.1
26
+ version: '0.7'
27
27
  - !ruby/object:Gem::Dependency
28
- name: curb-fu
28
+ name: faraday
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.6.2
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.6.2
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.2.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