exception_notification-idobata 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa728904929bc8fd75fa221be571995ebf26df70
|
4
|
+
data.tar.gz: 6301680b8f61911bcc20f861fdd3dc0819a83a15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec84b599dd603518eccfed4e2b4bb684478d7bd0892f6ad18be6bab59d940114574ebf19391496676e98eb42450ce518a2ddd04ebba67f466009e2470a1ddc25
|
7
|
+
data.tar.gz: cab5440ad2d3754ecc3ebaad6846a411a1133ecb74633244537729596b86b8bcc156652779ee573f7b5019064478414682a33f8a732e018bf937f6d8df04bb87
|
@@ -7,7 +7,7 @@ module ExceptionNotifier
|
|
7
7
|
attr_reader :url
|
8
8
|
|
9
9
|
def initialize(options)
|
10
|
-
@options = extract_global_options(options, :url, :skip_library_backtrace)
|
10
|
+
@options = extract_global_options(options, :url, :skip_library_backtrace, :proxy)
|
11
11
|
|
12
12
|
raise(ArgumentError, 'Endpoint must be specified') unless @url
|
13
13
|
end
|
@@ -23,11 +23,28 @@ module ExceptionNotifier
|
|
23
23
|
|
24
24
|
source = build_message(exception, enviroments)
|
25
25
|
|
26
|
-
|
26
|
+
http_client.post_form URI.parse(url), source: source, format: :html
|
27
27
|
end
|
28
28
|
|
29
29
|
private
|
30
30
|
|
31
|
+
def http_client
|
32
|
+
@proxy ? Net::HTTP.Proxy(*extract_proxy_settings(@proxy)) : Net::HTTP
|
33
|
+
end
|
34
|
+
|
35
|
+
def extract_proxy_settings(proxy)
|
36
|
+
case proxy
|
37
|
+
when String
|
38
|
+
extract_proxy_settings(URI(proxy))
|
39
|
+
when URI
|
40
|
+
[proxy.host, proxy.port]
|
41
|
+
when Hash
|
42
|
+
proxy.values_at(:host, :port)
|
43
|
+
else
|
44
|
+
proxy
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
31
48
|
def extract_global_options(options, *global_option_names)
|
32
49
|
options.dup.tap do |opts|
|
33
50
|
global_option_names.each {|name| instance_variable_set "@#{name}", opts.delete(name) }
|
@@ -74,4 +74,46 @@ describe ExceptionNotifier::IdobataNotifier do
|
|
74
74
|
</table>
|
75
75
|
HTML
|
76
76
|
end
|
77
|
+
|
78
|
+
describe '#http_client' do
|
79
|
+
let(:proxy) { raise NotImplementedError }
|
80
|
+
let(:notifier) do
|
81
|
+
ExceptionNotifier::IdobataNotifier.new(
|
82
|
+
:url => 'https://idobata.io/hook/endpoint',
|
83
|
+
:proxy => proxy,
|
84
|
+
)
|
85
|
+
end
|
86
|
+
|
87
|
+
subject(:http_client) { notifier.send(:http_client) }
|
88
|
+
|
89
|
+
context ':proxy is a url string' do
|
90
|
+
let(:proxy) { 'http://proxy-address:8080/' }
|
91
|
+
|
92
|
+
it { expect(http_client).to be_proxy_class }
|
93
|
+
it { expect(http_client.proxy_address).to eq 'proxy-address' }
|
94
|
+
it { expect(http_client.proxy_port).to eq 8080 }
|
95
|
+
end
|
96
|
+
|
97
|
+
context ':proxy is a URI object' do
|
98
|
+
let(:proxy) { URI('http://proxy-address:8080/') }
|
99
|
+
|
100
|
+
it { expect(http_client).to be_proxy_class }
|
101
|
+
it { expect(http_client.proxy_address).to eq 'proxy-address' }
|
102
|
+
it { expect(http_client.proxy_port).to eq 8080 }
|
103
|
+
end
|
104
|
+
|
105
|
+
context ':proxy is a Hash object' do
|
106
|
+
let(:proxy) { {host: 'proxy-address', port: 8080} }
|
107
|
+
|
108
|
+
it { expect(http_client).to be_proxy_class }
|
109
|
+
it { expect(http_client.proxy_address).to eq 'proxy-address' }
|
110
|
+
it { expect(http_client.proxy_port).to eq 8080 }
|
111
|
+
end
|
112
|
+
|
113
|
+
context ':proxy is nil' do
|
114
|
+
let(:proxy) { nil }
|
115
|
+
|
116
|
+
it { expect(http_client).to_not be_proxy_class }
|
117
|
+
end
|
118
|
+
end
|
77
119
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exception_notification-idobata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hiroshi Yoshida
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: exception_notification
|