tarumi 0.0.1 → 0.0.2

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: b1dc45129272a733c25133c4f0735da412585237
4
- data.tar.gz: 8960015ed1b1ec4234dd8c11cee4996e17393f08
3
+ metadata.gz: 0f06eeaef8132a24e5164f9898ac80d64436284a
4
+ data.tar.gz: 76234f6d7348349ddc9f67a79fc7800a9760167d
5
5
  SHA512:
6
- metadata.gz: 9d8dea22f78f6411cff9ebe642bb8e7d24df26358b013334e419054f98ab4a304b1c9e9d9449fdc7b279e65eabe44730efb562b85cce1baf9a896e5643fa6c1c
7
- data.tar.gz: abed9a0ea945f41be881160f847a2a26629499cfe4e9d663e634715164b2131d1ec9dbafb52cb78fc6404c105e6e8c9ed4b9c44b2c20dda70889683e2b5d05b2
6
+ metadata.gz: 8745178a3f021be520b34769023bc103e4aabe11b6bf94180ed60e3e4e076732014dc79517c3afc403a27a6c6b5f880c1acab4b136be77bea0c28e6cfa6298bb
7
+ data.tar.gz: 3d2afdccb5d311ddd3d7b64f56466d011812eec8bf8eb29f68523e10bd4e114de04523dd71710b138667e971f363ad6e9499c5c30076445b09c1bc7c29ac7449
data/README.md CHANGED
@@ -58,7 +58,9 @@ The example above will post a message to the `#general` channel, but you can eas
58
58
  options = {
59
59
  username: "usernametopost",
60
60
  channel: "#anotherchannel",
61
- hook_name: "webhookname"
61
+ hook_name: "webhookname",
62
+ icon_url: "http://a_url_to_an_icon.com/icon.png",
63
+ icon_emoji: "http://a_url_to_an_emoji.com/emoji.png"
62
64
  }
63
65
  ```
64
66
  That should be it for you to easily configure the bot and start sending messages.
@@ -67,7 +69,7 @@ That should be it for you to easily configure the bot and start sending messages
67
69
 
68
70
  ## Contributing
69
71
 
70
- 1. Fork it ( http://github.com/<my-github-username>/tarumi/fork )
72
+ 1. Fork it ( http://github.com/IcaliaLabs/tarumi/fork )
71
73
  2. Create your feature branch (`git checkout -b my-new-feature`)
72
74
  3. Commit your changes (`git commit -am 'Add some feature'`)
73
75
  4. Push to the branch (`git push origin my-new-feature`)
@@ -4,8 +4,8 @@ module Tarumi
4
4
  class Bot
5
5
  include HTTParty
6
6
 
7
- attr_reader :options, :username, :channel,
8
- :hook_name
7
+ attr_reader :username, :channel, :hook_name,
8
+ :icon_emoji, :icon_url
9
9
 
10
10
  # Add the default format to be json on each request
11
11
  format :json
@@ -14,27 +14,40 @@ module Tarumi
14
14
  disable_rails_query_string_format if defined?(Rails)
15
15
 
16
16
  def initialize(team, token, options = {})
17
- self.class.base_uri("https://#{team}.slack.com")
17
+ self.class.base_uri("https://#{team}.slack.com")
18
18
  self.class.default_params(token: token) #we sent this token on each request
19
19
 
20
- @username = options[:username] || "webhookbot"
21
- @channel = options[:channel] || "#general"
22
- @hook_name = options[:hook_name] || "incoming-webhook"
20
+ @username = options[:username] || "webhookbot"
21
+ @channel = options[:channel] || "#general"
22
+ @hook_name = options[:hook_name] || "incoming-webhook"
23
+ @icon_url = options[:icon_url] || "https://slack.com/img/icons/app-57.png"
24
+ @icon_emoji = options[:icon_emoji]
23
25
 
24
26
  raise ArgumentError, 'You need to specify a team' if team.blank?
25
27
  raise ArgumentError, 'You need to specify the token, to get one go to https://yourteamname.slack.com/services/new' if token.blank?
26
28
  end
27
29
 
28
30
  def ping(text, options = {})
29
- payload = { text: text, channel: @channel, username: @username }.merge(options)
31
+ payload = {
32
+ text: text,
33
+ channel: @channel,
34
+ username: @username
35
+ }.merge(icon).merge(options)
36
+
30
37
  body = { body: "payload=#{payload.to_json}"}
31
38
 
32
- response = self.class.post("/services/hooks/#{@hook_name}", body)
39
+ response = self.class.post("/services/hooks/#{@hook_name}", body)
33
40
 
34
41
  raise ArgumentError, 'You need to specify a text' if text.blank?
35
42
 
36
43
  "#{response.body} - #{response.code}"
37
44
  end
38
45
 
46
+ private
47
+
48
+ def icon
49
+ @icon_emoji ? { icon_emoji: @icon_emoji } : { icon_url: @icon_url }
50
+ end
51
+
39
52
  end
40
53
  end
@@ -1,3 +1,3 @@
1
1
  module Tarumi
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tarumi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abraham Kuri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-06 00:00:00.000000000 Z
11
+ date: 2015-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -103,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
103
  version: '0'
104
104
  requirements: []
105
105
  rubyforge_project:
106
- rubygems_version: 2.2.1
106
+ rubygems_version: 2.4.2
107
107
  signing_key:
108
108
  specification_version: 4
109
109
  summary: A super simple library to interact with Slack webhooks