fastly 2.2.0 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +4 -4
- data/lib/fastly.rb +0 -2
- data/lib/fastly/client.rb +34 -20
- data/lib/fastly/gem_version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 77c4d6df5e0621d48acdbecb30dd4245dbcacc9225ca5485a3da71871108a006
|
4
|
+
data.tar.gz: 232962c9bb9513d029cb23ae84e066a64b1238d5fe03c3ef0612d9bf946ade1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa2ad393f31e11794e9e8bc900583793ef301c84bceb07d7eaa68440f4ebf880de0d748290e2bfc09a113e007294f0fbb44f164895f40e1ab7c0c43450da33a1
|
7
|
+
data.tar.gz: 82ba77b6314b2ffdebbfde260a121664a4b2687e9ad2e2f7950fd267278f3037dc33a6358e5d5d8a6b0998d4f8a6e3ea59a12b8b1e91d23dd186be66a56df8be
|
data/.travis.yml
CHANGED
@@ -3,11 +3,11 @@ script: 'bundle exec rake test:unit'
|
|
3
3
|
sudo: false
|
4
4
|
matrix:
|
5
5
|
include:
|
6
|
-
- rvm: 2.
|
6
|
+
- rvm: 2.3.8
|
7
7
|
gemfile: gemfiles/HEAD.gemfile
|
8
|
-
- rvm: 2.
|
8
|
+
- rvm: 2.4.5
|
9
9
|
gemfile: gemfiles/HEAD.gemfile
|
10
|
-
- rvm: 2.3
|
10
|
+
- rvm: 2.5.3
|
11
11
|
gemfile: gemfiles/HEAD.gemfile
|
12
|
-
- rvm: 2.
|
12
|
+
- rvm: 2.6.0
|
13
13
|
gemfile: gemfiles/HEAD.gemfile
|
data/lib/fastly.rb
CHANGED
@@ -80,9 +80,7 @@ class Fastly
|
|
80
80
|
end
|
81
81
|
|
82
82
|
# Return a User object representing the current logged in user.
|
83
|
-
# NOTE: requires you to be fully authed - will not work with only an API key
|
84
83
|
def current_user
|
85
|
-
fail FullAuthRequired unless fully_authed?
|
86
84
|
@current_user ||= get(User)
|
87
85
|
end
|
88
86
|
|
data/lib/fastly/client.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'json'
|
2
4
|
require 'cgi'
|
3
5
|
require 'net/http' # also requires uri
|
@@ -9,28 +11,19 @@ class Fastly
|
|
9
11
|
|
10
12
|
DEFAULT_URL = 'https://api.fastly.com'.freeze
|
11
13
|
|
12
|
-
attr_accessor :
|
14
|
+
attr_accessor :api_key, :base_url, :debug, :user, :password, :cookie, :customer
|
13
15
|
|
14
16
|
def initialize(opts)
|
15
|
-
@api_key
|
16
|
-
@
|
17
|
-
@
|
18
|
-
@
|
19
|
-
@
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
# handle TLS connections outside of development
|
27
|
-
@http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
28
|
-
@http.use_ssl = uri.scheme.downcase == 'https'
|
29
|
-
|
30
|
-
# debug http interactions if specified
|
31
|
-
@http.set_debug_output(opts[:debug]) if opts[:debug]
|
32
|
-
|
33
|
-
@http.start
|
17
|
+
@api_key = opts.fetch(:api_key, nil)
|
18
|
+
@base_url = opts.fetch(:base_url, DEFAULT_URL)
|
19
|
+
@customer = opts.fetch(:customer, nil)
|
20
|
+
@oldpurge = opts.fetch(:use_old_purge_method, false)
|
21
|
+
@password = opts.fetch(:password, nil)
|
22
|
+
@user = opts.fetch(:user, nil)
|
23
|
+
@debug = opts.fetch(:debug, nil)
|
24
|
+
@thread_http_client = if defined?(Concurrent::ThreadLocalVar)
|
25
|
+
Concurrent::ThreadLocalVar.new { build_http_client }
|
26
|
+
end
|
34
27
|
|
35
28
|
return self unless fully_authed?
|
36
29
|
|
@@ -114,8 +107,29 @@ class Fastly
|
|
114
107
|
JSON.parse(resp.body)
|
115
108
|
end
|
116
109
|
|
110
|
+
def http
|
111
|
+
return @thread_http_client.value if @thread_http_client
|
112
|
+
return Thread.current[:fastly_net_http] if Thread.current[:fastly_net_http]
|
113
|
+
|
114
|
+
Thread.current[:fastly_net_http] = build_http_client
|
115
|
+
end
|
116
|
+
|
117
117
|
private
|
118
118
|
|
119
|
+
def build_http_client
|
120
|
+
uri = URI.parse(base_url)
|
121
|
+
net_http = Net::HTTP.new(uri.host, uri.port, :ENV, nil, nil, nil)
|
122
|
+
|
123
|
+
# handle TLS connections outside of development
|
124
|
+
net_http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
125
|
+
net_http.use_ssl = uri.scheme.downcase == 'https'
|
126
|
+
|
127
|
+
# debug http interactions if specified
|
128
|
+
net_http.set_debug_output(debug) if debug
|
129
|
+
|
130
|
+
net_http
|
131
|
+
end
|
132
|
+
|
119
133
|
def post_and_put(method, path, params = {})
|
120
134
|
extras = params.delete(:headers) || {}
|
121
135
|
query = make_params(params)
|
data/lib/fastly/gem_version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fastly
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Client library for the Fastly acceleration system
|
14
14
|
email:
|
@@ -106,8 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
106
|
- !ruby/object:Gem::Version
|
107
107
|
version: '0'
|
108
108
|
requirements: []
|
109
|
-
|
110
|
-
rubygems_version: 2.5.2.3
|
109
|
+
rubygems_version: 3.0.1
|
111
110
|
signing_key:
|
112
111
|
specification_version: 4
|
113
112
|
summary: Client library for the Fastly acceleration system
|