1
0
Fork 0
robbie/README.md

90 lines
1.9 KiB
Markdown
Raw Normal View History

2012-08-26 04:09:00 +00:00
# Robbie
2012-08-26 04:21:02 +00:00
[Rovi](http://developer.rovicorp.com/Get_Started) API wrapper
2012-08-26 04:09:00 +00:00
## Installation
Add this line to your application's Gemfile:
```ruby
gem "robbie"
```
And then execute:
```bash
$ bundle
```
Or install it yourself as:
```bash
$ gem install robbie
```
## Usage
2012-08-26 04:21:02 +00:00
Working with models
2012-08-26 04:09:00 +00:00
```ruby
require "robbie"
Robbie.setup(api_key: "your api key", api_secret: "your api secret")
foo = Robbie::Artist.find_by_name("foo fighters")
2012-08-26 04:21:02 +00:00
# <Robbie::Artist:0x007fb9cbd7c120
# @id="MA0000002613",
# @name="Foo Fighters",
# @is_group=true,
# @genres=[#<Robbie::Genre:0x007fb9cbd7c2b0 @id="MA0000002613", @name="Pop/Rock">]
# >
2012-08-26 04:09:00 +00:00
# ...or directly by id
2012-08-26 04:21:02 +00:00
foo = Robbie::Artist.find("MA0000002613")
2012-08-26 04:09:00 +00:00
foo.albums.last
# <Robbie::Album:0x007fb9cc16b790 @id="MW0002115022", @title="Wasting Light">
# ...or directly by id
Robbie::Album.find("MW0002115022")
foo.albums.last.tracks.first
2012-08-26 04:21:02 +00:00
# <Robbie::Track:0x007fa633a39540
# @id="MT0041016087",
# @disc_id=1,
# @position=1,
# @artists=[#<Robbie::Artist:0x007fa633a397e8 @id="MN0000184043", @name="Foo Fighters">],
# @title="Bridge Burning",
# @duration=286
# >
2012-08-26 04:09:00 +00:00
# ...or directly by id
Robbie::Track.find("MT0041016087")
```
Autocomplete and extended autocomplete
```ruby
Robbie::Autocomplete.complete("b")
2012-08-26 04:21:02 +00:00
# ["Beyoncé", "Bruno Mars", "Bad Meets Evil", "Bon Iver", "Bob Marley",
# "Big Sean", "The Band Perry", "Blake Shelton", "B.O.B", "The Black Eyed Peas"]
2012-08-26 04:09:00 +00:00
Robbie::Autocomplete.predict("b").first
2012-08-26 04:21:02 +00:00
# <Robbie::Artist:0x007fa633b31ba0
# @id="MN0000761179",
# @name="Beyoncé",
# @is_group=false,
# @genres=[#<Robbie::Genre:0x007fa633b31e48 @id="MA0000002809", @name="R&B">]
# >
2012-08-26 04:09:00 +00:00
```
2012-08-26 04:21:02 +00:00
You can turn response caching
2012-08-26 04:09:00 +00:00
```ruby
# on
Robbie.enable_cache
# and off
Robbie.disable_cache
```
## Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Added some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request