slack-ruby-client 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +4 -0
- data/.gitmodules +3 -0
- data/.rspec +2 -0
- data/.rubocop.yml +6 -0
- data/.rubocop_todo.yml +34 -0
- data/.travis.yml +6 -0
- data/CHANGELOG.md +4 -0
- data/CONTRIBUTING.md +139 -0
- data/Gemfile +3 -0
- data/LICENSE.md +22 -0
- data/README.md +123 -0
- data/RELEASING.md +67 -0
- data/Rakefile +19 -0
- data/examples/hi_real_time/Gemfile +3 -0
- data/examples/hi_real_time/hi.gif +0 -0
- data/examples/hi_real_time/hi.rb +27 -0
- data/examples/hi_real_time_and_web/Gemfile +3 -0
- data/examples/hi_real_time_and_web/hi.gif +0 -0
- data/examples/hi_real_time_and_web/hi.rb +24 -0
- data/examples/hi_web/Gemfile +3 -0
- data/examples/hi_web/hi.gif +0 -0
- data/examples/hi_web/hi.rb +14 -0
- data/lib/slack-ruby-client.rb +23 -0
- data/lib/slack.rb +1 -0
- data/lib/slack/config.rb +17 -0
- data/lib/slack/real_time/api/message.rb +20 -0
- data/lib/slack/real_time/api/message_id.rb +14 -0
- data/lib/slack/real_time/api/ping.rb +16 -0
- data/lib/slack/real_time/api/typing.rb +17 -0
- data/lib/slack/real_time/client.rb +91 -0
- data/lib/slack/real_time/socket.rb +41 -0
- data/lib/slack/version.rb +3 -0
- data/lib/slack/web/api/endpoints.rb +39 -0
- data/lib/slack/web/api/endpoints/api.rb +25 -0
- data/lib/slack/web/api/endpoints/auth.rb +21 -0
- data/lib/slack/web/api/endpoints/channels.rb +216 -0
- data/lib/slack/web/api/endpoints/chat.rb +78 -0
- data/lib/slack/web/api/endpoints/emoji.rb +21 -0
- data/lib/slack/web/api/endpoints/files.rb +76 -0
- data/lib/slack/web/api/endpoints/groups.rb +229 -0
- data/lib/slack/web/api/endpoints/im.rb +82 -0
- data/lib/slack/web/api/endpoints/oauth.rb +32 -0
- data/lib/slack/web/api/endpoints/presence.rb +24 -0
- data/lib/slack/web/api/endpoints/rtm.rb +21 -0
- data/lib/slack/web/api/endpoints/search.rb +68 -0
- data/lib/slack/web/api/endpoints/stars.rb +23 -0
- data/lib/slack/web/api/endpoints/users.rb +70 -0
- data/lib/slack/web/api/error.rb +8 -0
- data/lib/slack/web/api/schema/method.json +45 -0
- data/lib/slack/web/api/tasks/generate.rake +37 -0
- data/lib/slack/web/api/templates/endpoints.erb +17 -0
- data/lib/slack/web/api/templates/method.erb +39 -0
- data/lib/slack/web/client.rb +17 -0
- data/lib/slack/web/config.rb +36 -0
- data/lib/slack/web/faraday/connection.rb +25 -0
- data/lib/slack/web/faraday/request.rb +39 -0
- data/lib/slack/web/faraday/response/raise_error.rb +14 -0
- data/lib/slack_ruby_client.rb +1 -0
- data/screenshots/register-bot.png +0 -0
- data/slack-ruby-client.gemspec +28 -0
- data/spec/fixtures/slack/web/auth_test_error.yml +48 -0
- data/spec/fixtures/slack/web/auth_test_success.yml +57 -0
- data/spec/fixtures/slack/web/rtm_start.yml +73 -0
- data/spec/slack/config_spec.rb +14 -0
- data/spec/slack/real_time/api/message_spec.rb +15 -0
- data/spec/slack/real_time/api/ping_spec.rb +15 -0
- data/spec/slack/real_time/api/typing_spec.rb +15 -0
- data/spec/slack/real_time/client_spec.rb +51 -0
- data/spec/slack/real_time/socket_spec.rb +42 -0
- data/spec/slack/version_spec.rb +7 -0
- data/spec/slack/web/api/endpoints/auth_spec.rb +15 -0
- data/spec/slack/web/client_spec.rb +31 -0
- data/spec/spec_helper.rb +14 -0
- data/spec/support/real_time/connected_client.rb +13 -0
- data/spec/support/vcr.rb +8 -0
- metadata +287 -0
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Slack::Web::Api::Endpoints::Auth do
|
4
|
+
let(:client) { Slack::Web::Client.new }
|
5
|
+
context 'without auth', vcr: { cassette_name: 'web/auth_test_error' } do
|
6
|
+
it 'fails with an exception' do
|
7
|
+
expect { client.auth_test }.to raise_error Slack::Web::Api::Error
|
8
|
+
end
|
9
|
+
end
|
10
|
+
context 'with auth', vcr: { cassette_name: 'web/auth_test_success' } do
|
11
|
+
it 'succeeds' do
|
12
|
+
expect { client.auth_test }.to_not raise_error
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Slack::Web::Client do
|
4
|
+
context 'with defaults' do
|
5
|
+
let(:client) { Slack::Web::Client.new }
|
6
|
+
describe '#initialize' do
|
7
|
+
it 'sets user-agent' do
|
8
|
+
expect(client.user_agent).to eq Slack::Web::Config.user_agent
|
9
|
+
expect(client.user_agent).to include Slack::VERSION
|
10
|
+
end
|
11
|
+
Slack::Web::Config::ATTRIBUTES.each do |key|
|
12
|
+
it "sets #{key}" do
|
13
|
+
expect(client.send(key)).to eq Slack::Web::Config.send(key)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
context 'with custom settings' do
|
19
|
+
describe '#initialize' do
|
20
|
+
Slack::Web::Config::ATTRIBUTES.each do |key|
|
21
|
+
context key do
|
22
|
+
let(:client) { Slack::Web::Client.new(key => 'custom') }
|
23
|
+
it "sets #{key}" do
|
24
|
+
expect(client.send(key)).to_not eq Slack::Web::Config.send(key)
|
25
|
+
expect(client.send(key)).to eq 'custom'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..'))
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'rspec'
|
5
|
+
|
6
|
+
require 'slack-ruby-client'
|
7
|
+
|
8
|
+
Dir[File.join(File.dirname(__FILE__), 'support', '**/*.rb')].each do |file|
|
9
|
+
require file
|
10
|
+
end
|
11
|
+
|
12
|
+
Slack.configure do |config|
|
13
|
+
config.token = ENV['SLACK_API_TOKEN']
|
14
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
RSpec.shared_context 'connected client' do
|
2
|
+
let(:client) { Slack::RealTime::Client.new }
|
3
|
+
let(:ws) { double(Faye::WebSocket::Client) }
|
4
|
+
let(:url) { 'wss://ms173.slack-msgs.com/websocket/lqcUiAvrKTP-uuid=' }
|
5
|
+
let(:socket) { double(Slack::RealTime::Socket, connected?: true) }
|
6
|
+
before do
|
7
|
+
allow(EM).to receive(:run).and_yield
|
8
|
+
allow(Slack::RealTime::Socket).to receive(:new).with(url).and_return(socket)
|
9
|
+
allow(socket).to receive(:connect!).and_yield(ws)
|
10
|
+
allow(ws).to receive(:on)
|
11
|
+
client.start!
|
12
|
+
end
|
13
|
+
end
|
data/spec/support/vcr.rb
ADDED
metadata
ADDED
@@ -0,0 +1,287 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: slack-ruby-client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Daniel Doubrovkine
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-07-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday_middleware
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: faye-websocket
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: eventmachine
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: erubis
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: json-schema
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rake
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: vcr
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: webmock
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: rubocop
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - '='
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 0.32.1
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - '='
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: 0.32.1
|
167
|
+
description:
|
168
|
+
email: dblock@dblock.org
|
169
|
+
executables: []
|
170
|
+
extensions: []
|
171
|
+
extra_rdoc_files: []
|
172
|
+
files:
|
173
|
+
- ".gitignore"
|
174
|
+
- ".gitmodules"
|
175
|
+
- ".rspec"
|
176
|
+
- ".rubocop.yml"
|
177
|
+
- ".rubocop_todo.yml"
|
178
|
+
- ".travis.yml"
|
179
|
+
- CHANGELOG.md
|
180
|
+
- CONTRIBUTING.md
|
181
|
+
- Gemfile
|
182
|
+
- LICENSE.md
|
183
|
+
- README.md
|
184
|
+
- RELEASING.md
|
185
|
+
- Rakefile
|
186
|
+
- examples/hi_real_time/Gemfile
|
187
|
+
- examples/hi_real_time/hi.gif
|
188
|
+
- examples/hi_real_time/hi.rb
|
189
|
+
- examples/hi_real_time_and_web/Gemfile
|
190
|
+
- examples/hi_real_time_and_web/hi.gif
|
191
|
+
- examples/hi_real_time_and_web/hi.rb
|
192
|
+
- examples/hi_web/Gemfile
|
193
|
+
- examples/hi_web/hi.gif
|
194
|
+
- examples/hi_web/hi.rb
|
195
|
+
- lib/slack-ruby-client.rb
|
196
|
+
- lib/slack.rb
|
197
|
+
- lib/slack/config.rb
|
198
|
+
- lib/slack/real_time/api/message.rb
|
199
|
+
- lib/slack/real_time/api/message_id.rb
|
200
|
+
- lib/slack/real_time/api/ping.rb
|
201
|
+
- lib/slack/real_time/api/typing.rb
|
202
|
+
- lib/slack/real_time/client.rb
|
203
|
+
- lib/slack/real_time/socket.rb
|
204
|
+
- lib/slack/version.rb
|
205
|
+
- lib/slack/web/api/endpoints.rb
|
206
|
+
- lib/slack/web/api/endpoints/api.rb
|
207
|
+
- lib/slack/web/api/endpoints/auth.rb
|
208
|
+
- lib/slack/web/api/endpoints/channels.rb
|
209
|
+
- lib/slack/web/api/endpoints/chat.rb
|
210
|
+
- lib/slack/web/api/endpoints/emoji.rb
|
211
|
+
- lib/slack/web/api/endpoints/files.rb
|
212
|
+
- lib/slack/web/api/endpoints/groups.rb
|
213
|
+
- lib/slack/web/api/endpoints/im.rb
|
214
|
+
- lib/slack/web/api/endpoints/oauth.rb
|
215
|
+
- lib/slack/web/api/endpoints/presence.rb
|
216
|
+
- lib/slack/web/api/endpoints/rtm.rb
|
217
|
+
- lib/slack/web/api/endpoints/search.rb
|
218
|
+
- lib/slack/web/api/endpoints/stars.rb
|
219
|
+
- lib/slack/web/api/endpoints/users.rb
|
220
|
+
- lib/slack/web/api/error.rb
|
221
|
+
- lib/slack/web/api/schema/method.json
|
222
|
+
- lib/slack/web/api/tasks/generate.rake
|
223
|
+
- lib/slack/web/api/templates/endpoints.erb
|
224
|
+
- lib/slack/web/api/templates/method.erb
|
225
|
+
- lib/slack/web/client.rb
|
226
|
+
- lib/slack/web/config.rb
|
227
|
+
- lib/slack/web/faraday/connection.rb
|
228
|
+
- lib/slack/web/faraday/request.rb
|
229
|
+
- lib/slack/web/faraday/response/raise_error.rb
|
230
|
+
- lib/slack_ruby_client.rb
|
231
|
+
- screenshots/register-bot.png
|
232
|
+
- slack-ruby-client.gemspec
|
233
|
+
- spec/fixtures/slack/web/auth_test_error.yml
|
234
|
+
- spec/fixtures/slack/web/auth_test_success.yml
|
235
|
+
- spec/fixtures/slack/web/rtm_start.yml
|
236
|
+
- spec/slack/config_spec.rb
|
237
|
+
- spec/slack/real_time/api/message_spec.rb
|
238
|
+
- spec/slack/real_time/api/ping_spec.rb
|
239
|
+
- spec/slack/real_time/api/typing_spec.rb
|
240
|
+
- spec/slack/real_time/client_spec.rb
|
241
|
+
- spec/slack/real_time/socket_spec.rb
|
242
|
+
- spec/slack/version_spec.rb
|
243
|
+
- spec/slack/web/api/endpoints/auth_spec.rb
|
244
|
+
- spec/slack/web/client_spec.rb
|
245
|
+
- spec/spec_helper.rb
|
246
|
+
- spec/support/real_time/connected_client.rb
|
247
|
+
- spec/support/vcr.rb
|
248
|
+
homepage: http://github.com/dblock/slack-ruby-client
|
249
|
+
licenses:
|
250
|
+
- MIT
|
251
|
+
metadata: {}
|
252
|
+
post_install_message:
|
253
|
+
rdoc_options: []
|
254
|
+
require_paths:
|
255
|
+
- lib
|
256
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
257
|
+
requirements:
|
258
|
+
- - ">="
|
259
|
+
- !ruby/object:Gem::Version
|
260
|
+
version: '0'
|
261
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
262
|
+
requirements:
|
263
|
+
- - ">="
|
264
|
+
- !ruby/object:Gem::Version
|
265
|
+
version: 1.3.6
|
266
|
+
requirements: []
|
267
|
+
rubyforge_project:
|
268
|
+
rubygems_version: 2.2.2
|
269
|
+
signing_key:
|
270
|
+
specification_version: 4
|
271
|
+
summary: Slack Web and RealTime API client.
|
272
|
+
test_files:
|
273
|
+
- spec/fixtures/slack/web/auth_test_error.yml
|
274
|
+
- spec/fixtures/slack/web/auth_test_success.yml
|
275
|
+
- spec/fixtures/slack/web/rtm_start.yml
|
276
|
+
- spec/slack/config_spec.rb
|
277
|
+
- spec/slack/real_time/api/message_spec.rb
|
278
|
+
- spec/slack/real_time/api/ping_spec.rb
|
279
|
+
- spec/slack/real_time/api/typing_spec.rb
|
280
|
+
- spec/slack/real_time/client_spec.rb
|
281
|
+
- spec/slack/real_time/socket_spec.rb
|
282
|
+
- spec/slack/version_spec.rb
|
283
|
+
- spec/slack/web/api/endpoints/auth_spec.rb
|
284
|
+
- spec/slack/web/client_spec.rb
|
285
|
+
- spec/spec_helper.rb
|
286
|
+
- spec/support/real_time/connected_client.rb
|
287
|
+
- spec/support/vcr.rb
|