server_sent_events 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/server_sent_events.rb +15 -2
- data/lib/server_sent_events/version.rb +1 -1
- 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: e78a58f0bae0af943ea4eb80dc128d25e61e242390e14e5c58050d68dbe4ff2c
|
4
|
+
data.tar.gz: b241e5065b1981b941b9f4c517008ecc7b228577c06dabc1d55012df4ca57a58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c56f578a27e59e90f98fb2d9a92fa44fd42f207b6594b2226f41c6ac1b4066f9045abb8c487ed87026a318b0cf4f41d57ff5942701c43f2c9a0a441feaa596a9
|
7
|
+
data.tar.gz: e42101bca2af7b0f147437fa9524ca1112d56adad6970ad8d34dd523f7e0ec75fe475265f99fc42e51476a7b7a05c44d40c145413965e23428b463531f1d0ed0
|
data/lib/server_sent_events.rb
CHANGED
@@ -7,7 +7,7 @@ require "server_sent_events/client"
|
|
7
7
|
require "server_sent_events/parser"
|
8
8
|
|
9
9
|
module ServerSentEvents
|
10
|
-
# Convenience method
|
10
|
+
# Convenience method to get up-and-running fast.
|
11
11
|
#
|
12
12
|
# In order to start listening to server events, this is all the code that we
|
13
13
|
# need:
|
@@ -15,7 +15,20 @@ module ServerSentEvents
|
|
15
15
|
# ServerSentEvents.listen("http://example.com") do |event|
|
16
16
|
# puts event
|
17
17
|
# end
|
18
|
+
#
|
19
|
+
# @param address [String, URI] SSE endpoint
|
20
|
+
# @param headers [Hash] HTTP headers to use when connecting
|
21
|
+
# @param callback code block that should be executed on event arrival
|
18
22
|
def self.listen(address, headers = {}, &callback)
|
19
|
-
|
23
|
+
create_client(address, headers).listen(&callback)
|
24
|
+
end
|
25
|
+
|
26
|
+
# Create new client that uses default parser to parse events.
|
27
|
+
#
|
28
|
+
# @param address [String, URI] SSE endpoint
|
29
|
+
# @param headers [Hash] HTTP headers to use when connecting
|
30
|
+
# @return [Client] client
|
31
|
+
def self.create_client(address, headers = {})
|
32
|
+
Client.new(URI(address), Parser.new, headers)
|
20
33
|
end
|
21
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: server_sent_events
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tadej Borovšak
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-09-
|
11
|
+
date: 2018-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|