slackpost 0.1.1 → 0.1.2
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
- checksums.yaml.gz.sig +0 -0
- data/Gemfile.lock +1 -1
- data/README.md +26 -8
- data/lib/slackpost/version.rb +1 -1
- data/lib/slackpost.rb +7 -5
- data.tar.gz.sig +0 -0
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6aa7e1774c5a0b9a4542c511a0e1c17ab9324b9f12d5f0e7cd5d216c1458d9f7
|
4
|
+
data.tar.gz: 7c963de9c738334066bb48e6c3ea48f7f0aadca1e85c3de9c7f740ec91e9acbb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a86b8fcb64f296e897d374afe6e60b8fbecad6d0bafc0d2a22b632f13c139675f2e07562a762a21c30f3ee7b854a7ed40eab8c5b9543448c65547077e8623e07
|
7
|
+
data.tar.gz: e39b6844d495b25dbdf2e987de23ae7f3c969128250a5281ffef9e2d90733f40fbfceabb1486068f7509b88c5bdc51a09ca34cde2170f0880d436d97a494c6db
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# Slackpost
|
2
2
|
|
3
|
-
|
3
|
+
This is the simplest gem you will find to send messages to slack from your application. Although there are some
|
4
|
+
similar gems, this one is focused on simplicity and usability. Also, it does not have any other gem dependencies!
|
4
5
|
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -22,7 +22,29 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
|
25
|
+
First, you need some lines in your app, in order to configure the slack incoming webhook. If you are not sure what
|
26
|
+
token do you need, refer to this page: https://api.slack.com/incoming-webhooks
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
require 'slackpost'
|
30
|
+
|
31
|
+
Slackpost.configure do |config|
|
32
|
+
config.slack_token = "T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX"
|
33
|
+
end
|
34
|
+
```
|
35
|
+
|
36
|
+
That's it! And now you can use the static methods `send_message` and `send_attachemnt`, like this:
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
Slackpost.send_message("This is a test", 'test_channel')
|
40
|
+
|
41
|
+
Slackpost.send_attachment("This is a test attachment", 'test_channel',
|
42
|
+
"attachment title", "attachment message", "#0055bb")
|
43
|
+
|
44
|
+
```
|
45
|
+
|
46
|
+
This gem is active and will be under development, so new features are absolutely welcome. However keep in mind that
|
47
|
+
the purpose of this gem is to be simple. If you need more specific features, please take a look at other gems.
|
26
48
|
|
27
49
|
## Development
|
28
50
|
|
@@ -32,12 +54,8 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
54
|
|
33
55
|
## Contributing
|
34
56
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
57
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/guillermijas/slackpost.
|
36
58
|
|
37
59
|
## License
|
38
60
|
|
39
61
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
40
|
-
|
41
|
-
## Code of Conduct
|
42
|
-
|
43
|
-
Everyone interacting in the Slackpost project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/slackpost/blob/master/CODE_OF_CONDUCT.md).
|
data/lib/slackpost/version.rb
CHANGED
data/lib/slackpost.rb
CHANGED
@@ -18,14 +18,14 @@ module Slackpost
|
|
18
18
|
yield(config)
|
19
19
|
end
|
20
20
|
|
21
|
-
def
|
21
|
+
def send_message(msg, channel)
|
22
22
|
body = { channel: channel,
|
23
23
|
link_names: 1,
|
24
24
|
text: msg }
|
25
|
-
|
25
|
+
send_slack(body)
|
26
26
|
end
|
27
27
|
|
28
|
-
def
|
28
|
+
def send_attachment(msg, channel, att_title, att_value, att_color)
|
29
29
|
body = { channel: channel,
|
30
30
|
link_names: 1,
|
31
31
|
text: msg,
|
@@ -33,10 +33,12 @@ module Slackpost
|
|
33
33
|
color: att_color,
|
34
34
|
fields: [{ title: att_title,
|
35
35
|
value: att_value }] }] }
|
36
|
-
|
36
|
+
send_slack(body)
|
37
37
|
end
|
38
38
|
|
39
|
-
|
39
|
+
private
|
40
|
+
|
41
|
+
def send_slack(body)
|
40
42
|
uri = URI.parse("https://hooks.slack.com/services/#{config.slack_token}")
|
41
43
|
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
42
44
|
request = Net::HTTP::Post.new(uri)
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|