dagger 2.0.0 → 2.1.1

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
  SHA256:
3
- metadata.gz: 447d77e66ec69445f5040231d19c038279d4ec7de624461deda078c544423ca9
4
- data.tar.gz: c5eb814e71fd6a37b3b4272f6f747654eeb157655dec65ae6ec6f0cf86d4e5ff
3
+ metadata.gz: 5942c147bb4bcf52ad8d1aa04cb5a44010eb15a6c85877a71b68872d745710c2
4
+ data.tar.gz: 14654c7a309a5719f0b23d136f62f67a6e995b9ac0d6dff0e697b628acf57f35
5
5
  SHA512:
6
- metadata.gz: 31108057fbc3cd1d2e0c319d4c64244c596cbbb90d8ae6067945caedb2f8f7ff5c0fd144b16be55ac24cd36bbd466f08659b995b47ecd67425d26224bd505ede
7
- data.tar.gz: d996eaefa87c30682eb127d9f2f28cbb28363fcf2a2f758e32610d553937c05a35750316f043a6f4d2a9eb6727aad8f0351ca761ee62b326313b46e902764fd2
6
+ metadata.gz: 4f71ee8900cc198365cb0ec64176b0861ebe9e8c295a407b048d6c712806f80453770f336e0b518a3f87338b34be4a110963bfb978fdaafec80b54a885d79466
7
+ data.tar.gz: ec8bc6f7f374466b4d73fdb5cca061b2cab17918818d72e28c7b03b728cdfe5328e04a79584c483a223dbec2ec767dc10a9e0e562152d561f55c24db3b08bd0e
data/dagger.gemspec CHANGED
@@ -19,8 +19,8 @@ Gem::Specification.new do |s|
19
19
  s.add_development_dependency "rspec-mocks"
20
20
  s.add_development_dependency "rspec-expectations"
21
21
 
22
- s.add_runtime_dependency "oj", "~> 2.1"
23
- s.add_runtime_dependency "ox", "~> 2.4"
22
+ s.add_runtime_dependency "oj", ">= 2.1"
23
+ s.add_runtime_dependency "ox", ">= 2.4"
24
24
 
25
25
  s.files = `git ls-files`.split("\n")
26
26
  s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
@@ -3,7 +3,7 @@ module Dagger
3
3
  class ConnectionManager
4
4
 
5
5
  def initialize(opts = {})
6
- @opts = {}
6
+ @opts = opts
7
7
  @active_connections = {}
8
8
  @mutex = Mutex.new
9
9
  end
@@ -1,7 +1,7 @@
1
1
  module Dagger
2
2
  MAJOR = 2
3
- MINOR = 0
4
- PATCH = 0
3
+ MINOR = 1
4
+ PATCH = 1
5
5
 
6
6
  VERSION = [MAJOR, MINOR, PATCH].join('.')
7
7
  end
data/lib/dagger.rb CHANGED
@@ -40,7 +40,7 @@ module Dagger
40
40
  end
41
41
 
42
42
  def self.resolve_uri(uri, host = nil, query = nil)
43
- uri = host + uri if uri[0] == '/' && host
43
+ uri = host + uri if uri.to_s[0] == '/' && host
44
44
  uri = parse_uri(uri.to_s)
45
45
  uri.path.sub!(/\?.*|$/, '?' + to_query_string(query)) if query and query.any?
46
46
  uri
@@ -91,7 +91,7 @@ module Dagger
91
91
  def self.init_connection(uri, opts = {})
92
92
  http = Net::HTTP.new(opts[:ip] || uri.host, uri.port)
93
93
 
94
- if uri.port == 443
94
+ if uri.port == 443 || uri.scheme == 'https'
95
95
  http.use_ssl = true if http.respond_to?(:use_ssl=) # persistent does it automatically
96
96
  http.verify_mode = opts[:verify_ssl] === false ? OpenSSL::SSL::VERIFY_NONE : OpenSSL::SSL::VERIFY_PEER
97
97
  end
@@ -0,0 +1,61 @@
1
+ require './lib/dagger'
2
+
3
+ require 'rspec/mocks'
4
+ require 'rspec/expectations'
5
+
6
+ describe 'Retries' do
7
+
8
+ def send_request
9
+ Dagger.get('http://foobar.com/test', opts)
10
+ end
11
+
12
+ let(:fake_http) { double('Net::HTTP', started?: true, "keep_alive_timeout=": true, "open_timeout=": true, "read_timeout=": true) }
13
+ let(:fake_resp) { double('Net::HTTPResponse', code: 200, body: 'foo') }
14
+
15
+ before do
16
+ allow(Net::HTTP).to receive(:new).at_least(:once).and_return(fake_http)
17
+ allow(fake_http).to receive(:verify_mode=).and_return(true)
18
+ end
19
+
20
+ describe 'on ECONNREFUSED' do
21
+
22
+ context 'if no retries option passed' do
23
+
24
+ let(:opts) { {} }
25
+
26
+ it 'does not retry request, and raises error' do
27
+ expect(fake_http).to receive(:request).once.and_raise(Errno::ECONNREFUSED)
28
+ expect { send_request }.to raise_error(Errno::ECONNREFUSED)
29
+ end
30
+
31
+ end
32
+
33
+ context 'if retries is 1' do
34
+
35
+ let(:opts) { { retries: 1, retry_wait: 1 } }
36
+
37
+ context 'and it still fails' do
38
+
39
+ it 'sends a second request, and raises error' do
40
+ expect(fake_http).to receive(:request).twice.and_raise(Errno::ECONNREFUSED)
41
+ expect { send_request }.to raise_error(Errno::ECONNREFUSED)
42
+ end
43
+
44
+ end
45
+
46
+ context 'and then it works' do
47
+
48
+ it 'sends a second request, and does not raise error' do
49
+ expect(fake_http).to receive(:request).once.and_raise(Errno::ECONNREFUSED)
50
+ expect(fake_http).to receive(:request).once.and_return(fake_resp)
51
+ allow(fake_resp).to receive(:[]).with('Content-Type').and_return('text/plain')
52
+
53
+ expect(send_request.body).to eq('foo')
54
+ end
55
+
56
+ end
57
+
58
+ end
59
+
60
+ end
61
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dagger
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomás Pollak
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-24 00:00:00.000000000 Z
11
+ date: 2023-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -70,28 +70,28 @@ dependencies:
70
70
  name: oj
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '2.1'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '2.1'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: ox
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '2.4'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '2.4'
97
97
  description: Dagger.post(url, params).body
@@ -120,6 +120,7 @@ files:
120
120
  - spec/ip_connect_spec.rb
121
121
  - spec/parsers_spec.rb
122
122
  - spec/persistent_spec.rb
123
+ - spec/retries_spec.rb
123
124
  - spec/sending_data_spec.rb
124
125
  homepage: https://github.com/tomas/dagger
125
126
  licenses: []
@@ -139,8 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
140
  - !ruby/object:Gem::Version
140
141
  version: 1.3.6
141
142
  requirements: []
142
- rubyforge_project: dagger
143
- rubygems_version: 2.7.3
143
+ rubygems_version: 3.4.6
144
144
  signing_key:
145
145
  specification_version: 4
146
146
  summary: Simplified Net::HTTP wrapper.