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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b3af1268aea6ef6f47d8779c6cd8c847098deb5b9b7f76c307a85c822bfe921d
4
- data.tar.gz: e2dbd4647b2341078821d1538848889fa520d29b3f126598c1f96b8fa4919867
3
+ metadata.gz: 6aa7e1774c5a0b9a4542c511a0e1c17ab9324b9f12d5f0e7cd5d216c1458d9f7
4
+ data.tar.gz: 7c963de9c738334066bb48e6c3ea48f7f0aadca1e85c3de9c7f740ec91e9acbb
5
5
  SHA512:
6
- metadata.gz: 5df6cd0a6298ac14745bde2ec00e715875300679a957a4e3dd2269b89d411eefe63d8185993b21dab10b3c2eb98a2c74d990b36c77a9b9a311b43bbe756a0b26
7
- data.tar.gz: f4b1929a53f19010bdfc1b9692e8dcd97c20655891a716a95fd48c752b7283f3d5c90f54c162228601823ecc9221b20c95635bbf635c39f194c94c7802e43d3b
6
+ metadata.gz: a86b8fcb64f296e897d374afe6e60b8fbecad6d0bafc0d2a22b632f13c139675f2e07562a762a21c30f3ee7b854a7ed40eab8c5b9543448c65547077e8623e07
7
+ data.tar.gz: e39b6844d495b25dbdf2e987de23ae7f3c969128250a5281ffef9e2d90733f40fbfceabb1486068f7509b88c5bdc51a09ca34cde2170f0880d436d97a494c6db
checksums.yaml.gz.sig CHANGED
Binary file
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- slackpost (0.1.0)
4
+ slackpost (0.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Slackpost
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/slackpost`. To experiment with that code, run `bin/console` for an interactive prompt.
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
- TODO: Write usage instructions here
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/[USERNAME]/slackpost. 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.
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).
@@ -1,3 +1,3 @@
1
1
  module Slackpost
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.1.2'.freeze
3
3
  end
data/lib/slackpost.rb CHANGED
@@ -18,14 +18,14 @@ module Slackpost
18
18
  yield(config)
19
19
  end
20
20
 
21
- def simple_msg_to_channel(msg, channel)
21
+ def send_message(msg, channel)
22
22
  body = { channel: channel,
23
23
  link_names: 1,
24
24
  text: msg }
25
- send_slackpost(body)
25
+ send_slack(body)
26
26
  end
27
27
 
28
- def attachment_msg_to_channel(msg, channel, att_title, att_value, att_color)
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
- send_slackpost(body)
36
+ send_slack(body)
37
37
  end
38
38
 
39
- def send_slackpost(body)
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
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slackpost
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guillermo Mora
metadata.gz.sig CHANGED
Binary file