https://github.com/peterhellberg/nobel
Ruby client for the Nobel Prize API
https://github.com/peterhellberg/nobel
Last synced: 12 months ago
JSON representation
Ruby client for the Nobel Prize API
- Host: GitHub
- URL: https://github.com/peterhellberg/nobel
- Owner: peterhellberg
- License: mit
- Created: 2013-01-30T05:05:00.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2013-09-23T16:53:44.000Z (over 12 years ago)
- Last Synced: 2025-02-15T06:02:43.272Z (12 months ago)
- Language: Ruby
- Homepage:
- Size: 137 KB
- Stars: 9
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Nobel
A small API client for the Nobel Prize API.
You can find out more on the official [Developer Zone](http://www.nobelprize.org/nobel_organizations/nobelmedia/nobelprize_org/developer/)
There is also an API Console on [API HQ](http://console.apihq.com/nobel-prize-api)
[](https://travis-ci.org/peterhellberg/nobel)
## Dependencies
Nope.
## Installation
Add this line to your application's Gemfile:
gem 'nobel'
And then execute:
$ bundle
Or install it yourself as:
$ gem install nobel
## Usage
It is probably a good idea to take a look in `specs`
### Prize
```ruby
# All Nobel Prizes in 2010
Nobel::Prize.all year: 2010
# All Peace Prizes
Nobel::Prize.all category: 'peace'
```
### Laureate
The laureate data contains their prizes (and affiliations)
```ruby
# Find a Nobel Laureate by ID
nelly = Nobel::Laureate.find 640
# Show the categories Nelly won
nelly.categories #=> ["literature"]
# Show the years Nelly won
nelly.years #=> [1966]
# Find all living female Nobel Laureates
# (`query` is an alias to `all`)
Nobel::Laureate.query diedDate: '0000', gender: 'female'
```
### Country
The country data only contains the country code and name.
```ruby
# To return a list of all known countries
Nobel::Country.all
# To find a specific country
Nobel::Country.find 'FR' #=> #
# You can also find by name
Nobel::Country.find 'Germany', :name #=> #
```
### Configuration
Nothing needs to be configured out of the box, but you can change the
`api_host`, `api_version`, `json_parser`, `http_client` and `debug`
settings like this:
```ruby
Nobel.configure do |c|
c.api_host = 'nobel.api'
c.api_version = 'v42'
c.json_parser = ->(json) { Oj.load(json) }
c.http_client = MyOwnHttpClient
c.debug = true
end
```
## Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request