slacking 0.0.2 → 0.0.3

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: 226004f4bac0af53510170e39010e56cb75707d2
4
- data.tar.gz: 736175a5789aaee2f9721f706e0c0d83fca149eb
3
+ metadata.gz: 67122d41e3207dee33537c6d23ce8dcfeb70ad1d
4
+ data.tar.gz: d611c3578faa58356e43ad7c16b00ab394449121
5
5
  SHA512:
6
- metadata.gz: 7b6830b6546003af331d4657184a6c81740ad75c9e2289bc9e5d3726c23df627f5d609e9507cd6d3f8a3fe05ad54c6b3b67e1047cd367960aabc60e6c82be22d
7
- data.tar.gz: 131036821066f0c5dd17a56aad90b6005e22323ccb73335faab21e05ae7f3ce374aca49290d1e144e39a53d7ca64eed99e12a03373097cd41164a5cc3e8d8405
6
+ metadata.gz: a7a4e80da3dcb364cb8cd0747606e7dca190e11b64292b5c48c251d2217556b6e95980dffd5cc0abd6018e5aac4d05f6231683892be18b0c7c6b693307a60b77
7
+ data.tar.gz: f4b4bee8357ec18acdbad8550fe2db6423ce7a491aa14bf9a425051b98590613dc6481a0780e74b242affcb5c32a2b33a2e9a9c1c4b5bf324abde34af71c212d
@@ -18,5 +18,18 @@ module Slacking
18
18
 
19
19
  config[:token]
20
20
  end
21
+
22
+ def get_slack_organization(write_options = 'a+')
23
+ create_config_dir
24
+ config = read_config_from_disk || {}
25
+
26
+ unless config[:organization]
27
+ puts "Please enter your slack organization (i.e. https://{organization}.slack.com):\n"
28
+ config.merge!(organization: get_action)
29
+ write_config_to_disk(config)
30
+ end
31
+
32
+ config[:organization]
33
+ end
21
34
  end
22
35
  end
@@ -9,8 +9,9 @@ module Slacking
9
9
  include IO
10
10
  include Config
11
11
 
12
- def initialize(token)
12
+ def initialize(token, organization)
13
13
  @token = token
14
+ @organization = organization
14
15
  end
15
16
 
16
17
  def post_to_slack(profile)
@@ -54,7 +55,7 @@ module Slacking
54
55
  end
55
56
 
56
57
  def slack_url
57
- "https://byliner.slack.com/services/hooks/incoming-webhook?token=#{@token}"
58
+ "https://#{@organization}.slack.com/services/hooks/incoming-webhook?token=#{@token}"
58
59
  end
59
60
  end
60
61
  end
@@ -1,3 +1,3 @@
1
1
  module Slacking
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/slacking.rb CHANGED
@@ -14,13 +14,14 @@ module Slacking
14
14
 
15
15
  def run
16
16
  @token = get_slack_token
17
+ @organization = get_slack_organization
17
18
  listen
18
19
  end
19
20
 
20
21
  protected
21
22
 
22
23
  def client
23
- @client ||= Slacking::HttpClient.new(@token)
24
+ @client ||= Slacking::HttpClient.new(@token, @organization)
24
25
  end
25
26
 
26
27
  private
@@ -10,7 +10,7 @@ class SlackingTest < Minitest::Test
10
10
  end
11
11
 
12
12
  def test_profile
13
- stub_request(:post, "https://byliner.slack.com/services/hooks/incoming-webhook?token=xhibit").
13
+ stub_request(:post, "https://xhibit.slack.com/services/hooks/incoming-webhook?token=xhibit").
14
14
  with(:body => "{\"text\":\"message\",\"channel\":\"#xhibit\",\"icon_url\":\"xhibit\",\"username\":\"xhibit\"}",
15
15
  :headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}).
16
16
  to_return(:status => 200, :body => "", :headers => {})
@@ -1,2 +1,3 @@
1
1
  ---
2
2
  :token: xhibit
3
+ :organization: xhibit
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slacking
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Ryan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-05 00:00:00.000000000 Z
11
+ date: 2014-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -85,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
85
  version: '0'
86
86
  requirements: []
87
87
  rubyforge_project:
88
- rubygems_version: 2.2.0
88
+ rubygems_version: 2.2.2
89
89
  signing_key:
90
90
  specification_version: 4
91
91
  summary: Post comments to slack as different users