slack-poster 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/slack/poster.rb +6 -18
- data/lib/slack/version.rb +1 -1
- data/slack-poster.gemspec +1 -1
- data/spec/poster_spec.rb +2 -2
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2dc84d4b5731b1487e433e2292b0f398690ea523
|
4
|
+
data.tar.gz: ddea706f2a76c965c5e100c309054789a082f379
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0feea6c7a74fef533258880438f840782487226e444fdc093cdcda5b00e27c30d149cb60d282938a31e38f7992ed31786d16ab40aa6ecd4a6c1c3a196837894e
|
7
|
+
data.tar.gz: 7974d9bfd0c3f5ebc1830e12116eb8928ce18f4caffc9ce943ed62138abc7df941ff59683cb425ec22acb498e28f3a408e8366c7b90485a0cca18d9c79c0dd89
|
data/lib/slack/poster.rb
CHANGED
@@ -2,27 +2,13 @@ require 'slack/version'
|
|
2
2
|
require 'slack/field'
|
3
3
|
require 'slack/message'
|
4
4
|
require 'slack/attachment'
|
5
|
-
|
6
|
-
require '
|
5
|
+
require 'json'
|
6
|
+
require 'faraday'
|
7
7
|
|
8
8
|
module Slack
|
9
9
|
class Poster
|
10
|
-
include HTTParty
|
11
|
-
|
12
10
|
attr_accessor :options
|
13
11
|
|
14
|
-
# The format of the response. This comes back as 'ok' from slack.
|
15
|
-
format :plain
|
16
|
-
|
17
|
-
# Disable the use of rails query string format.
|
18
|
-
#
|
19
|
-
# With rails query string format enabled:
|
20
|
-
# => get '/', :query => {:selected_ids => [1,2,3]}
|
21
|
-
#
|
22
|
-
# Would translate to this:
|
23
|
-
# => /?selected_ids[]=1&selected_ids[]=2&selected_ids[]=3
|
24
|
-
disable_rails_query_string_format
|
25
|
-
|
26
12
|
# Define getters and setters for the options hash keys. This will make assign of the options
|
27
13
|
# more flexible.
|
28
14
|
[:username, :channel, :icon_url, :icon_emoji].each do |option_attr|
|
@@ -49,7 +35,7 @@ module Slack
|
|
49
35
|
# username: 'Ricardo',
|
50
36
|
# icon_emoji: 'ghost')
|
51
37
|
def initialize(webhook_url, options = {})
|
52
|
-
|
38
|
+
@base_uri = webhook_url
|
53
39
|
|
54
40
|
@options = options
|
55
41
|
|
@@ -71,7 +57,9 @@ module Slack
|
|
71
57
|
def send_message(message)
|
72
58
|
body = message.is_a?(String) ? options.merge(text: message) : options.merge(message.as_json)
|
73
59
|
|
74
|
-
|
60
|
+
conn = Faraday.new(url: @base_uri)
|
61
|
+
|
62
|
+
response = conn.post('', payload: body.to_json)
|
75
63
|
|
76
64
|
response
|
77
65
|
end
|
data/lib/slack/version.rb
CHANGED
data/slack-poster.gemspec
CHANGED
data/spec/poster_spec.rb
CHANGED
@@ -54,7 +54,7 @@ describe Slack::Poster do
|
|
54
54
|
response = poster.send_message(message)
|
55
55
|
|
56
56
|
expect(response).to_not be_nil
|
57
|
-
expect(response.
|
57
|
+
expect(response.env.status).to eq(200)
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
@@ -63,7 +63,7 @@ describe Slack::Poster do
|
|
63
63
|
response = poster.send_message('Hello world')
|
64
64
|
|
65
65
|
expect(response).to_not be_nil
|
66
|
-
expect(response.
|
66
|
+
expect(response.env.status).to eq(200)
|
67
67
|
end
|
68
68
|
end
|
69
69
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slack-poster
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ricardo Otero
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -115,19 +115,19 @@ dependencies:
|
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: '0.35'
|
117
117
|
- !ruby/object:Gem::Dependency
|
118
|
-
name:
|
118
|
+
name: faraday
|
119
119
|
requirement: !ruby/object:Gem::Requirement
|
120
120
|
requirements:
|
121
121
|
- - "~>"
|
122
122
|
- !ruby/object:Gem::Version
|
123
|
-
version:
|
123
|
+
version: 0.9.2
|
124
124
|
type: :runtime
|
125
125
|
prerelease: false
|
126
126
|
version_requirements: !ruby/object:Gem::Requirement
|
127
127
|
requirements:
|
128
128
|
- - "~>"
|
129
129
|
- !ruby/object:Gem::Version
|
130
|
-
version:
|
130
|
+
version: 0.9.2
|
131
131
|
description: Slack Poster is a gem to make your integration with Slack WebHooks easier.
|
132
132
|
email:
|
133
133
|
- oterosantos@gmail.com
|