async-slack 0.1.0 → 0.1.1

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
  SHA256:
3
- metadata.gz: 315657ffe3859a70c177fcbda5cfd167d8d196de733b8a7120a45e005c0fbd5a
4
- data.tar.gz: 80201b5872df1dff9d5c8cfa6634ad81ec2be3f10d03361df919de13ddd9d59d
3
+ metadata.gz: a64150cb0b14528d0e8b5086f0763b18d0384d32591caae16f07eae3ad5bba20
4
+ data.tar.gz: 4197055f6f5fcd96abdfe2dd24110d009443d028dac0aba7b59459d6d521230e
5
5
  SHA512:
6
- metadata.gz: 3c780e82b86cf2af7bf9d01357abcf664fffcd8d83c5222aee2fa7defe259fdffe984d6513d7158ba5129710d7b44f56ee1e64a20d3725b4e6186fe0818c5c87
7
- data.tar.gz: 1da87de2bdf291fe4983f5be6234609037aa59a5b43e653bc18efb82b45d5765053a252d2539600785fb22a54830e20a1363b0e0aac727c3e9f06917a4cf54bf
6
+ metadata.gz: 2d852cef4378305932aaa3069a4fc73b07208feb27068c096fb9c6866e811b582a3dfb87432a8a5934144f6b3233a76afb8b55957aed8ca34b3ffaa0133a73ee
7
+ data.tar.gz: 1b97a8d12e4e665587f4ca299537cdd9e48558f151560108de5aaae635ef37573016e2e78bc5651b5600519806aacd752cc9bf475ea79905bda6948178dc9430
data/.gitignore CHANGED
@@ -9,3 +9,4 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+ Gemfile.lock
data/README.md CHANGED
@@ -2,8 +2,7 @@
2
2
 
3
3
  A simple asynchronous slack client implementation.
4
4
 
5
- [![Build Status](https://secure.travis-ci.org/socketry/async-slack.svg)](http://travis-ci.org/socketry/async-slack)
6
- [![Coverage Status](https://coveralls.io/repos/socketry/async-slack/badge.svg)](https://coveralls.io/r/socketry/async-slack)
5
+ [![Build Status](https://travis-ci.com/socketry/async-slack.svg?branch=master)](https://travis-ci.com/socketry/async-slack)
7
6
 
8
7
  ## Installation
9
8
 
@@ -21,7 +20,21 @@ Or install it yourself as:
21
20
 
22
21
  ## Usage
23
22
 
24
- ...
23
+ ### Real Time WebSockets
24
+
25
+ It can use HTTP/2 WebSockets to connect to the Slack Real Time interface.
26
+
27
+ ```ruby
28
+ require "async/slack"
29
+
30
+ Async::Slack.connect(token: token) do |client|
31
+ client.real_time.connect do |connection|
32
+ while message = connection.read
33
+ pp message
34
+ end
35
+ end
36
+ end
37
+ ```
25
38
 
26
39
  ## Contributing
27
40
 
data/async-slack.gemspec CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.require_paths = ["lib"]
18
18
 
19
19
  spec.add_dependency "async-rest"
20
- spec.add_dependency "async-websocket"
20
+ spec.add_dependency "async-websocket", "~> 0.13"
21
21
 
22
22
  spec.add_development_dependency "async-rspec"
23
23
 
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "../../lib/async/slack"
4
+
5
+ token = ENV['SLACK_TOKEN']
6
+
7
+ Async::Slack.connect(token: token) do |client|
8
+ client.real_time.connect do |connection|
9
+ id = 1
10
+
11
+ Async do |task|
12
+ while true
13
+ task.sleep 5
14
+
15
+ Async.logger.info(self) {"Sending Slack Ping Frame #{id}..."}
16
+
17
+ connection.write({type: "ping", id: id})
18
+ connection.flush
19
+
20
+ id += 1
21
+ end
22
+ end
23
+
24
+ while message = connection.read
25
+ Async.logger.info(self) {"message: #{message.inspect}"}
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "../../lib/async/slack"
4
+
5
+ token = ENV['SLACK_TOKEN']
6
+
7
+ class Connection < Async::WebSocket::Connection
8
+ def receive_pong(frame)
9
+ Async.logger.info(self) {"receive_pong: #{frame.inspect}"}
10
+ end
11
+ end
12
+
13
+ Async::Slack.connect(token: token) do |client|
14
+ client.real_time.connect(handler: Connection) do |connection|
15
+ id = 1
16
+
17
+ Async do |task|
18
+ while true
19
+ task.sleep 5
20
+
21
+ Async.logger.info(self) {"Sending WebSocket Ping Frame #{id}..."}
22
+
23
+ connection.send_ping("id=#{id}")
24
+ connection.flush
25
+
26
+ id += 1
27
+ end
28
+ end
29
+
30
+ while message = connection.read
31
+ Async.logger.info(self) {"message: #{message.inspect}"}
32
+ end
33
+ end
34
+ end
@@ -28,7 +28,7 @@ require_relative 'representation'
28
28
  module Async
29
29
  module Slack
30
30
  class RealTime < Representation
31
- def connect(&block)
31
+ def connect(**options, &block)
32
32
  response = self.post
33
33
 
34
34
  parameters = response.read
@@ -36,7 +36,7 @@ module Async
36
36
 
37
37
  endpoint = Async::HTTP::Endpoint.parse(url)
38
38
 
39
- Async::WebSocket::Client.connect(endpoint, &block)
39
+ Async::WebSocket::Client.connect(endpoint, **options, &block)
40
40
  end
41
41
  end
42
42
  end
@@ -1,6 +1,6 @@
1
1
 
2
2
  module Async
3
3
  module Slack
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async-slack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-21 00:00:00.000000000 Z
11
+ date: 2019-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async-rest
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: async-websocket
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '0.13'
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
- version: '0'
40
+ version: '0.13'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: async-rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -119,10 +119,11 @@ files:
119
119
  - ".rspec"
120
120
  - ".travis.yml"
121
121
  - Gemfile
122
- - Gemfile.lock
123
122
  - README.md
124
123
  - Rakefile
125
124
  - async-slack.gemspec
125
+ - examples/alive/slack.rb
126
+ - examples/alive/websockets.rb
126
127
  - lib/async/slack.rb
127
128
  - lib/async/slack/chat.rb
128
129
  - lib/async/slack/client.rb
@@ -153,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
154
  - !ruby/object:Gem::Version
154
155
  version: '0'
155
156
  requirements: []
156
- rubygems_version: 3.0.3
157
+ rubygems_version: 3.0.2
157
158
  signing_key:
158
159
  specification_version: 4
159
160
  summary: Build Slack bots and use real time messaging.
data/Gemfile.lock DELETED
@@ -1,82 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- async-slack (0.1.0)
5
- async-rest
6
- async-websocket
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- ast (2.4.0)
12
- async (1.19.0)
13
- console (~> 1.0)
14
- nio4r (~> 2.3)
15
- timers (~> 4.1)
16
- async-http (0.45.8)
17
- async (~> 1.19)
18
- async-io (~> 1.18)
19
- protocol-http (~> 0.8.0)
20
- protocol-http1 (~> 0.8.0)
21
- protocol-http2 (~> 0.8.0)
22
- async-io (1.23.1)
23
- async (~> 1.14)
24
- async-rest (0.9.0)
25
- async-http (~> 0.42)
26
- protocol-http (~> 0.7)
27
- async-rspec (1.12.2)
28
- rspec (~> 3.0)
29
- async-websocket (0.12.1)
30
- async-http (~> 0.43)
31
- async-io (~> 1.23)
32
- protocol-websocket (~> 0.6.0)
33
- console (1.3.2)
34
- covered (0.13.1)
35
- async-rest
36
- console (~> 1.0)
37
- msgpack
38
- parser
39
- diff-lcs (1.3)
40
- msgpack (1.3.0)
41
- nio4r (2.3.1)
42
- parser (2.6.3.0)
43
- ast (~> 2.4.0)
44
- protocol-hpack (1.4.1)
45
- protocol-http (0.8.1)
46
- protocol-http1 (0.8.0)
47
- protocol-http (~> 0.5)
48
- protocol-http2 (0.8.2)
49
- protocol-hpack (~> 1.4)
50
- protocol-http (~> 0.2)
51
- protocol-websocket (0.6.1)
52
- protocol-http (~> 0.2)
53
- protocol-http1 (~> 0.2)
54
- rake (10.5.0)
55
- rspec (3.8.0)
56
- rspec-core (~> 3.8.0)
57
- rspec-expectations (~> 3.8.0)
58
- rspec-mocks (~> 3.8.0)
59
- rspec-core (3.8.1)
60
- rspec-support (~> 3.8.0)
61
- rspec-expectations (3.8.4)
62
- diff-lcs (>= 1.2.0, < 2.0)
63
- rspec-support (~> 3.8.0)
64
- rspec-mocks (3.8.1)
65
- diff-lcs (>= 1.2.0, < 2.0)
66
- rspec-support (~> 3.8.0)
67
- rspec-support (3.8.2)
68
- timers (4.3.0)
69
-
70
- PLATFORMS
71
- ruby
72
-
73
- DEPENDENCIES
74
- async-rspec
75
- async-slack!
76
- bundler
77
- covered
78
- rake (~> 10.0)
79
- rspec (~> 3.0)
80
-
81
- BUNDLED WITH
82
- 2.0.1