peertransfer_chat 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/peertransfer_chat/client.rb +10 -2
- data/lib/peertransfer_chat/config.rb +7 -3
- data/lib/peertransfer_chat/version.rb +2 -2
- data/spec/integration/client_spec.rb +42 -17
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ee2091c5b39f66278a542c6d73a6bec47c00f8546f7a65f90311bacead47756
|
4
|
+
data.tar.gz: 6345ecdd4d49cc7bab70b58d01fe1cbd03fa5394f556847a82c36b3336ad4e20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f3a49c1ebdb70f5147364cddc64c9c3bd2f9988b3c759792c5c84ec80241145ff13bdc4659a0689cbec4bf2bd4bd7a3f1adce775d8284f51e6381f510762180
|
7
|
+
data.tar.gz: bae2b0ec4811adb30de2d5965c087e54a825168440aee6d8d2d2dd33be0016b83783c89f70aec98ff67acdff9b4906fd1cabcd098214eff0d3d62dafeaa370c4
|
@@ -1,7 +1,8 @@
|
|
1
1
|
require 'slackr'
|
2
2
|
|
3
|
-
|
3
|
+
class PeertransferChat
|
4
4
|
class Client
|
5
|
+
attr_accessor :config
|
5
6
|
|
6
7
|
def self.upload(filename)
|
7
8
|
new.upload(filename)
|
@@ -11,6 +12,13 @@ module PeertransferChat
|
|
11
12
|
new.speak(something)
|
12
13
|
end
|
13
14
|
|
15
|
+
def initialize
|
16
|
+
if block_given?
|
17
|
+
@config = Config.new
|
18
|
+
yield(@config)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
14
22
|
def upload(filename)
|
15
23
|
slack = Slackr.connect(team, api_token, slack_opts)
|
16
24
|
slack.upload(filename, { 'channels' => channel_id })
|
@@ -47,7 +55,7 @@ module PeertransferChat
|
|
47
55
|
end
|
48
56
|
|
49
57
|
def config
|
50
|
-
PeertransferChat.config
|
58
|
+
@config ||= PeertransferChat.config
|
51
59
|
end
|
52
60
|
end
|
53
61
|
end
|
@@ -1,17 +1,21 @@
|
|
1
|
-
|
1
|
+
class PeertransferChat
|
2
2
|
class Config
|
3
3
|
SETTINGS = [:team, :channel, :incoming_token, :username, :api_token, :channel_id]
|
4
4
|
|
5
|
-
attr_accessor
|
5
|
+
attr_accessor(*SETTINGS)
|
6
6
|
|
7
7
|
def valid?
|
8
8
|
@team && @channel && @incoming_token && @username
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
+
def config
|
13
|
+
@config ||= Config.new
|
14
|
+
end
|
15
|
+
|
12
16
|
class << self
|
13
17
|
def configure
|
14
|
-
@config ||=
|
18
|
+
@config ||= new.config
|
15
19
|
yield(@config)
|
16
20
|
end
|
17
21
|
|
@@ -1,3 +1,3 @@
|
|
1
|
-
|
2
|
-
VERSION = "0.0
|
1
|
+
class PeertransferChat
|
2
|
+
VERSION = "0.1.0"
|
3
3
|
end
|
@@ -1,35 +1,60 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe PeertransferChat::Client do
|
4
|
-
let(:slack_client) {
|
4
|
+
let(:slack_client) { instance_spy(Slackr) }
|
5
5
|
let(:team_name) { 'a team' }
|
6
6
|
let(:team_token) { 'a token' }
|
7
7
|
let(:team_channel) { 'a channel' }
|
8
8
|
let(:team_username) { 'a username' }
|
9
9
|
let(:opts) { { 'channel' => team_channel, 'username' => team_username } }
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
context 'with class configuration' do
|
12
|
+
before do
|
13
|
+
PeertransferChat.configure do |c|
|
14
|
+
c.team = team_name
|
15
|
+
c.incoming_token = team_token
|
16
|
+
c.channel = team_channel
|
17
|
+
c.username = team_username
|
18
|
+
end
|
14
19
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
c.incoming_token = team_token
|
19
|
-
c.channel = team_channel
|
20
|
-
c.username = team_username
|
20
|
+
allow(Slackr).to receive(:connect).
|
21
|
+
with(team_name, team_token, opts).
|
22
|
+
and_return(slack_client)
|
21
23
|
end
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
-
|
25
|
+
describe '.say' do
|
26
|
+
it 'speaks something to a channel' do
|
27
|
+
described_class.speak('hello')
|
28
|
+
|
29
|
+
expect(slack_client).to have_received(:say).with('hello')
|
30
|
+
|
31
|
+
PeertransferChat.reset!
|
32
|
+
end
|
33
|
+
end
|
26
34
|
end
|
27
35
|
|
28
|
-
|
29
|
-
|
30
|
-
|
36
|
+
context 'with instance configuration' do
|
37
|
+
before do
|
38
|
+
allow(Slackr).to receive(:connect).
|
39
|
+
with(team_name, team_token, opts).
|
40
|
+
and_return(slack_client)
|
41
|
+
end
|
42
|
+
|
43
|
+
let(:client) do
|
44
|
+
PeertransferChat::Client.new do |c|
|
45
|
+
c.team = team_name
|
46
|
+
c.incoming_token = team_token
|
47
|
+
c.channel = team_channel
|
48
|
+
c.username = team_username
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe '.say' do
|
53
|
+
it 'speaks something to a channel' do
|
54
|
+
client.speak('hello')
|
31
55
|
|
32
|
-
|
56
|
+
expect(slack_client).to have_received(:say).with('hello')
|
57
|
+
end
|
33
58
|
end
|
34
59
|
end
|
35
60
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: peertransfer_chat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- peerTransfer tech
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-06-
|
11
|
+
date: 2018-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: slackr
|