Gem to make interacting with http://api.dirble.com/ amazingly easy. Using familiar Rails syntax. It uses Faraday and Typhoeus as adapter.
- Ruby 1.9.3 and 2
- Rubinius
Add this line to your application's Gemfile:
gem'dirble'And then execute:
$ bundle
Or install it yourself as:
$ gem install dirble
In Rails: Put this quick configuration block in environment file. Beyond Rails: Put this in initialization or config file.
Dirble.configuredo |config|
config.api_key="valid_api_key_from_dirble"endNow you are ready to go.
Fetch all categories with
Dirble::Category.allFetch primary categories with
Dirble::Category.primaryorDirble::PrimaryCategory.allFind category by id
Dirble::Category.find(2)Get first category
Dirble::Category.firstFind children of primary category
primary_category=Dirble::PrimaryCategory.firstchildren=primary_category.childrenFind stations of category
category.stationsCategory details
category.idcategory.namecategory.descriptionSearch stations
Dirble::Station.search('pop')Stations by continent
Dirble::Station.by_continent('Asia')Stations by country using iso code
Dirble::Station.by_country('us')Stations by country name
Dirbel::Station.by_country_name('United States')Stations amount. Check currently registered stations in Dirble.
Dirble::Station.countFind station by id
Dirble::Station.find(100)Adding new station to directory (website, name and directory are required fields)
params_for_creation={name: 'New station',website: 'www.new-station.com',directory: 'Pop'}Dirble::Station.create(params_for_creation)- Station details
station.namestation.websitestation.bitratestation.directorystation.descriptionstation.stream_urlstation.statusAccessing song history by station, information available only after
Dirble::Station.find(id)station.song_history
Songs in song history have many interesting informations.
Name and title
song.namesong.titleSpotify url
song.spotify_urlWhen last played on particular station
song.played_on
- Add parallel connections with Typhoeus
- Fork it ( https://github.com/[my-github-username]/dirble/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
