slack-post 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/slack/post/version.rb +1 -1
- data/lib/slack/post.rb +10 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84c9ebf0228144d31f8bc86bdd3ad6276771b556
|
4
|
+
data.tar.gz: 14eb6e6c814e9b15acee434961f73460f8a92e1b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c961880f1c93adfddb80b6bebf7b7a50a500515a57339c03d91b677cee9cbe603c85e20dd8539fceecd345448cb035c023351729b237466475637cf6bb10be93
|
7
|
+
data.tar.gz: 92ac2e49c819bdfec26adbf250d28f9a979a13e9a5bf27f39520809ea6990480f795a2e775ad20c7606af321c14acefc7cacba9b3d5778ca9221479096266c79
|
data/lib/slack/post/version.rb
CHANGED
data/lib/slack/post.rb
CHANGED
@@ -12,7 +12,7 @@ module Slack
|
|
12
12
|
}.freeze
|
13
13
|
|
14
14
|
def self.post_with_attachments(message,attachments,chan=nil,opts={})
|
15
|
-
raise "
|
15
|
+
raise "Slack::Post.configure was not called or configuration was invalid" unless configured?(chan)
|
16
16
|
pkt = {
|
17
17
|
channel: chan || config[:channel],
|
18
18
|
text: message,
|
@@ -64,8 +64,10 @@ module Slack
|
|
64
64
|
|
65
65
|
LegacyConfigParams = [:subdomain,:token].freeze
|
66
66
|
|
67
|
-
def self.configured?(
|
68
|
-
|
67
|
+
def self.configured?(channel_was_overriden=false)
|
68
|
+
# if a channel was not manually specified, then we must have a channel option in the config OR
|
69
|
+
# we must be using the webhook_url which provided its own default channel on the Slack-side config.
|
70
|
+
return false if !channel_was_overriden && !config[:channel] && !config[:webhook_url]
|
69
71
|
|
70
72
|
# we need _either_ a webhook url or all LegacyConfigParams
|
71
73
|
return true if config[:webhook_url]
|
@@ -75,11 +77,15 @@ module Slack
|
|
75
77
|
end
|
76
78
|
|
77
79
|
def self.config
|
78
|
-
@config ||=
|
80
|
+
@config ||= {}
|
79
81
|
end
|
80
82
|
|
81
83
|
def self.configure(opts)
|
82
84
|
@config = config.merge(prune(opts))
|
85
|
+
|
86
|
+
# If a channel has not been configured, add the default channel
|
87
|
+
# unless we are using a webhook_url, which provides its own default channel.
|
88
|
+
@config.merge!(DefaultOpts) unless ( @config[:webhook_url] || @config[:channel] )
|
83
89
|
end
|
84
90
|
|
85
91
|
KnownConfigParams = [:webhook_url,:username,:channel,:subdomain,:token,:icon_url,:icon_emoji].freeze
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slack-post
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Bragg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|