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

Class Method Details

.close_streamObject

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.

Yield Parameters:



6
7
8
9
# File 'lib/nervion/configuration.rb', line 6

def self.configure
  Configuration.configured!
  yield Configuration
end

.filter(params, &callback) ⇒ Object

Note:

At least one predicate parameter (follow, locations, or track) must be specified.

Sets up the message callback and starts streaming the filter endpoint.

Parameters:

  • params (hash)

    the parameters submitted to the sample endpoint

  • callback (Proc)

    the callback

Options Hash (params):

  • :follow (String)

    a comma separated list of user IDs, indicating the users to return statuses for in the stream.

  • :track (String)

    keywords to track. Phrases of keywords are specified by a comma-separated list.

  • :locations (String)

    Specifies a set of bounding boxes to track.

  • :delimited (Boolean)

    specifies whether messages should be length-delimited.

  • :stall_warnings (Boolean)

    specifies whether stall warnings should be delivered.

See Also:



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

Note:

This endpoint requires a special access level.

Sets up the message callback and starts streaming the firehose endpoint.

Parameters:

  • params (hash) (defaults to: {})

    the parameters submitted to the sample endpoint

  • callback (Proc)

    the callback

Options Hash (params):

  • :count (Integer)

    the number of messages to backfill.

  • :delimited (Boolean)

    specifies whether messages should be length-delimited.

  • :stall_warnings (Boolean)

    specifies whether stall warnings should be delivered.

See Also:

Since:

  • 0.0.2



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).

Parameters:

  • callback (Proc)

    the callback

Returns:

  • (self)

    to allow callback setup chaining



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.

Parameters:

  • callback (Proc)

    the callback

Returns:

  • (self)

    to allow callback setup chaining



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.

Returns:

  • (boolean)

    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.

Parameters:

  • params (hash) (defaults to: {})

    the parameters submitted to the sample endpoint

  • callback (Proc)

    the callback

Options Hash (params):

  • :delimited (Boolean)

    specifies whether messages should be length-delimited.

  • :stall_warnings (Boolean)

    specifies whether stall warnings should be delivered.

See Also:



39
40
41
# File 'lib/nervion/facade.rb', line 39

def self.sample(params = {}, &callback)
  stream sample_endpoint(params), callback
end

.stopObject

Stops streaming and stops EventMachine’s event loop



92
93
94
# File 'lib/nervion/facade.rb', line 92

def self.stop
  @client.stop
end