Ably

Build Status Gem Version

A Ruby REST client library for ably.io, the real-time messaging service.

Note: This library was created solely for developers who do not want EventMachine as a dependency of their application. If this is not a requirement for you, then we recommended you use the combined REST & Real-time gem.

Installation

The client library is available as a gem from RubyGems.org.

Add this line to your application's Gemfile:

gem 'ably-rest'

And then execute:

$ bundle

Or install it yourself as:

$ gem install ably-rest

Using the REST API

All examples assume a client and/or channel has been created as follows:

client = Ably::Rest.new(api_key: 'xxxxx')
channel = client.channel('test')

Publishing a message to a channel

channel.publish('myEvent', 'Hello!') #=> true

Querying the History

mesage_history = channel.history #=> #<Ably::Models::PaginatedResource ...>
message_history.first # => #<Ably::Models::Message ...>

Presence on a channel

members = channel.presence.get # => #<Ably::Models::PaginatedResource ...>
members.first # => #<Ably::Models::PresenceMessage ...>

Querying the Presence History

presence_history = channel.presence.history # => #<Ably::Models::PaginatedResource ...>
presence_history.first # => #<Ably::Models::PresenceMessage ...>

Generate Token and Token Request

client.auth.request_token
# => #<Ably::Models::Token ...>

token = client.auth.create_token_request
# => {"id"=>...,
#     "clientId"=>nil,
#     "ttl"=>3600,
#     "timestamp"=>...,
#     "capability"=>"{\"*\":[\"*\"]}",
#     "nonce"=>...,
#     "mac"=>...}

client = Ably::Rest.new(token_id: token.id)

Fetching your application's stats

stats = client.stats #=> #<Ably::Models::PaginatedResource ...>
stats.first = #<Ably::Models::Stat ...>

Fetching the Ably service time

client.time #=> 2013-12-12 14:23:34 +0000

Support, feedback and troubleshooting

Please visit http://support.ably.io/ for access to our knowledgebase and to ask for any assistance.

You can also view the community reported Github issues.

To see what has changed in recent versions of Bundler, see the CHANGELOG.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Ensure you have added suitable tests and the test suite is passing(bundle exec rspec)
  5. Push to the branch (git push origin my-new-feature)
  6. Create a new Pull Request

License

Copyright (c) 2015 Ably Real-time Ltd, Licensed under the Apache License, Version 2.0. Refer to LICENSE for the license terms.