slack_tsuribari 0.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 +7 -0
- data/.github/workflows/ruby.yml +24 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.rubocop.yml +37 -0
- data/CHANGELOG.md +4 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +125 -0
- data/Rakefile +6 -0
- data/bin/console +11 -0
- data/bin/setup +8 -0
- data/lib/slack_tsuribari.rb +6 -0
- data/lib/slack_tsuribari/angler.rb +27 -0
- data/lib/slack_tsuribari/connection.rb +31 -0
- data/lib/slack_tsuribari/hook.rb +80 -0
- data/lib/slack_tsuribari/version.rb +5 -0
- data/slack_tsuribari.gemspec +29 -0
- metadata +131 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 27b61f76c23e7c65fae3944fd22612fe4638bd770c6d64240c12a2754248cbd1
|
|
4
|
+
data.tar.gz: adbcafd65c338a0478387008cdb8f0e4af7839657034236a610a02d1ed843c28
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: fa659bd30956fb58fbf26eb8e1f9bfd95c5ea114e1a15ba5f05e47d98bf11fa84833e5fe3e9734621c3d2ff451144ab4a13de51526a7871e580a9b05c52cdfd2
|
|
7
|
+
data.tar.gz: 96dc2d0b186cd2a1554f9f0ad6175f6949658ed420d05ef98eb15faab736a6d8aae85f5552ea37c40ff92ee061769d0b3727f551adb8e22ad47c9391910f67b8
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
name: gem test
|
|
2
|
+
|
|
3
|
+
on: [push, pull_request]
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
|
|
7
|
+
build:
|
|
8
|
+
runs-on: ubuntu-latest
|
|
9
|
+
strategy:
|
|
10
|
+
matrix:
|
|
11
|
+
ruby: [ '2.5.7', '2.6.5', '2.7.0' ]
|
|
12
|
+
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v1
|
|
15
|
+
|
|
16
|
+
- name: Set up Ruby version
|
|
17
|
+
uses: actions/setup-ruby@master
|
|
18
|
+
with:
|
|
19
|
+
ruby-version: ${{ matrix.ruby }}
|
|
20
|
+
|
|
21
|
+
- run: gem install bundler --no-document
|
|
22
|
+
- run: bundle install --jobs 4 --retry 3
|
|
23
|
+
- run: bundle exec rake spec
|
|
24
|
+
- run: bundle exec rubocop
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
AllCops:
|
|
2
|
+
Exclude:
|
|
3
|
+
- "slack_tsuribari.gemspec"
|
|
4
|
+
- "Gemfile"
|
|
5
|
+
- "Rakefile"
|
|
6
|
+
- "bin/*"
|
|
7
|
+
- "slack_tsuribari/version.rb"
|
|
8
|
+
- "spec/spec_helper.rb"
|
|
9
|
+
|
|
10
|
+
Style/Documentation:
|
|
11
|
+
Enabled: false
|
|
12
|
+
|
|
13
|
+
Metrics/AbcSize:
|
|
14
|
+
Max: 20
|
|
15
|
+
|
|
16
|
+
Layout/LineLength:
|
|
17
|
+
Max: 120
|
|
18
|
+
|
|
19
|
+
Metrics/MethodLength:
|
|
20
|
+
Enabled: false
|
|
21
|
+
|
|
22
|
+
Metrics/BlockLength:
|
|
23
|
+
Exclude:
|
|
24
|
+
- 'spec/**/*'
|
|
25
|
+
|
|
26
|
+
Metrics/ParameterLists:
|
|
27
|
+
Enabled: false
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
Style/HashEachMethods:
|
|
31
|
+
Enabled: false
|
|
32
|
+
|
|
33
|
+
Style/HashTransformKeys:
|
|
34
|
+
Enabled: false
|
|
35
|
+
|
|
36
|
+
Style/HashTransformValues:
|
|
37
|
+
Enabled: false
|
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
|
10
|
+
orientation.
|
|
11
|
+
|
|
12
|
+
## Our Standards
|
|
13
|
+
|
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
|
15
|
+
include:
|
|
16
|
+
|
|
17
|
+
* Using welcoming and inclusive language
|
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
|
19
|
+
* Gracefully accepting constructive criticism
|
|
20
|
+
* Focusing on what is best for the community
|
|
21
|
+
* Showing empathy towards other community members
|
|
22
|
+
|
|
23
|
+
Examples of unacceptable behavior by participants include:
|
|
24
|
+
|
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
+
advances
|
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
+
* Public or private harassment
|
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
|
30
|
+
address, without explicit permission
|
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
+
professional setting
|
|
33
|
+
|
|
34
|
+
## Our Responsibilities
|
|
35
|
+
|
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
+
response to any instances of unacceptable behavior.
|
|
39
|
+
|
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
+
threatening, offensive, or harmful.
|
|
45
|
+
|
|
46
|
+
## Scope
|
|
47
|
+
|
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
+
when an individual is representing the project or its community. Examples of
|
|
50
|
+
representing a project or community include using an official project e-mail
|
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
|
53
|
+
further defined and clarified by project maintainers.
|
|
54
|
+
|
|
55
|
+
## Enforcement
|
|
56
|
+
|
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
+
reported by contacting the project team at nekosatoru@gmail.com. All
|
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
|
63
|
+
|
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
+
members of the project's leadership.
|
|
67
|
+
|
|
68
|
+
## Attribution
|
|
69
|
+
|
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
|
72
|
+
|
|
73
|
+
[homepage]: http://contributor-covenant.org
|
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 nekomaho
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# SlackTsuribari
|
|
2
|
+
SlackTsuribari is a Slack Incoming Webhook wrapper for ruby.
|
|
3
|
+
|
|
4
|
+
## Installation
|
|
5
|
+
|
|
6
|
+
Add this line to your application's Gemfile:
|
|
7
|
+
|
|
8
|
+
```ruby
|
|
9
|
+
gem 'slack_tsuribari'
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
And then execute:
|
|
13
|
+
|
|
14
|
+
$ bundle
|
|
15
|
+
|
|
16
|
+
Or install it yourself as:
|
|
17
|
+
|
|
18
|
+
$ gem install slack_tsuribari
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
To post a message to a slack an easy way, create a hook object and send data with Angler.easy_throw!.
|
|
22
|
+
```ruby
|
|
23
|
+
hook = SlackTsuribari::Hook.config('https://hooks.slack.com/services/webhook_url')
|
|
24
|
+
SlackTsuribari::Angler.easy_throw!(hook, 'test message')
|
|
25
|
+
```
|
|
26
|
+
Use Angler.throw! If you need a bit more control, like adding color.
|
|
27
|
+
|
|
28
|
+
```ruby
|
|
29
|
+
hook = SlackTsuribari::Hook.config('https://hooks.slack.com/services/webhook_url')
|
|
30
|
+
payload = {
|
|
31
|
+
attachments: [
|
|
32
|
+
fallback: 'test message',
|
|
33
|
+
text: 'test message',
|
|
34
|
+
color: '#00FF00',
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
SlackTsuribari::Angler.throw!(hook, payload)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
The second argument of throw! can specify the payload of slack's Incoming Webhook.
|
|
41
|
+
See Setup Instructions of Incoming Webhook and [Adding secondary attachment](https://api.slack.com/messaging/composing/layouts#attachments)
|
|
42
|
+
for arguments that can be specified in the payload.
|
|
43
|
+
|
|
44
|
+
### proxy setting
|
|
45
|
+
If a proxy is needed, it can be configured as follows
|
|
46
|
+
|
|
47
|
+
```ruby
|
|
48
|
+
hook = SlackTsuribari::Hook.config do |config|
|
|
49
|
+
config.uri = 'https://hooks.slack.com/services/webhook_url'
|
|
50
|
+
config.proxy_addr = '127.0.0.1'
|
|
51
|
+
config.proxy_port = 8080
|
|
52
|
+
config.proxy_user = 'test'
|
|
53
|
+
config.proxy_pass = 'password'
|
|
54
|
+
config.no_proxy = '192.168.1.1'
|
|
55
|
+
end
|
|
56
|
+
SlackTsuribari::Angler.easy_throw!(hook, 'test message')
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### pre payload setting
|
|
60
|
+
In config you can also set the `channel`, `username`, `text` and icon to post.
|
|
61
|
+
The `channel` is set when you change the channel to post.
|
|
62
|
+
```ruby
|
|
63
|
+
hook = SlackTsuribari::Hook.config do |config|
|
|
64
|
+
config.uri = 'https://hooks.slack.com/services/webhook_url'
|
|
65
|
+
config.pre_payload.channel = 'sample_channel'
|
|
66
|
+
end
|
|
67
|
+
SlackTsuribari::Angler.easy_throw!(hook, 'test message')
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
The `username` allows you to change the name of the post.
|
|
71
|
+
```ruby
|
|
72
|
+
hook = SlackTsuribari::Hook.config do |config|
|
|
73
|
+
config.uri = 'https://hooks.slack.com/services/webhook_url'
|
|
74
|
+
config.pre_payload.username = 'Robot'
|
|
75
|
+
end
|
|
76
|
+
SlackTsuribari::Angler.easy_throw!(hook, 'test message')
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
The `text` allows you to set the text to be posted. If text is specified with `easy_throw!` or `throw!`, its setting is preferred.
|
|
80
|
+
```ruby
|
|
81
|
+
hook = SlackTsuribari::Hook.config do |config|
|
|
82
|
+
config.uri = 'https://hooks.slack.com/services/webhook_url'
|
|
83
|
+
config.pre_payload.text = 'pre payload text'
|
|
84
|
+
end
|
|
85
|
+
SlackTsuribari::Angler.easy_throw!(hook) # => throw 'pre payload text'
|
|
86
|
+
SlackTsuribari::Angler.throw!(hook) # => throw 'pre payload text'
|
|
87
|
+
|
|
88
|
+
SlackTsuribari::Angler.easy_throw!(hook, 'text') # => throw 'text'
|
|
89
|
+
SlackTsuribari::Angler.throw!(hook, {text: 'text'}) # => throw 'text'
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
If you want to set an icon, put a value in either `icon_url` or `icon_emoji`.
|
|
93
|
+
The `icon_url` is the URL of the icon.
|
|
94
|
+
The `icon_emoji` is the text of the emoji to be set for the icon.
|
|
95
|
+
```ruby
|
|
96
|
+
hook = SlackTsuribari::Hook.config do |config|
|
|
97
|
+
config.uri = 'https://hooks.slack.com/services/webhook_url'
|
|
98
|
+
config.pre_payload.icon_url = 'path to icon url'
|
|
99
|
+
end
|
|
100
|
+
SlackTsuribari::Angler.easy_throw!(hook, 'test message')
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
```ruby
|
|
104
|
+
hook = SlackTsuribari::Hook.config do |config|
|
|
105
|
+
config.uri = 'https://hooks.slack.com/services/webhook_url'
|
|
106
|
+
config.pre_payload.icon_emoji = ':+1:'
|
|
107
|
+
end
|
|
108
|
+
SlackTsuribari::Angler.easy_throw!(hook, 'test message')
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Development
|
|
112
|
+
|
|
113
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
114
|
+
|
|
115
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
116
|
+
|
|
117
|
+
## Contributing
|
|
118
|
+
|
|
119
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/nekomaho/slack-tsuribari. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
## License
|
|
123
|
+
|
|
124
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
|
125
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "slack_tsuribari"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
require "pry"
|
|
11
|
+
Pry.start
|
data/bin/setup
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'slack_tsuribari/connection'
|
|
4
|
+
|
|
5
|
+
module SlackTsuribari
|
|
6
|
+
module Angler
|
|
7
|
+
class << self
|
|
8
|
+
def easy_throw!(hook, message = nil)
|
|
9
|
+
payload = message.nil? ? nil : { text: message }
|
|
10
|
+
throw_action(hook, payload, true)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def throw!(hook, payload = nil)
|
|
14
|
+
throw_action(hook, payload, true)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
private
|
|
18
|
+
|
|
19
|
+
def throw_action(hook, payload, auto_detach)
|
|
20
|
+
hook.attach(payload)
|
|
21
|
+
Connection.new(hook.uri, hook.proxy_setting).post(hook.payload_to_json).tap do
|
|
22
|
+
hook.detach if auto_detach
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'net/http'
|
|
4
|
+
|
|
5
|
+
module SlackTsuribari
|
|
6
|
+
class Connection
|
|
7
|
+
attr_reader :scheme, :host, :port, :path
|
|
8
|
+
attr_reader :proxy_addr, :proxy_port, :proxy_user, :proxy_pass, :no_proxy
|
|
9
|
+
|
|
10
|
+
def initialize(uri, options = {})
|
|
11
|
+
URI.parse(uri).tap do |parse_uri|
|
|
12
|
+
@scheme = parse_uri.scheme
|
|
13
|
+
@host = parse_uri.host
|
|
14
|
+
@path = parse_uri.path
|
|
15
|
+
@port = parse_uri.port
|
|
16
|
+
end
|
|
17
|
+
@proxy_addr = options[:proxy_addr] || :ENV
|
|
18
|
+
@proxy_port = options[:proxy_port] || nil
|
|
19
|
+
@proxy_user = options[:proxy_user] || nil
|
|
20
|
+
@proxy_pass = options[:proxy_pass] || nil
|
|
21
|
+
@no_proxy = options[:no_proxy] || nil
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def post(data, header = { 'Content-Type' => 'application/json' })
|
|
25
|
+
Net::HTTP.new(host, port, proxy_addr, proxy_port, proxy_user, proxy_pass, no_proxy).yield_self do |http|
|
|
26
|
+
http.use_ssl = scheme == 'https'
|
|
27
|
+
http.post(path, data, header)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'json'
|
|
4
|
+
|
|
5
|
+
module SlackTsuribari
|
|
6
|
+
class Hook
|
|
7
|
+
PrePayload = Struct.new(:channel, :username, :text, :icon_url, :icon_emoji) do
|
|
8
|
+
def to_h
|
|
9
|
+
%I[channel username text icon_url icon_emoji].each_with_object({}) do |attr, hash|
|
|
10
|
+
hash[attr] = send(attr) unless send(attr).nil?
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def nil?
|
|
15
|
+
%I[channel username text icon_url icon_emoji].all? { |attr| send(attr).nil? }
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
Config = Struct.new(
|
|
20
|
+
:uri,
|
|
21
|
+
:proxy_addr,
|
|
22
|
+
:proxy_port,
|
|
23
|
+
:proxy_user,
|
|
24
|
+
:proxy_pass,
|
|
25
|
+
:no_proxy,
|
|
26
|
+
:pre_payload,
|
|
27
|
+
keyword_init: true
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
class << self
|
|
31
|
+
def config(uri = nil)
|
|
32
|
+
config = Config.new(pre_payload: PrePayload.new)
|
|
33
|
+
|
|
34
|
+
if block_given?
|
|
35
|
+
yield(config)
|
|
36
|
+
else
|
|
37
|
+
config.uri = uri
|
|
38
|
+
end
|
|
39
|
+
new(config)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
class NoPayloadError < StandardError; end
|
|
44
|
+
|
|
45
|
+
attr_reader :config, :payload
|
|
46
|
+
|
|
47
|
+
def initialize(config)
|
|
48
|
+
@config = config
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def uri
|
|
52
|
+
config.uri
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def proxy_setting
|
|
56
|
+
{
|
|
57
|
+
proxy_addr: config.proxy_addr,
|
|
58
|
+
proxy_port: config.proxy_port,
|
|
59
|
+
proxy_user: config.proxy_user,
|
|
60
|
+
proxy_pass: config.proxy_pass,
|
|
61
|
+
no_proxy: config.no_proxy
|
|
62
|
+
}
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def payload_to_json
|
|
66
|
+
payload.to_json
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def attach(payload)
|
|
70
|
+
return @payload if !@payload.nil? && payload.nil? # when not detached and new payload is nil
|
|
71
|
+
raise NoPayloadError if payload.nil? && config.pre_payload.nil?
|
|
72
|
+
|
|
73
|
+
@payload = config.pre_payload.to_h.merge(payload.nil? ? {} : payload)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def detach
|
|
77
|
+
@payload = nil
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'slack_tsuribari/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "slack_tsuribari"
|
|
8
|
+
spec.version = SlackTsuribari::VERSION
|
|
9
|
+
spec.authors = ["nekomaho"]
|
|
10
|
+
spec.email = ["nekosatoru@gmail.com"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{This gem can post messages to the channel using slack's incoming webhook.}
|
|
13
|
+
spec.description = %q{A gem to help post to slack using webhook}
|
|
14
|
+
spec.homepage = "https://github.com/nekomaho/slack-tsuribari"
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
|
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
|
19
|
+
end
|
|
20
|
+
spec.bindir = "exe"
|
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
22
|
+
spec.require_paths = ["lib"]
|
|
23
|
+
|
|
24
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
|
25
|
+
spec.add_development_dependency "rake", "~> 12.0"
|
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
27
|
+
spec.add_development_dependency "rubocop", "< 1.0"
|
|
28
|
+
spec.add_development_dependency "pry"
|
|
29
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: slack_tsuribari
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- nekomaho
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2020-03-28 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '2.0'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '2.0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '12.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '12.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rspec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '3.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rubocop
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "<"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '1.0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "<"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '1.0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: pry
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
description: A gem to help post to slack using webhook
|
|
84
|
+
email:
|
|
85
|
+
- nekosatoru@gmail.com
|
|
86
|
+
executables: []
|
|
87
|
+
extensions: []
|
|
88
|
+
extra_rdoc_files: []
|
|
89
|
+
files:
|
|
90
|
+
- ".github/workflows/ruby.yml"
|
|
91
|
+
- ".gitignore"
|
|
92
|
+
- ".rspec"
|
|
93
|
+
- ".rubocop.yml"
|
|
94
|
+
- CHANGELOG.md
|
|
95
|
+
- CODE_OF_CONDUCT.md
|
|
96
|
+
- Gemfile
|
|
97
|
+
- LICENSE.txt
|
|
98
|
+
- README.md
|
|
99
|
+
- Rakefile
|
|
100
|
+
- bin/console
|
|
101
|
+
- bin/setup
|
|
102
|
+
- lib/slack_tsuribari.rb
|
|
103
|
+
- lib/slack_tsuribari/angler.rb
|
|
104
|
+
- lib/slack_tsuribari/connection.rb
|
|
105
|
+
- lib/slack_tsuribari/hook.rb
|
|
106
|
+
- lib/slack_tsuribari/version.rb
|
|
107
|
+
- slack_tsuribari.gemspec
|
|
108
|
+
homepage: https://github.com/nekomaho/slack-tsuribari
|
|
109
|
+
licenses:
|
|
110
|
+
- MIT
|
|
111
|
+
metadata: {}
|
|
112
|
+
post_install_message:
|
|
113
|
+
rdoc_options: []
|
|
114
|
+
require_paths:
|
|
115
|
+
- lib
|
|
116
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
117
|
+
requirements:
|
|
118
|
+
- - ">="
|
|
119
|
+
- !ruby/object:Gem::Version
|
|
120
|
+
version: '0'
|
|
121
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
|
+
requirements:
|
|
123
|
+
- - ">="
|
|
124
|
+
- !ruby/object:Gem::Version
|
|
125
|
+
version: '0'
|
|
126
|
+
requirements: []
|
|
127
|
+
rubygems_version: 3.1.2
|
|
128
|
+
signing_key:
|
|
129
|
+
specification_version: 4
|
|
130
|
+
summary: This gem can post messages to the channel using slack's incoming webhook.
|
|
131
|
+
test_files: []
|