slack-incoming-webhooks-ruby 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +64 -0
- data/.rspec +2 -0
- data/.travis.yml +19 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +108 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/examples/post.rb +24 -0
- data/images/attachment.png +0 -0
- data/images/field.png +0 -0
- data/images/normal.png +0 -0
- data/lib/slack-incoming-webhooks-ruby.rb +15 -0
- data/lib/slack/http/connection.rb +29 -0
- data/lib/slack/http/result.rb +13 -0
- data/lib/slack/incoming_webhooks/client.rb +13 -0
- data/lib/slack/messages/attachment.rb +39 -0
- data/lib/slack/messages/field.rb +21 -0
- data/lib/slack/messages/payload.rb +37 -0
- data/lib/slack/version.rb +3 -0
- data/slack-incoming-webhooks-ruby.gemspec +29 -0
- metadata +123 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 886b5fb87d395fdf7bd11b27e9b2b7b0a3535386
|
4
|
+
data.tar.gz: 6827c2d8a7caa6095dc41c28dbdbf7e772407e45
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c9dc74c378f48044f4928049d05d4c3e1686f0cb4862ca3c312ac57d6a28de8884fe5d400b559c7fedcf222db0f218982187c5e9a309e1ce3656a879a15721d3
|
7
|
+
data.tar.gz: 25f9417ae2ee65af07af27b4ea15caa27c5f16ccede49c425366dcf416367bb3064d311031bc5e47c7a5efd288a51b37057f5240cba359d861510d158b2b48c8
|
data/.gitignore
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# for a library or gem, you might want to ignore these files since the code is
|
2
|
+
# intended to run in multiple environments; otherwise, check them in:
|
3
|
+
/Gemfile.lock
|
4
|
+
# .ruby-version
|
5
|
+
# .ruby-gemset
|
6
|
+
|
7
|
+
# rspec failure tracking
|
8
|
+
.rspec_status
|
9
|
+
|
10
|
+
*.gem
|
11
|
+
*.rbc
|
12
|
+
/.config
|
13
|
+
/coverage/
|
14
|
+
/InstalledFiles
|
15
|
+
/pkg/
|
16
|
+
/spec/reports/
|
17
|
+
/spec/examples.txt
|
18
|
+
/test/tmp/
|
19
|
+
/test/version_tmp/
|
20
|
+
/tmp/
|
21
|
+
|
22
|
+
# Used by dotenv library to load environment variables.
|
23
|
+
# .env
|
24
|
+
|
25
|
+
## Specific to RubyMotion:
|
26
|
+
.dat*
|
27
|
+
.repl_history
|
28
|
+
build/
|
29
|
+
*.bridgesupport
|
30
|
+
build-iPhoneOS/
|
31
|
+
build-iPhoneSimulator/
|
32
|
+
|
33
|
+
## Specific to RubyMotion (use of CocoaPods):
|
34
|
+
#
|
35
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
36
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
37
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
38
|
+
#
|
39
|
+
# vendor/Pods/
|
40
|
+
|
41
|
+
## Documentation cache and generated files:
|
42
|
+
/.yardoc/
|
43
|
+
/_yardoc/
|
44
|
+
/doc/
|
45
|
+
/rdoc/
|
46
|
+
|
47
|
+
## Environment normalization:
|
48
|
+
/.bundle/
|
49
|
+
/vendor/bundle
|
50
|
+
/lib/bundler/man/
|
51
|
+
var/
|
52
|
+
etc/
|
53
|
+
|
54
|
+
# for a library or gem, you might want to ignore these files since the code is
|
55
|
+
# intended to run in multiple environments; otherwise, check them in:
|
56
|
+
# Gemfile.lock
|
57
|
+
# .ruby-version
|
58
|
+
# .ruby-gemset
|
59
|
+
|
60
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
61
|
+
.rvmrc
|
62
|
+
|
63
|
+
# mac
|
64
|
+
.DS_Store
|
data/.rspec
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
sudo: false
|
2
|
+
language: ruby
|
3
|
+
rvm:
|
4
|
+
- 2.4.0
|
5
|
+
cache: bundler
|
6
|
+
git:
|
7
|
+
submodules: false
|
8
|
+
before_install:
|
9
|
+
- gem update --system
|
10
|
+
- gem update bundler
|
11
|
+
script:
|
12
|
+
- bundle exec rake spec
|
13
|
+
after_success:
|
14
|
+
- echo "success"
|
15
|
+
after_failure:
|
16
|
+
- echo "failure"
|
17
|
+
notifications:
|
18
|
+
slack:
|
19
|
+
secure: gPy0UwXMT/GSRQFyyADs+8kQqLLDdCYi4uTcnUYNIcOgp8L+0t6DCZOKE9uaJZJLfr2RWdOMDjBkLp7UL5hpvwQKu7dBrzLa71HDudIKTQHuGEOfpTL1/x/HU36EPJAIrsRZK8c0f4wF3YJsxMMWtosMCUFe1rGb9uQMvDSUkwwYwcHRltrWIHuUazmLso4oezEkSyWM5v2z9C3BSZWf2v6l1I57j1n3EzHUn5GSabyDPFlWU/s12LPzsdOozQCzEqzmE+3imly0Fnz08w1rpwMdis+PrZIJ3Dj8BpLls/PqMTMeYaSqIm8G4Js2LlM34HJKYAWu+DfXYUy35I6fLSbH/jR3knF24Ohio6B4UNWj/Hv/Nc0EEpixcz3K4Fpm3OToiB2MGKl7ErPkWF4iLW4c6aFePg07pHR+8lyLHK/PJi8JRwzXB44q1Hf5Z1Q7z6zee6aupGK097nTUEE06/2Y3FK5qzKOTEFOZ2+U4dkTwiUUmGnEHy9teztdPAd3cH9vCicaFWQqaU/+n/P/zEEDC6q3kya9ZMdibGCRYnkFkcMkLuiqNivCL4o1LBTzC8nQFohwoa+JYB7SIpZkyIZOmV+HqQYBjL5vMW4cOLNzNVIT62oFoEIws8810On3r7i5N2OlJfy67Mj67go8VghBuCeQZCvn+OJ8tUoVauA=
|
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 n.h.in.m.h@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) 2017 naoto0822
|
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,108 @@
|
|
1
|
+
# slack-incoming-webhooks-ruby
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/naoto0822/slack-incoming-webhooks-ruby.svg?branch=master)](https://travis-ci.org/naoto0822/slack-incoming-webhooks-ruby)
|
4
|
+
|
5
|
+
Ruby Client of Slack Incoming webhooks.
|
6
|
+
|
7
|
+
About Slack incoming-webhooks
|
8
|
+
- [slack incoming webhooks](https://api.slack.com/incoming-webhooks)
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'slack-incoming-webhooks-ruby'
|
16
|
+
```
|
17
|
+
|
18
|
+
## Usage
|
19
|
+
|
20
|
+
### Setting Incoming webhooks
|
21
|
+
|
22
|
+
Start by setting up an [incoming webhook integration](https://my.slack.com/services/new/incoming-webhook/) in your Slack team.
|
23
|
+
|
24
|
+
### Post to slack
|
25
|
+
|
26
|
+
#### normal post
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
require 'slack-incoming-webhooks-ruby'
|
30
|
+
|
31
|
+
url = ENV['SLACK_WEBHOOK_URL']
|
32
|
+
slack = Slack::IncomingWebhooks::Client.new(url)
|
33
|
+
|
34
|
+
payload = Slack::Messages::Payload.new
|
35
|
+
payload.text = 'sample text'
|
36
|
+
slack.post(payload)
|
37
|
+
```
|
38
|
+
|
39
|
+
![normal](./images/normal.png)
|
40
|
+
|
41
|
+
#### with attachment
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
require 'slack-incoming-webhooks-ruby'
|
45
|
+
|
46
|
+
url = ENV['SLACK_WEBHOOK_URL']
|
47
|
+
slack = Slack::IncomingWebhooks::Client.new(url)
|
48
|
+
payload = Slack::Messages::Payload.new
|
49
|
+
attachment = Slack::Messages::Attachment.new
|
50
|
+
attachment.fallback = 'sample fallback'
|
51
|
+
attachment.color = 'good'
|
52
|
+
attachment.title = 'sample title'
|
53
|
+
attachment.footer = 'from sample'
|
54
|
+
payload.attachments = [attachment]
|
55
|
+
|
56
|
+
slack.post(payload)
|
57
|
+
```
|
58
|
+
|
59
|
+
![attachment](./images/attachment.png)
|
60
|
+
|
61
|
+
#### with field
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
require 'slack-incoming-webhooks-ruby'
|
65
|
+
|
66
|
+
url = ENV['SLACK_WEBHOOK_URL']
|
67
|
+
slack = Slack::IncomingWebhooks::Client.new(url)
|
68
|
+
payload = Slack::Messages::Payload.new
|
69
|
+
attachment = Slack::Messages::Attachment.new
|
70
|
+
attachment.fallback = 'sample fallback'
|
71
|
+
attachment.color = 'good'
|
72
|
+
attachment.title = 'sample title'
|
73
|
+
attachment.footer = 'from sample'
|
74
|
+
|
75
|
+
field = Slack::Messages::Field.new
|
76
|
+
field.title = "sample field"
|
77
|
+
field.value = 'http://github.com'
|
78
|
+
|
79
|
+
field2 = Slack::Messages::Field.new
|
80
|
+
field2.title = "sample field2"
|
81
|
+
field2.value = 'http://github2.com'
|
82
|
+
|
83
|
+
attachment.fields = [field, field2]
|
84
|
+
payload.attachments = [attachment]
|
85
|
+
|
86
|
+
slack.post(payload)
|
87
|
+
```
|
88
|
+
|
89
|
+
![field](./images/field.png)
|
90
|
+
|
91
|
+
## TODO
|
92
|
+
|
93
|
+
- [ ] spec
|
94
|
+
- [ ] CI
|
95
|
+
|
96
|
+
## Development
|
97
|
+
|
98
|
+
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.
|
99
|
+
|
100
|
+
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).
|
101
|
+
|
102
|
+
## License
|
103
|
+
|
104
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
105
|
+
|
106
|
+
## Code of Conduct
|
107
|
+
|
108
|
+
Everyone interacting in the Slack::IncomingWebhooks::Client project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/naoto0822/slack-incoming-webhooks-ruby/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "slack-incoming-webhooks-ruby"
|
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
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/examples/post.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'slack-incoming-webhooks-ruby'
|
2
|
+
|
3
|
+
url = ENV['SLACK_WEBHOOK_URL']
|
4
|
+
slack = Slack::IncomingWebhooks::Client.new(url)
|
5
|
+
payload = Slack::Messages::Payload.new
|
6
|
+
# payload.text = 'sample text'
|
7
|
+
attachment = Slack::Messages::Attachment.new
|
8
|
+
attachment.fallback = 'sample fallback'
|
9
|
+
attachment.color = 'good'
|
10
|
+
attachment.title = 'sample title'
|
11
|
+
attachment.footer = 'from sample'
|
12
|
+
|
13
|
+
field = Slack::Messages::Field.new
|
14
|
+
field.title = "sample field"
|
15
|
+
field.value = 'http://github.com'
|
16
|
+
|
17
|
+
field2 = Slack::Messages::Field.new
|
18
|
+
field2.title = "sample field2"
|
19
|
+
field2.value = 'http://github2.com'
|
20
|
+
|
21
|
+
attachment.fields = [field, field2]
|
22
|
+
payload.attachments = [attachment]
|
23
|
+
|
24
|
+
slack.post(payload)
|
Binary file
|
data/images/field.png
ADDED
Binary file
|
data/images/normal.png
ADDED
Binary file
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'net/https'
|
3
|
+
require 'uri'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
require 'slack/version'
|
7
|
+
require 'slack/incoming_webhooks/client'
|
8
|
+
|
9
|
+
Dir[File.dirname(__FILE__) + '/slack/messages/**/*.rb'].each do |file|
|
10
|
+
require file
|
11
|
+
end
|
12
|
+
|
13
|
+
Dir[File.dirname(__FILE__) + '/slack/http/**/*.rb'].each do |file|
|
14
|
+
require file
|
15
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Slack
|
2
|
+
module Http
|
3
|
+
class Connection
|
4
|
+
def self.send(url, payload)
|
5
|
+
if url.nil? || payload.nil? || payload.empty?
|
6
|
+
msg = 'error: url or payload is nil.'
|
7
|
+
return Result.new(msg: msg)
|
8
|
+
end
|
9
|
+
|
10
|
+
res = request(url, payload)
|
11
|
+
Result.new(code: res.code, msg: res.message,
|
12
|
+
header: res.header, body: res.body)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.request(url, payload)
|
16
|
+
uri = URI.parse(url)
|
17
|
+
req = Net::HTTP::Post.new(uri.path)
|
18
|
+
req.set_form_data(payload: payload.to_json)
|
19
|
+
res = Net::HTTP.start(uri.host, uri.port,
|
20
|
+
use_ssl: uri.scheme == 'https') { |http|
|
21
|
+
http.open_timeout = 5
|
22
|
+
http.read_timeout = 5
|
23
|
+
http.request(req)
|
24
|
+
}
|
25
|
+
res
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Slack
|
2
|
+
module Http
|
3
|
+
class Result
|
4
|
+
attr_reader :code, :msg, :header, :body
|
5
|
+
def initialize(code: nil, msg: nil, header: nil, body: nil)
|
6
|
+
@code = code
|
7
|
+
@msg = msg
|
8
|
+
@header = header
|
9
|
+
@body = body
|
10
|
+
end
|
11
|
+
end # Result
|
12
|
+
end # Http
|
13
|
+
end # Slack
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Slack
|
2
|
+
module Messages
|
3
|
+
class Attachment
|
4
|
+
ATTACHMENT_PARAMS = %i[
|
5
|
+
fallback
|
6
|
+
color
|
7
|
+
pretext
|
8
|
+
author_name
|
9
|
+
author_link
|
10
|
+
author_icon
|
11
|
+
title
|
12
|
+
title_link
|
13
|
+
text
|
14
|
+
fields
|
15
|
+
image_url
|
16
|
+
thumb_url
|
17
|
+
footer
|
18
|
+
footer_icon
|
19
|
+
ts
|
20
|
+
].freeze
|
21
|
+
|
22
|
+
attr_accessor *ATTACHMENT_PARAMS
|
23
|
+
|
24
|
+
def to_params
|
25
|
+
params = {}
|
26
|
+
ATTACHMENT_PARAMS.each { |p|
|
27
|
+
if "#{p}" == 'fields'
|
28
|
+
fields = []
|
29
|
+
@fields.each { |f| fields.push(f.to_params) } unless @fields.nil?
|
30
|
+
params['fields'] = fields
|
31
|
+
next
|
32
|
+
end
|
33
|
+
params["#{p}"] = send(p) unless send(p).nil?
|
34
|
+
}
|
35
|
+
params
|
36
|
+
end
|
37
|
+
end # Attachment
|
38
|
+
end # Messages
|
39
|
+
end # Slack
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Slack
|
2
|
+
module Messages
|
3
|
+
class Field
|
4
|
+
FIELD_PARAMS = %i[
|
5
|
+
title
|
6
|
+
value
|
7
|
+
short
|
8
|
+
].freeze
|
9
|
+
|
10
|
+
attr_accessor *FIELD_PARAMS
|
11
|
+
|
12
|
+
def to_params
|
13
|
+
params = {}
|
14
|
+
FIELD_PARAMS.each { |p|
|
15
|
+
params["#{p}"] = send(p) unless send(p).nil?
|
16
|
+
}
|
17
|
+
params
|
18
|
+
end
|
19
|
+
end # Field
|
20
|
+
end # Messages
|
21
|
+
end # Slack
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Slack
|
2
|
+
module Messages
|
3
|
+
class Payload
|
4
|
+
PAYLOAD_PARAMS = %i[
|
5
|
+
channel
|
6
|
+
text
|
7
|
+
parse
|
8
|
+
link_names
|
9
|
+
attachments
|
10
|
+
unfurl_links
|
11
|
+
unfurl_media
|
12
|
+
username
|
13
|
+
as_user
|
14
|
+
icon_url
|
15
|
+
icon_emoji
|
16
|
+
thread_ts
|
17
|
+
reply_broadcast
|
18
|
+
].freeze
|
19
|
+
|
20
|
+
attr_accessor *PAYLOAD_PARAMS
|
21
|
+
|
22
|
+
def to_params
|
23
|
+
params = {}
|
24
|
+
PAYLOAD_PARAMS.each { |p|
|
25
|
+
if "#{p}" == 'attachments'
|
26
|
+
attachments = []
|
27
|
+
@attachments.each { |a| attachments.push(a.to_params) } unless @attachments.nil?
|
28
|
+
params['attachments'] = attachments unless attachments.empty?
|
29
|
+
next
|
30
|
+
end
|
31
|
+
params["#{p}"] = send(p) unless send(p).nil?
|
32
|
+
}
|
33
|
+
params
|
34
|
+
end
|
35
|
+
end # Payload
|
36
|
+
end # Messages
|
37
|
+
end # Slack
|
@@ -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/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "slack-incoming-webhooks-ruby"
|
8
|
+
spec.version = Slack::VERSION
|
9
|
+
spec.authors = ["naoto0822"]
|
10
|
+
spec.email = ["n.h.in.m.h@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = "slack incoming webhooks ruby client."
|
13
|
+
spec.description = "slack incoming webhooks ruby client."
|
14
|
+
spec.homepage = "https://github.com/naoto0822/slack-incoming-webhooks-ruby"
|
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
|
+
spec.required_ruby_version = '>= 2.4.0'
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.15"
|
26
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
27
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
28
|
+
spec.add_development_dependency "travis"
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: slack-incoming-webhooks-ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- naoto0822
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-06-25 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: '1.15'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.15'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.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: travis
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: slack incoming webhooks ruby client.
|
70
|
+
email:
|
71
|
+
- n.h.in.m.h@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".travis.yml"
|
79
|
+
- CODE_OF_CONDUCT.md
|
80
|
+
- Gemfile
|
81
|
+
- LICENSE.txt
|
82
|
+
- README.md
|
83
|
+
- Rakefile
|
84
|
+
- bin/console
|
85
|
+
- bin/setup
|
86
|
+
- examples/post.rb
|
87
|
+
- images/attachment.png
|
88
|
+
- images/field.png
|
89
|
+
- images/normal.png
|
90
|
+
- lib/slack-incoming-webhooks-ruby.rb
|
91
|
+
- lib/slack/http/connection.rb
|
92
|
+
- lib/slack/http/result.rb
|
93
|
+
- lib/slack/incoming_webhooks/client.rb
|
94
|
+
- lib/slack/messages/attachment.rb
|
95
|
+
- lib/slack/messages/field.rb
|
96
|
+
- lib/slack/messages/payload.rb
|
97
|
+
- lib/slack/version.rb
|
98
|
+
- slack-incoming-webhooks-ruby.gemspec
|
99
|
+
homepage: https://github.com/naoto0822/slack-incoming-webhooks-ruby
|
100
|
+
licenses:
|
101
|
+
- MIT
|
102
|
+
metadata: {}
|
103
|
+
post_install_message:
|
104
|
+
rdoc_options: []
|
105
|
+
require_paths:
|
106
|
+
- lib
|
107
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: 2.4.0
|
112
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
requirements: []
|
118
|
+
rubyforge_project:
|
119
|
+
rubygems_version: 2.6.12
|
120
|
+
signing_key:
|
121
|
+
specification_version: 4
|
122
|
+
summary: slack incoming webhooks ruby client.
|
123
|
+
test_files: []
|