0.0
No commit activity in last 3 years
No release in over 3 years
A wrapper around Open Charities API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0.10.5
~> 2.9.0
~> 1.8.8

Runtime

~> 0.8.4
>= 0
 Project Readme

Open Charities

A simple library for querying http://opencharities.org/ database.

Installation

To install as a standalone

$ gem install open-charities

or as a dependency in a Gemfile

gem "open-charities", "~> 0.2.0", require: 'open_charities'

Usage

charity = OpenCharities.lookup("1149855")
=> #<OpenCharities::Response:0x00000001738d30 @attributes={"address"...>

charity['title']
=> "VETERAN'S HEADQUARTERS"

charity.title
=> "VETERAN'S HEADQUARTERS"

charity.charity_number
=> "1149855"

charity.address
=> {"region"=>nil, "raw_address"=>nil, "created_at"=>"2012-11-22T05:00:54+00:00"...}

As can be seen from this example, some of the attributes are exposed as instance methods. More specifically, the methods that are exposed correspond to the top-level keys in the Hash containing information about the charity. As in the above example, the address attribute returns another Hash.

Caching

Requests can be cached by configuring the gem to use an external cache (for example, the Rails cache).

# file config/initializers/open_charities.rb

# swap in your own cache here
OpenCharities.cache = Rails.cache

# Optional
OpenCharities.cache_args = { expires_in: 10.minutes }

Testing

To run the tests, issue rspec spec on the command-line.

Available testing data

There is testing data available spec/data/veteransheadquarters.json. The same data is used by the tests in spec/.