async_cable 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 51ecb6cb916b09cf5f40b62a9be1ddd360fabbb782977ec5da1f1a0babfbc361
4
- data.tar.gz: 3036bbc16779cd6211e6b5f3d513028f84ccab08491395c844307fed7d4caf85
3
+ metadata.gz: 998abf5f3d5c77b7708cc89f7959e96240c41d1e9d03969b835dfe6feb3bd965
4
+ data.tar.gz: 598c96f04bd6081fbb87f4652ef5c7934e6bc0ca56f6b7fa71af3dce2413f8ea
5
5
  SHA512:
6
- metadata.gz: 480548a0bcf0e13f62fccb45cdaac42223f0573d552420b2c9ea286f2b1561ff0d6d8195cb20494b689e4c5aa387d7519d47355f67d0b2c54c32b6353f3e9a35
7
- data.tar.gz: 742caf72b09cee54c0b36a1014bd794b9f59bbca68c88c9bf9df387c0bfad191b1a633a2c735ae9abf2b225d5e2ee518fd469823ede76acf86f81cad8b1d2882
6
+ metadata.gz: 8e46330cb55642128c2dc7023b93aa2137605bb5cfa3c8fbfc19c834eab67acb8a62fa2941367235d575555e2084ad7a21e2befc907582f2c57281fc1131f6b4
7
+ data.tar.gz: 93bcf416e3e8a6c116d26a2a2e66cfbb440009933712aa0155f52465e03add44057080adf7f941943215fde75881c06c8d64fd0fae85be428de2de37fd6c3a4d
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ### Unreleased
4
+
5
+ ### 0.2.1
6
+ * fix registry
7
+
3
8
  ### 0.2.0
4
9
  * fix config.rb requiring
5
10
  * broadcast async connection iteration
data/README.md CHANGED
@@ -94,6 +94,11 @@ example of JS code for connecting with websocket server
94
94
 
95
95
  ## Development
96
96
 
97
+ ### Building version
98
+
99
+ gem_push=false rake release
100
+ gem push pkg/async_cable-X.Y.Z.gem
101
+
97
102
  will use [Semver](https://semver.org) from version `1.0.0`
98
103
 
99
104
  ## Contributing
data/lib/async_cable.rb CHANGED
@@ -6,14 +6,19 @@ require 'async_cable/connection'
6
6
  require 'async_cable/server'
7
7
 
8
8
  module AsyncCable
9
+
10
+ # @return [Async::Config]
9
11
  def config
10
12
  @config ||= Config.new
11
13
  end
12
14
 
15
+ # @yield [Async::Config]
13
16
  def configure
14
17
  yield config
15
18
  end
16
19
 
20
+ # Transmit data to all WS connections.
21
+ # @param data [Hash]
17
22
  def broadcast(data)
18
23
  config.logger.debug { "#{name}.broadcast data=#{data.inspect}" }
19
24
  Registry.each { |conn| conn.transmit(data) }
@@ -9,14 +9,17 @@ module AsyncCable
9
9
  subclass.identified_as subclass.name.demodulize.underscore
10
10
  end
11
11
 
12
+ # sets #channel_name for connection class
12
13
  def identified_as(channel)
13
14
  @channel_name = channel.to_s
14
15
  end
15
16
 
17
+ # @return [String]
16
18
  def channel_name
17
19
  @channel_name
18
20
  end
19
21
 
22
+ # @return [Logger]
20
23
  def logger
21
24
  AsyncCable.config.logger
22
25
  end
@@ -77,6 +80,8 @@ module AsyncCable
77
80
  @stream_name
78
81
  end
79
82
 
83
+ # @param reason [String,NilClass] exception message.
84
+ # @raise [AsyncCable::UnauthorizedError]
80
85
  def reject_unauthorized(reason = nil)
81
86
  raise UnauthorizedError, reason
82
87
  end
@@ -94,6 +99,7 @@ module AsyncCable
94
99
  close_code == Protocol::WebSocket::Error::NO_ERROR
95
100
  end
96
101
 
102
+ # Called when connection being opened.
97
103
  # @param env [Hash]
98
104
  # @raise [AsyncCable::Errors::StreamNameNotSet] if #stream_for was not called
99
105
  # @raise [AsyncCable::Errors::UnauthorizedError] if #reject_unauthorized was called
@@ -105,6 +111,8 @@ module AsyncCable
105
111
  Registry.add(channel_name, stream_name, self)
106
112
  end
107
113
 
114
+ # Called when connection being closed.
115
+ # @see #close_code #close_reason for close details.
108
116
  def handle_close
109
117
  logger.debug { "#{self.class}#handle_close clean=#{close_clean?} code=#{close_code} reason=#{close_reason}" }
110
118
  close
@@ -112,10 +120,12 @@ module AsyncCable
112
120
  on_close
113
121
  end
114
122
 
123
+ # @return [String]
115
124
  def channel_name
116
125
  self.class.channel_name
117
126
  end
118
127
 
128
+ # @return [Logger]
119
129
  def logger
120
130
  self.class.logger
121
131
  end
@@ -6,12 +6,14 @@ module AsyncCable
6
6
  end
7
7
  end
8
8
 
9
+ # @see AsyncCable::Connection#handle_open
9
10
  class StreamNameNotSet < Error
10
11
  def initialize(class_name)
11
12
  super("#stream_for must be called with stream name in #{class_name}#on_open")
12
13
  end
13
14
  end
14
15
 
16
+ # @see AsyncCable::Connection#reject_unauthorized
15
17
  class UnauthorizedError < Error
16
18
  def initialize(reason = nil)
17
19
  super(reason || 'unauthorized')
@@ -7,7 +7,7 @@ module AsyncCable
7
7
  extend SingleForwardable
8
8
  @mutex = Mutex.new
9
9
 
10
- single_delegate [:add, :remove, :find, :all] => :instance
10
+ single_delegate [:add, :remove, :find, :each] => :instance
11
11
 
12
12
  # Adds connection to registry.
13
13
  # @param channel_name [String]
@@ -41,8 +41,6 @@ module AsyncCable
41
41
  response || [400, { 'Content-Type' => 'text/plain' }, ['Not valid ws']]
42
42
  end
43
43
 
44
- private
45
-
46
44
  def logger
47
45
  AsyncCable.config.logger
48
46
  end
@@ -1,3 +1,3 @@
1
1
  module AsyncCable
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async_cable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Talakevich