Module: Shove
- Defined in:
- lib/shove.rb,
lib/shove/client.rb,
lib/shove/request.rb,
lib/shove/response.rb
Overview
Shove
See shove.io for an account
Defined Under Namespace
Classes: Client, Request, Response
Constant Summary collapse
- Version =
0.3
Class Attribute Summary collapse
-
.client ⇒ Object
Returns the value of attribute client.
-
.config ⇒ Object
Returns the value of attribute config.
Class Method Summary collapse
-
.authorize(uid, channel = "*", &block) ⇒ Object
authorize a user on a private channel
uid
the users idchannel
the channel to authorize them on. -
.broadcast(channel, event, message, &block) ⇒ Object
broadcast a message
channel
the channel to broadcast onevent
the event to triggermessage
the message to send, UTF-8 encoded kthx. -
.configure(settings) ⇒ Object
configure shover
settings
the settings for the created client as a string for a yaml file, or as a hash. -
.direct(uid, event, message, &block) ⇒ Object
direct a message to a specific user
uid
the users idevent
the event to triggermessage
the message to send, UTF-8 encoded kthx. -
.stream(channel, &block) ⇒ Object
act as a stream client.
Class Attribute Details
.client ⇒ Object
Returns the value of attribute client.
17 18 19 |
# File 'lib/shove.rb', line 17 def client @client end |
.config ⇒ Object
Returns the value of attribute config.
17 18 19 |
# File 'lib/shove.rb', line 17 def config @config end |
Class Method Details
.authorize(uid, channel = "*", &block) ⇒ Object
authorize a user on a private channel uid
the users id channel
the channel to authorize them on
53 54 55 |
# File 'lib/shove.rb', line 53 def uid, channel="*", &block client. uid, channel, &block end |
.broadcast(channel, event, message, &block) ⇒ Object
broadcast a message channel
the channel to broadcast on event
the event to trigger message
the message to send, UTF-8 encoded kthx
38 39 40 |
# File 'lib/shove.rb', line 38 def broadcast channel, event, , &block client.broadcast channel, event, , &block end |
.configure(settings) ⇒ Object
configure shover settings
the settings for the created client as a string for a yaml file, or as a hash
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/shove.rb', line 22 def configure settings if settings.kind_of? String self.config = YAML.load_file(settings) elsif settings.kind_of? Hash self.config = settings else raise "Unsupported configuration type" end self.client = Client.new config[:network], config[:key], config end |
.direct(uid, event, message, &block) ⇒ Object
direct a message to a specific user uid
the users id event
the event to trigger message
the message to send, UTF-8 encoded kthx
46 47 48 |
# File 'lib/shove.rb', line 46 def direct uid, event, , &block client.direct uid, event, , &block end |
.stream(channel, &block) ⇒ Object
act as a stream client. requires EM channel
the channel to stream
59 60 61 62 63 64 |
# File 'lib/shove.rb', line 59 def stream channel, &block unless EM.reactor_running? raise "You can stream when running in an Eventmachine event loop. EM.run { #code here }" end raise "Websocket client not implemented yet... soon" end |