slack_tsuribari 0.1.1 → 0.2.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 +4 -4
- data/CHANGELOG.md +16 -0
- data/lib/slack_tsuribari/angler.rb +3 -3
- data/lib/slack_tsuribari/connection.rb +6 -1
- data/lib/slack_tsuribari/hook.rb +5 -3
- data/lib/slack_tsuribari/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 56e497a4bc1b1c809c538a6893f7d4fc8e78b56d53a034c67883fa7b464b5ff0
|
|
4
|
+
data.tar.gz: 1e3a88c6ff3df4d87f5e8b823c2686a8d184cb17b0d1d57cee67a09eb7528175
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8489f976de55e5e92497eb1b3d4a094b988180e7c8089a627bc2c4919e880de46be33b60b34cfb19add7cada1a99902a966bc40b5da14a5fa6cdedcf1c8e98ed
|
|
7
|
+
data.tar.gz: 2adea9bc419ac63771446108978ae4fdb420757f271891d12760d554146cc57b95fda2fd0e11e886ab390d4aa9d22c542b4c2589f021d949d66e02d3b73133d1
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Change log
|
|
2
2
|
|
|
3
|
+
## 0.2.0 / 2020-05-06
|
|
4
|
+
- [Add raise error when http response is not 200](https://github.com/nekomaho/slack-tsuribari/pull/4)
|
|
5
|
+
|
|
6
|
+
**BREAKING CHANGES**
|
|
7
|
+
|
|
8
|
+
From v0.2.0, if slack does not return 200 as HTTP status code, exception will be raised by default.
|
|
9
|
+
The exceptions are the same as those raised with `Net::HTTPResponse#value`.
|
|
10
|
+
If you don't want to raise the exception like the previous version, specify `raise_error: false` in config.
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
hook = SlackTsuribari::Hook.config do |config|
|
|
14
|
+
config.uri = 'uri'
|
|
15
|
+
config.raise_errror = false
|
|
16
|
+
end
|
|
17
|
+
```
|
|
18
|
+
|
|
3
19
|
## 0.1.1 / 2020-04-28
|
|
4
20
|
- [Specified the version of rubies ](https://github.com/nekomaho/slack-tsuribari/pull/3)
|
|
5
21
|
- [Use ruby/setup-ruby for CI ](https://github.com/nekomaho/slack-tsuribari/pull/2)
|
|
@@ -18,9 +18,9 @@ module SlackTsuribari
|
|
|
18
18
|
|
|
19
19
|
def throw_action(hook, payload, auto_detach)
|
|
20
20
|
hook.attach(payload)
|
|
21
|
-
Connection.new(hook.uri, hook.
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
Connection.new(hook.uri, hook.setting).post(hook.payload_to_json)
|
|
22
|
+
ensure
|
|
23
|
+
hook.detach if auto_detach
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
26
|
end
|
|
@@ -6,6 +6,7 @@ module SlackTsuribari
|
|
|
6
6
|
class Connection
|
|
7
7
|
attr_reader :scheme, :host, :port, :path
|
|
8
8
|
attr_reader :proxy_addr, :proxy_port, :proxy_user, :proxy_pass, :no_proxy
|
|
9
|
+
attr_reader :raise_error
|
|
9
10
|
|
|
10
11
|
def initialize(uri, options = {})
|
|
11
12
|
URI.parse(uri).tap do |parse_uri|
|
|
@@ -19,12 +20,16 @@ module SlackTsuribari
|
|
|
19
20
|
@proxy_user = options[:proxy_user] || nil
|
|
20
21
|
@proxy_pass = options[:proxy_pass] || nil
|
|
21
22
|
@no_proxy = options[:no_proxy] || nil
|
|
23
|
+
@raise_error = options.fetch(:raise_error, true)
|
|
22
24
|
end
|
|
23
25
|
|
|
24
26
|
def post(data, header = { 'Content-Type' => 'application/json' })
|
|
25
27
|
Net::HTTP.new(host, port, proxy_addr, proxy_port, proxy_user, proxy_pass, no_proxy).yield_self do |http|
|
|
26
28
|
http.use_ssl = scheme == 'https'
|
|
27
|
-
http.post(path, data, header)
|
|
29
|
+
http.post(path, data, header).tap do |response|
|
|
30
|
+
# value method refers to https://docs.ruby-lang.org/en/2.7.0/Net/HTTPResponse.html#method-i-value
|
|
31
|
+
response.value if raise_error
|
|
32
|
+
end
|
|
28
33
|
end
|
|
29
34
|
end
|
|
30
35
|
end
|
data/lib/slack_tsuribari/hook.rb
CHANGED
|
@@ -24,12 +24,13 @@ module SlackTsuribari
|
|
|
24
24
|
:proxy_pass,
|
|
25
25
|
:no_proxy,
|
|
26
26
|
:pre_payload,
|
|
27
|
+
:raise_error,
|
|
27
28
|
keyword_init: true
|
|
28
29
|
)
|
|
29
30
|
|
|
30
31
|
class << self
|
|
31
32
|
def config(uri = nil)
|
|
32
|
-
config = Config.new(pre_payload: PrePayload.new)
|
|
33
|
+
config = Config.new(pre_payload: PrePayload.new, raise_error: true)
|
|
33
34
|
|
|
34
35
|
if block_given?
|
|
35
36
|
yield(config)
|
|
@@ -52,13 +53,14 @@ module SlackTsuribari
|
|
|
52
53
|
config.uri
|
|
53
54
|
end
|
|
54
55
|
|
|
55
|
-
def
|
|
56
|
+
def setting
|
|
56
57
|
{
|
|
57
58
|
proxy_addr: config.proxy_addr,
|
|
58
59
|
proxy_port: config.proxy_port,
|
|
59
60
|
proxy_user: config.proxy_user,
|
|
60
61
|
proxy_pass: config.proxy_pass,
|
|
61
|
-
no_proxy: config.no_proxy
|
|
62
|
+
no_proxy: config.no_proxy,
|
|
63
|
+
raise_error: config.raise_error
|
|
62
64
|
}
|
|
63
65
|
end
|
|
64
66
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: slack_tsuribari
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- nekomaho
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-
|
|
11
|
+
date: 2020-05-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -124,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
124
124
|
- !ruby/object:Gem::Version
|
|
125
125
|
version: '0'
|
|
126
126
|
requirements: []
|
|
127
|
-
rubygems_version: 3.
|
|
127
|
+
rubygems_version: 3.1.2
|
|
128
128
|
signing_key:
|
|
129
129
|
specification_version: 4
|
|
130
130
|
summary: This gem can post messages to the channel using slack's incoming webhook.
|