Module: Nervion
- Defined in:
- lib/nervion/client.rb,
lib/nervion/facade.rb,
lib/nervion/stream.rb,
lib/nervion/request.rb,
lib/nervion/version.rb,
lib/nervion/oauth_header.rb,
lib/nervion/configuration.rb,
lib/nervion/stream_parser.rb,
lib/nervion/callback_table.rb,
lib/nervion/stream_handler.rb,
lib/nervion/oauth_signature.rb,
lib/nervion/percent_encoder.rb,
lib/nervion/reconnection_scheduler.rb
Defined Under Namespace
Modules: PercentEncoder, Request Classes: CallbackTable, Client, Configuration, ErrorCounter, Get, HttpError, HttpWaitCalculator, NetworkWaitCalculator, OAuthHeader, OAuthSignature, Post, ReconnectionScheduler, Stream, StreamHandler, StreamParser, TooManyConnectionErrors, WaitCalculator
Constant Summary collapse
- VERSION =
'0.0.4'
Class Method Summary collapse
-
.close_stream ⇒ Object
Stops streaming but keeps EventMachine’s event loop running.
-
.configure {|config| ... } ⇒ Object
Allows to configure Nervion.
-
.filter(params, &callback) ⇒ Object
Sets up the message callback and starts streaming the filter endpoint.
-
.firehose(params = {}, &callback) ⇒ Object
Sets up the message callback and starts streaming the firehose endpoint.
-
.on_http_error(&callback) ⇒ self
Sets up the callback to be called upon HTTP errors (when the response from Twitter’s Streaming API has a status above 200).
-
.on_network_error(&callback) ⇒ self
Sets up the callback to be called upon network errors or unexpected disconnection.
-
.running? ⇒ boolean
Whether Nervion is running or not.
-
.sample(params = {}, &callback) ⇒ Object
Sets up the message callback and starts streaming the sample endpoint.
-
.stop ⇒ Object
Stops streaming and stops EventMachine’s event loop.
Class Method Details
.close_stream ⇒ Object
Stops streaming but keeps EventMachine’s event loop running
97 98 99 |
# File 'lib/nervion/facade.rb', line 97 def self.close_stream @client.close_stream end |
.configure {|config| ... } ⇒ Object
Allows to configure Nervion.
6 7 8 9 |
# File 'lib/nervion/configuration.rb', line 6 def self.configure Configuration.configured! yield Configuration end |
.filter(params, &callback) ⇒ Object
At least one predicate parameter (follow, locations, or track) must be specified.
Sets up the message callback and starts streaming the filter endpoint.
66 67 68 |
# File 'lib/nervion/facade.rb', line 66 def self.filter(params, &callback) stream filter_endpoint(params), callback end |
.firehose(params = {}, &callback) ⇒ Object
This endpoint requires a special access level.
Sets up the message callback and starts streaming the firehose endpoint.
87 88 89 |
# File 'lib/nervion/facade.rb', line 87 def self.firehose(params = {}, &callback) stream firehose_endpoint(params), callback end |
.on_http_error(&callback) ⇒ self
Sets up the callback to be called upon HTTP errors (when the response from Twitter’s Streaming API has a status above 200).
12 13 14 15 |
# File 'lib/nervion/facade.rb', line 12 def self.on_http_error(&callback) callback_table[:http_error] = callback self end |
.on_network_error(&callback) ⇒ self
Sets up the callback to be called upon network errors or unexpected disconnection.
22 23 24 25 |
# File 'lib/nervion/facade.rb', line 22 def self.on_network_error(&callback) callback_table[:network_error] = callback self end |
.running? ⇒ boolean
Returns whether Nervion is running or not.
102 103 104 |
# File 'lib/nervion/facade.rb', line 102 def self.running? not @client.nil? end |
.sample(params = {}, &callback) ⇒ Object
Sets up the message callback and starts streaming the sample endpoint.
39 40 41 |
# File 'lib/nervion/facade.rb', line 39 def self.sample(params = {}, &callback) stream sample_endpoint(params), callback end |
.stop ⇒ Object
Stops streaming and stops EventMachine’s event loop
92 93 94 |
# File 'lib/nervion/facade.rb', line 92 def self.stop @client.stop end |