slacking 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/slacking/config.rb +13 -0
- data/lib/slacking/http_client.rb +3 -2
- data/lib/slacking/version.rb +1 -1
- data/lib/slacking.rb +2 -1
- data/test/slacking/slacking_test.rb +1 -1
- data/test/support/.slacking_config/config.yml +1 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67122d41e3207dee33537c6d23ce8dcfeb70ad1d
|
4
|
+
data.tar.gz: d611c3578faa58356e43ad7c16b00ab394449121
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7a4e80da3dcb364cb8cd0747606e7dca190e11b64292b5c48c251d2217556b6e95980dffd5cc0abd6018e5aac4d05f6231683892be18b0c7c6b693307a60b77
|
7
|
+
data.tar.gz: f4b4bee8357ec18acdbad8550fe2db6423ce7a491aa14bf9a425051b98590613dc6481a0780e74b242affcb5c32a2b33a2e9a9c1c4b5bf324abde34af71c212d
|
data/lib/slacking/config.rb
CHANGED
@@ -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
|
data/lib/slacking/http_client.rb
CHANGED
@@ -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
|
58
|
+
"https://#{@organization}.slack.com/services/hooks/incoming-webhook?token=#{@token}"
|
58
59
|
end
|
59
60
|
end
|
60
61
|
end
|
data/lib/slacking/version.rb
CHANGED
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://
|
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 => {})
|
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.
|
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-
|
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.
|
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
|