slack-ruby-client 0.5.2 → 0.5.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: 83beab009684f102b815d58a123f2a7dc50975fd
4
- data.tar.gz: 151c2fc2b883a65ff6eaced3054b2db8e607b599
3
+ metadata.gz: f97d44d55767e0fbbe09b77361f94b2893283192
4
+ data.tar.gz: bfec69bffc973d6895feac2b74d1ed330374dd79
5
5
  SHA512:
6
- metadata.gz: 0c584024b15b6f07310702399dea5a0ae82c703821d5a33a447e749ce677bedc0b38d2e01d89ebb983fe14f4819fa2a295ec43ca94372f7b142686255ba660d3
7
- data.tar.gz: c797d350c47ed7acf6eb942a723cb57ccb79897360677aa12bdece2fbce3298c6bec06139a8f0e3c27602e62e4bcfb2dac4b9f63e81904ba938b191d0cbe8789
6
+ metadata.gz: cd2c5f47750c4adda9439145cc2e84cb13f78e0b73f48ac0ddd6e4b5489b16e32b392858d73fb15a85c2aee71fce394103072afa12c4b6d7edacc3b398bbb247
7
+ data.tar.gz: c307c1cab8e48397597947aca5c70db67d3a2986893d5e3628f4f2442fb6e59baf503a3208ebf9ae66a9c5481a28477efae7795a767602a06e81082a7895c585
data/.travis.yml CHANGED
@@ -1,8 +1,12 @@
1
+ language: ruby
2
+
3
+ cache: bundler
4
+
1
5
  rvm:
2
6
  - 2.2
3
7
  - 2.1
4
8
  - 2.0
5
- - rbx-2.9
9
+ - rbx-2
6
10
  - jruby-19mode
7
11
  - ruby-head
8
12
  - jruby-head
@@ -11,6 +15,8 @@ matrix:
11
15
  allow_failures:
12
16
  - rvm: ruby-head
13
17
  - rvm: jruby-head
18
+ - rvm: jruby-19mode
19
+ - rvm: rbx-2
14
20
 
15
21
  git:
16
22
  submodules: false
data/CHANGELOG.md CHANGED
@@ -1,4 +1,9 @@
1
- ### 0.5.2 (1/8/2015)
1
+ ### 0.5.3 (1/11/2016)
2
+
3
+ * [#47](https://github.com/dblock/slack-ruby-client/pull/47): Fix: default to Celluloid newer API - [@jlyonsmith](https://github.com/jlyonsmith), [@dblock](https://github.com/dblock).
4
+ * Fixed JRuby file encoding regression - [@dblock](https://github.com/dblock).
5
+
6
+ ### 0.5.2 (1/8/2016)
2
7
 
3
8
  * [#41](https://github.com/dblock/slack-ruby-client/issues/41): Added `Slack::Messages::Formatting#unescape` - [@dblock](https://github.com/dblock).
4
9
  * Added `files_comments` to Web API - [@dblock](https://github.com/dblock).
data/README.md CHANGED
@@ -18,7 +18,7 @@ A Ruby client for the Slack [Web](https://api.slack.com/web) and [RealTime Messa
18
18
 
19
19
  ## Stable Release
20
20
 
21
- You're reading the documentation for the **stable** release of slack-ruby-client, 0.5.2. See [UPGRADING](UPGRADING.md) when upgrading from an older version.
21
+ You're reading the documentation for the **stable** release of slack-ruby-client, 0.5.3. See [UPGRADING](UPGRADING.md) when upgrading from an older version.
22
22
 
23
23
  ## Installation
24
24
 
data/Rakefile CHANGED
@@ -11,13 +11,9 @@ RSpec::Core::RakeTask.new(:spec) do |spec|
11
11
  spec.pattern = FileList['spec/**/*_spec.rb']
12
12
  end
13
13
 
14
- if RUBY_ENGINE == 'rbx'
15
- task default: [:spec]
16
- else
17
- require 'rubocop/rake_task'
18
- RuboCop::RakeTask.new
14
+ require 'rubocop/rake_task'
15
+ RuboCop::RakeTask.new
19
16
 
20
- task default: [:rubocop, :spec]
21
- end
17
+ task default: [:rubocop, :spec]
22
18
 
23
19
  load 'slack/web/api/tasks/generate.rake'
data/lib/slack/config.rb CHANGED
@@ -3,6 +3,10 @@ module Slack
3
3
  extend self
4
4
 
5
5
  attr_accessor :token
6
+
7
+ def reset
8
+ self.token = nil
9
+ end
6
10
  end
7
11
 
8
12
  class << self
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module Slack
2
3
  module Messages
3
4
  module Formatting
@@ -1,6 +1,7 @@
1
1
  require 'websocket/driver'
2
2
  require 'socket'
3
3
  require 'forwardable'
4
+ require 'celluloid/current'
4
5
  require 'celluloid/io'
5
6
 
6
7
  module Slack
@@ -9,7 +10,7 @@ module Slack
9
10
  module Celluloid
10
11
  class Socket < Slack::RealTime::Socket
11
12
  include ::Celluloid::IO
12
- include ::Celluloid::Logger
13
+ include ::Celluloid::Internals::Logger
13
14
 
14
15
  BLOCK_SIZE = 4096
15
16
 
@@ -31,7 +31,7 @@ module Slack
31
31
  [:Eventmachine, :Celluloid].each do |concurrency|
32
32
  begin
33
33
  return Slack::RealTime::Concurrency.const_get(concurrency)
34
- rescue LoadError
34
+ rescue LoadError, NameError
35
35
  false # could not be loaded, missing dependencies
36
36
  end
37
37
  end
data/lib/slack/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Slack
2
- VERSION = '0.5.2'
2
+ VERSION = '0.5.3'
3
3
  end
@@ -1,14 +1,19 @@
1
- require 'slack'
2
- require 'logger'
1
+ require 'spec_helper'
3
2
 
4
3
  RSpec.describe 'integration test', skip: !ENV['SLACK_API_TOKEN'] && 'missing SLACK_API_TOKEN' do
4
+ around do |ex|
5
+ WebMock.allow_net_connect!
6
+ VCR.turned_off { ex.run }
7
+ WebMock.disable_net_connect!
8
+ end
9
+
5
10
  before do
6
11
  Thread.abort_on_exception = true
7
12
  end
8
13
 
9
14
  let(:logger) { Logger.new(STDOUT) }
10
15
 
11
- let(:queue) { Queue.new }
16
+ let(:queue) { QueueWithTimeout.new }
12
17
 
13
18
  let(:client) { Slack::RealTime::Client.new(token: ENV['SLACK_API_TOKEN']) }
14
19
 
@@ -34,16 +39,18 @@ RSpec.describe 'integration test', skip: !ENV['SLACK_API_TOKEN'] && 'missing SLA
34
39
  end
35
40
 
36
41
  def start_server
37
- logger.debug '#start_server'
42
+ dt = rand(5) + 1
43
+ logger.debug "#start_server, waiting #{dt} second(s)"
44
+ sleep dt # prevent Slack 429 rate limit errors
38
45
  # start server and wait for on :open
39
46
  c = connection
40
47
  logger.debug "connection is #{c}"
41
- queue.pop
48
+ queue.pop_with_timeout(5)
42
49
  end
43
50
 
44
51
  def wait_for_server
45
52
  logger.debug '#wait_for_server'
46
- queue.pop
53
+ queue.pop_with_timeout(5)
47
54
  logger.debug '#wait_for_server, joined'
48
55
  end
49
56
 
@@ -67,8 +74,10 @@ RSpec.describe 'integration test', skip: !ENV['SLACK_API_TOKEN'] && 'missing SLA
67
74
 
68
75
  client.on :message do |data|
69
76
  logger.debug data
70
- expect(data).to include('text' => message, 'subtype' => 'bot_message')
77
+ expect(data['text']).to eq message
78
+ expect(data['subtype']).to eq 'bot_message'
71
79
  logger.debug 'client.stop!'
80
+ expect(client.started?).to be true
72
81
  client.stop!
73
82
  end
74
83
 
@@ -80,6 +89,7 @@ RSpec.describe 'integration test', skip: !ENV['SLACK_API_TOKEN'] && 'missing SLA
80
89
  it 'gets hello' do
81
90
  client.on :hello do |data|
82
91
  logger.debug "client.on :hello, data=#{data}"
92
+ expect(client.started?).to be true
83
93
  client.stop!
84
94
  end
85
95
 
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Slack::Messages::Formatting do
@@ -4,10 +4,16 @@ RSpec.describe Slack::RealTime::Client, vcr: { cassette_name: 'web/rtm_start' }
4
4
  let(:ws) { double(Slack::RealTime::Concurrency::Mock::WebSocket, on: true) }
5
5
  let(:url) { 'wss://ms173.slack-msgs.com/websocket/lqcUiAvrKTP-uuid=' }
6
6
  before do
7
+ @token = ENV.delete('SLACK_API_TOKEN')
8
+ Slack::Config.reset
9
+ Slack::RealTime::Config.reset
7
10
  Slack::RealTime.configure do |config|
8
11
  config.concurrency = Slack::RealTime::Concurrency::Mock
9
12
  end
10
13
  end
14
+ after do
15
+ ENV['SLACK_API_TOKEN'] = @token if @token
16
+ end
11
17
  context 'token' do
12
18
  before do
13
19
  Slack.configure do |config|
@@ -2,6 +2,12 @@ require 'spec_helper'
2
2
 
3
3
  describe Slack do
4
4
  let(:slack) { File.expand_path(File.join(__FILE__, '../../../bin/slack')) }
5
+ before do
6
+ @token = ENV.delete('SLACK_API_TOKEN')
7
+ end
8
+ after do
9
+ ENV['SLACK_API_TOKEN'] = @token if @token
10
+ end
5
11
  describe '#help' do
6
12
  it 'displays help' do
7
13
  help = `"#{slack}" help`
@@ -1,6 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  RSpec.describe Slack::Web::Client do
4
+ before do
5
+ Slack::Config.reset
6
+ end
4
7
  context 'with defaults' do
5
8
  let(:client) { Slack::Web::Client.new }
6
9
  describe '#initialize' do
@@ -0,0 +1,34 @@
1
+ # http://spin.atomicobject.com/2014/07/07/ruby-queue-pop-timeout/
2
+ class QueueWithTimeout
3
+ def initialize
4
+ @mutex = Mutex.new
5
+ @queue = []
6
+ @recieved = ConditionVariable.new
7
+ end
8
+
9
+ def push(x)
10
+ @mutex.synchronize do
11
+ @queue << x
12
+ @recieved.signal
13
+ end
14
+ end
15
+
16
+ def <<(x)
17
+ push(x)
18
+ end
19
+
20
+ def pop(non_block = false)
21
+ pop_with_timeout(non_block ? 0 : nil)
22
+ end
23
+
24
+ def pop_with_timeout(timeout = nil)
25
+ @mutex.synchronize do
26
+ if @queue.empty?
27
+ @recieved.wait(@mutex, timeout) if timeout != 0
28
+ # if we're still empty after the timeout, raise exception
29
+ fail ThreadError, 'queue empty' if @queue.empty?
30
+ end
31
+ @queue.shift
32
+ end
33
+ end
34
+ end
metadata CHANGED
@@ -1,167 +1,167 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slack-ruby-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Doubrovkine
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-08 00:00:00.000000000 Z
11
+ date: 2016-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: faraday_middleware
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: json
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: websocket-driver
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: gli
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: erubis
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: json-schema
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - '>='
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - '>='
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rake
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - '>='
115
+ - - ">="
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - '>='
122
+ - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: rspec
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - '>='
129
+ - - ">="
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - '>='
136
+ - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: vcr
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - '>='
143
+ - - ">="
144
144
  - !ruby/object:Gem::Version
145
145
  version: '0'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - '>='
150
+ - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: webmock
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - '>='
157
+ - - ">="
158
158
  - !ruby/object:Gem::Version
159
159
  version: '0'
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
- - - '>='
164
+ - - ">="
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
167
  - !ruby/object:Gem::Dependency
@@ -185,12 +185,12 @@ executables:
185
185
  extensions: []
186
186
  extra_rdoc_files: []
187
187
  files:
188
- - .gitignore
189
- - .gitmodules
190
- - .rspec
191
- - .rubocop.yml
192
- - .rubocop_todo.yml
193
- - .travis.yml
188
+ - ".gitignore"
189
+ - ".gitmodules"
190
+ - ".rspec"
191
+ - ".rubocop.yml"
192
+ - ".rubocop_todo.yml"
193
+ - ".travis.yml"
194
194
  - CHANGELOG.md
195
195
  - CONTRIBUTING.md
196
196
  - Gemfile
@@ -310,6 +310,7 @@ files:
310
310
  - spec/slack/web/api/error_spec.rb
311
311
  - spec/slack/web/client_spec.rb
312
312
  - spec/spec_helper.rb
313
+ - spec/support/queue_with_timeout.rb
313
314
  - spec/support/real_time/concurrency/mock.rb
314
315
  - spec/support/real_time/connected_client.rb
315
316
  - spec/support/token.rb
@@ -324,17 +325,17 @@ require_paths:
324
325
  - lib
325
326
  required_ruby_version: !ruby/object:Gem::Requirement
326
327
  requirements:
327
- - - '>='
328
+ - - ">="
328
329
  - !ruby/object:Gem::Version
329
330
  version: '0'
330
331
  required_rubygems_version: !ruby/object:Gem::Requirement
331
332
  requirements:
332
- - - '>='
333
+ - - ">="
333
334
  - !ruby/object:Gem::Version
334
335
  version: 1.3.6
335
336
  requirements: []
336
337
  rubyforge_project:
337
- rubygems_version: 2.4.5
338
+ rubygems_version: 2.4.8
338
339
  signing_key:
339
340
  specification_version: 4
340
341
  summary: Slack Web and RealTime API client.
@@ -361,6 +362,7 @@ test_files:
361
362
  - spec/slack/web/api/error_spec.rb
362
363
  - spec/slack/web/client_spec.rb
363
364
  - spec/spec_helper.rb
365
+ - spec/support/queue_with_timeout.rb
364
366
  - spec/support/real_time/concurrency/mock.rb
365
367
  - spec/support/real_time/connected_client.rb
366
368
  - spec/support/token.rb