slackhook 1.0 → 1.1

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
  SHA1:
3
- metadata.gz: 67c80a31d87839cfc10443f08d3134e9e66f22f3
4
- data.tar.gz: 4e37f2613048675d2909af139393883bb2a05bb9
3
+ metadata.gz: d149e24a892fb18632105335b67193dd91d3f122
4
+ data.tar.gz: cafc5b55dbee7865dafa25977047a756d902df06
5
5
  SHA512:
6
- metadata.gz: f4b6665206f40023aa234ca4ed96067ce4e09086b5ecd373ee28f7c2cb9cba75d8c76d30b3cfb194f238926197788e164e240614964b59b31054d36137559116
7
- data.tar.gz: 33f69d72a8a052e9a1acbae72fe0dc9107ebce3ec4b9abed4014ef67a99df97135299af53b1bcd7fa91485601c4561ddda94be6ab31c035008555fe840d7112a
6
+ metadata.gz: b8f3ecf28a3dd0339af74378df0f41e5b847ac950a62e9770384b6c90538214b736a77242383c750f9b7fd9fe14451ac0046c002063d87bb4fd0d9bb5c03a68d
7
+ data.tar.gz: 09e352475a98727694cbeba904b65e4ea14478650627d2d907027bce0e73085d9df0259960cc9fc13ab02a5dea224a477173753c5f45a98c89c48fd2281e5c85
@@ -1,3 +1,3 @@
1
1
  module Slackhook
2
- VERSION = "1.0"
2
+ VERSION = "1.1"
3
3
  end
@@ -6,8 +6,10 @@ require "json"
6
6
  module WebhookService
7
7
  class Webhook
8
8
  def initialize options = {}
9
+ raise ArgumentError.new('icon_type and icon_url are mutualy exclusive!') if options[:icon_type].present? && options[:icon_url].present?
9
10
  @text = options.fetch(:text, nil)
10
11
  @icon_type = options.fetch(:icon_type, nil)
12
+ @icon_url = options.fetch(:icon_url, nil)
11
13
  @channel = options.fetch(:channel, nil)
12
14
  @username = options.fetch(:username, nil)
13
15
  @webhook_url = options.fetch(:webhook_url, nil)
@@ -15,7 +17,14 @@ module WebhookService
15
17
 
16
18
  def send
17
19
  uri = URI::encode(@webhook_url)
18
- @toSend = { channel: @channel, text: @text, username: @username, icon_emoji: @icon_type}
20
+ @toSend = { channel: @channel, text: @text, username: @username }
21
+
22
+ if @icon_type.present?
23
+ @toSend.merge!(icon_emoji: @icon_type)
24
+ elsif @icon_url.present?
25
+ @toSend.merge!(icon_url: @icon_url)
26
+ end
27
+
19
28
  uri = URI.parse(uri)
20
29
  https = Net::HTTP.new(uri.host,uri.port)
21
30
  https.use_ssl = true
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slackhook
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.0'
4
+ version: '1.1'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Urielable
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-10 00:00:00.000000000 Z
11
+ date: 2015-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler