A simple wrapper for the awesome GiantBomb.com API.
Does giant_bomb helps your daily work with Ruby? So, please recommend me in Work With Rails and thanks for your kindness! :)
First, install the gem:
$ [sudo] gem install giant_bomb
Then, add it as a dependency of your code using your favorite way (a simple require or mechanisms like the Bundler gem).
Using it is really simple.
First, you need an API key. Then, configure giant_bomb to use it:
GiantBomb::Configuration.api_key = "my api key"
Now to the real data consumption. There are two kinds of entities: a Resource (single entity) and a ResourceList (list of entities).
An example of Resource is a Game. To get data about a particular game you can do the following:
>> GiantBomb::Game.details(17280) => <#Hashie::Mash name="BioShock" ...>
An example of a ResourceList is a GameList. To get a list of games you can do the following:
>> GiantBomb::GameList.fetch => [<#Hashie::Mash aliases="BioShock" ...>, <#Hashie::Mash aliases="Civilization V" ...>, ...]
As you can see, the gem makes use of Hashie’s Mash, which basically is a Hash with attribute accessors for all keys, meaning you can use the dot notation to access values:
>> game = GiantBomb::Game.details(17280) => <#Hashie::Mash name="BioShock" ...> >> game.name => "BioShock"
For a Resource, the return will always be a Mash instance. For a ResourceList, it will be an Array of Mash instances.
Besides the API key, the Configuration class allows you to configure an adapter to make HTTP requests (you can use the included CurbAdapter. and its specs as an example of implementation) and a logger (STDOUT by default).
Note on Patches/Pull Requests
- Fork the project.
- Make your feature addition or bug fix.
- Add tests for it. This is important so I don’t break it in a
future version unintentionally.
- Commit, do not mess with rakefile, version, or history.
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
- Send me a pull request. Bonus points for topic branches.
sentinel is released under the MIT license. See MIT LICENSE.