README.md in ably-0.1.0 vs README.md in ably-0.1.1
- old
+ new
@@ -1,11 +1,13 @@
-# Ably
+# [Ably](https://ably.io)
A Ruby client library for [ably.io](https://ably.io), the real-time messaging service.
## Installation
+The client library is available as a [gem from RubyGems.org](https://rubygems.org/gems/ably).
+
Add this line to your application's Gemfile:
gem 'ably'
And then execute:
@@ -20,78 +22,78 @@
### Subscribing to a channel
Given:
-```
+```ruby
client = Ably::Realtime.new(api_key: "xxxxx")
-
channel = client.channel("test")
```
Subscribe to all events:
-```
+```ruby
channel.subscribe do |message|
message[:name] #=> "greeting"
message[:data] #=> "Hello World!"
end
```
Only certain events:
-```
+```ruby
channel.subscribe("myEvent") do |message|
message[:name] #=> "myEvent"
message[:data] #=> "myData"
end
```
### Publishing to a channel
-```
+```ruby
client = Ably::Realtime.new(api_key: "xxxxx")
-
channel = client.channel("test")
-
channel.publish("greeting", "Hello World!")
```
## Using the REST API
### Publishing a message to a channel
-```
+```ruby
client = Ably::Rest.new(api_key: "xxxxx")
-
channel = client.channel("test")
-
channel.publish("myEvent", "Hello!") #=> true
```
### Fetching a channel's history
-```
+```ruby
client = Ably::Rest.new(api_key: "xxxxx")
-
channel = client.channel("test")
-
channel.history #=> [{:name=>"test", :data=>"payload"}]
```
-### Fetching your application's stats
+### Authentication with a token
-```
+```ruby
client = Ably::Rest.new(api_key: "xxxxx")
+client.auth.authorise # creates a token and will use token authentication moving forwards
+client.auth.current_token #=> #<Ably::Token>
+channel.publish("myEvent", "Hello!") #=> true, sent using token authentication
+```
+### Fetching your application's stats
+
+```ruby
+client = Ably::Rest.new(api_key: "xxxxx")
client.stats #=> [{:channels=>..., :apiRequests=>..., ...}]
```
### Fetching the Ably service time
-```
+```ruby
client = Ably::Rest.new(api_key: "xxxxx")
-
client.time #=> 2013-12-12 14:23:34 +0000
```
## Contributing