1
0
Fork 0

Readme fixes

This commit is contained in:
Gregory Eremin 2012-08-26 08:21:02 +04:00
parent d2cb07cb4e
commit f0f1730fc3
2 changed files with 27 additions and 9 deletions

View File

@ -1,6 +1,6 @@
# Robbie
Rovi API wrapper
[Rovi](http://developer.rovicorp.com/Get_Started) API wrapper
## Installation
@ -21,16 +21,21 @@ $ gem install robbie
## Usage
*Working with models*
Working with models
```ruby
require "robbie"
Robbie.setup(api_key: "your api key", api_secret: "your api secret")
foo = Robbie::Artist.find_by_name("foo fighters")
# <Robbie::Artist:0x007fb9cbd7c120 @id="MA0000002613", @name="Foo Fighters", @is_group=true, @genres=[#<Robbie::Genre:0x007fb9cbd7c2b0 @id="MA0000002613", @name="Pop/Rock">]>
# <Robbie::Artist:0x007fb9cbd7c120
# @id="MA0000002613",
# @name="Foo Fighters",
# @is_group=true,
# @genres=[#<Robbie::Genre:0x007fb9cbd7c2b0 @id="MA0000002613", @name="Pop/Rock">]
# >
# ...or directly by id
foo = Robbie::Artist.find_by_name("MA0000002613")
foo = Robbie::Artist.find("MA0000002613")
foo.albums.last
# <Robbie::Album:0x007fb9cc16b790 @id="MW0002115022", @title="Wasting Light">
@ -39,7 +44,14 @@ foo.albums.last
Robbie::Album.find("MW0002115022")
foo.albums.last.tracks.first
# <Robbie::Track:0x007fa633a39540 @id="MT0041016087", @disc_id=1, @position=1, @artists=[#<Robbie::Artist:0x007fa633a397e8 @id="MN0000184043", @name="Foo Fighters">], @title="Bridge Burning", @duration=286>
# <Robbie::Track:0x007fa633a39540
# @id="MT0041016087",
# @disc_id=1,
# @position=1,
# @artists=[#<Robbie::Artist:0x007fa633a397e8 @id="MN0000184043", @name="Foo Fighters">],
# @title="Bridge Burning",
# @duration=286
# >
# ...or directly by id
Robbie::Track.find("MT0041016087")
@ -48,13 +60,19 @@ Robbie::Track.find("MT0041016087")
Autocomplete and extended autocomplete
```ruby
Robbie::Autocomplete.complete("b")
# ["Beyoncé", "Bruno Mars", "Bad Meets Evil", "Bon Iver", "Bob Marley", "Big Sean", "The Band Perry", "Blake Shelton", "B.O.B", "The Black Eyed Peas"]
# ["Beyoncé", "Bruno Mars", "Bad Meets Evil", "Bon Iver", "Bob Marley",
# "Big Sean", "The Band Perry", "Blake Shelton", "B.O.B", "The Black Eyed Peas"]
Robbie::Autocomplete.predict("b").first
# <Robbie::Artist:0x007fa633b31ba0 @id="MN0000761179", @name="Beyoncé", @is_group=false, @genres=[#<Robbie::Genre:0x007fa633b31e48 @id="MA0000002809", @name="R&B">]>
# <Robbie::Artist:0x007fa633b31ba0
# @id="MN0000761179",
# @name="Beyoncé",
# @is_group=false,
# @genres=[#<Robbie::Genre:0x007fa633b31e48 @id="MA0000002809", @name="R&B">]
# >
```
*You can turn response caching*
You can turn response caching
```ruby
# on
Robbie.enable_cache

View File

@ -17,7 +17,7 @@ require "robbie/models/genre"
require "robbie/autocomplete"
module Robbie
@@cache_enabled = true
@@cache_enabled = false
class << self
def setup(params)
const_set(:API_KEY, params[:api_key])