File tree 4 files changed +25
-5
lines changed 4 files changed +25
-5
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,11 @@ language: ruby
2
2
dist : xenial
3
3
cache : bundler
4
4
5
+ addons :
6
+ apt :
7
+ packages :
8
+ - squid
9
+
5
10
matrix :
6
11
include :
7
12
- rvm : 2.4
@@ -13,6 +18,9 @@ matrix:
13
18
env : JRUBY_OPTS="--debug -X+O"
14
19
- rvm : truffleruby
15
20
- rvm : ruby-head
21
+ - rvm : 2.6
22
+ env : CLOUDFLARE_PROXY=http://localhost:3128
23
+ before_script : sudo service squid start
16
24
allow_failures :
17
25
- rvm : ruby-head
18
26
- rvm : jruby-head
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
22
22
spec . required_ruby_version = '>= 2.0.0'
23
23
24
- spec . add_dependency 'async-rest' , '~> 0.9 .0'
24
+ spec . add_dependency 'async-rest' , '~> 0.10 .0'
25
25
26
26
spec . add_development_dependency 'async-rspec'
27
27
Original file line number Diff line number Diff line change 25
25
require_relative 'cloudflare/connection'
26
26
27
27
module Cloudflare
28
- DEFAULT_URL = 'https://api.cloudflare.com/client/v4'
28
+ DEFAULT_ENDPOINT = Async :: HTTP :: Endpoint . parse ( 'https://api.cloudflare.com/client/v4' )
29
29
30
- def self . connect ( key : nil , email : nil )
31
- representation = Connection . for ( DEFAULT_URL )
30
+ def self . connect ( endpoint = DEFAULT_ENDPOINT , key : nil , email : nil )
31
+ representation = Connection . for ( endpoint )
32
32
33
33
if key
34
34
representation = representation . authenticated ( key , email )
Original file line number Diff line number Diff line change 21
21
# THE SOFTWARE.
22
22
23
23
require 'async/rspec'
24
+ require 'async/http/proxy'
25
+
24
26
require_relative '../../cloudflare'
25
27
26
28
module Cloudflare
@@ -35,10 +37,20 @@ module Connection
35
37
let ( :email ) { ENV [ 'CLOUDFLARE_EMAIL' ] }
36
38
let ( :key ) { ENV [ 'CLOUDFLARE_KEY' ] }
37
39
38
- let ( :connection ) { @connection = Cloudflare . connect ( key : key , email : email ) }
40
+ let ( :connection ) do
41
+ if proxy_url = ENV [ 'CLOUDFLARE_PROXY' ]
42
+ proxy_endpoint = Async ::HTTP ::Endpoint . parse ( proxy_url )
43
+ @proxy = Async ::HTTP ::Proxy . new ( proxy_endpoint )
44
+ @connection = Cloudflare . connect ( proxy . endpoint ( DEFAULT_ENDPOINT . url ) , key : key , email : email )
45
+ else
46
+ @proxy = nil
47
+ @connection = Cloudflare . connect ( key : key , email : email )
48
+ end
49
+ end
39
50
40
51
after do
41
52
@connection &.close
53
+ @proxy &.close
42
54
end
43
55
end
44
56
end
You can’t perform that action at this time.
0 commit comments