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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bbcc725463980506c2af9898e9d37f0b92163350
4
- data.tar.gz: fb11f3587bc82ca8ed87f1505a323ad67b7292ae
3
+ metadata.gz: 84c9ebf0228144d31f8bc86bdd3ad6276771b556
4
+ data.tar.gz: 14eb6e6c814e9b15acee434961f73460f8a92e1b
5
5
  SHA512:
6
- metadata.gz: f8b7b559d66708268f01c54f7b0cc5edde281029be145da1971d79f6a0d3f5ad2a02695a00940aa4c23987e418dd74350041ad8aa118deb0912a4a26cb736f0d
7
- data.tar.gz: e63c4596bcb406078bd0e15dfb236461ce575338f43bef9765bdcf6098b152090a7692bcf56eb2e4e1f248dd4f34a2ecbae1e6bafa91b7d6d530e742aff26555
6
+ metadata.gz: c961880f1c93adfddb80b6bebf7b7a50a500515a57339c03d91b677cee9cbe603c85e20dd8539fceecd345448cb035c023351729b237466475637cf6bb10be93
7
+ data.tar.gz: 92ac2e49c819bdfec26adbf250d28f9a979a13e9a5bf27f39520809ea6990480f795a2e775ad20c7606af321c14acefc7cacba9b3d5778ca9221479096266c79
@@ -1,5 +1,5 @@
1
1
  module Slack
2
2
  module Post
3
- VERSION = "0.3.0"
3
+ VERSION = "0.3.1"
4
4
  end
5
5
  end
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 "You need to call Slack::Post.configure before trying to send messages." unless configured?(chan.nil?)
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?(needs_channel=true)
68
- return false if needs_channel and !config[:channel]
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 ||= DefaultOpts
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.0
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-23 00:00:00.000000000 Z
11
+ date: 2015-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler