Wrapper for the Police UK API.
Documentation
The API provides a rich data source for information, including:
- Neighbourhood team members
Todo
- Upcoming events
Todo
- Street-level crime and outcome data
Covered in CrimeFetcher
- Nearest police stations
Todo
The API is implemented as a standard JSON web service using HTTP GET and POST requests. Full request and response examples are provided in the documentation.
Installation
Add this line to your application's Gemfile:
gem 'crime-fetcher', github: 'ChuckJHardy/CrimeFetcher'
And then execute:
$ bundle
Configuration
CrimeFetcher.configure do |config|
config.domain = "https://data.police.uk/api/v2"
config.verbose = true
config.log = true
config.logger = Rails.logger
end
domain
sets the base urlhttps://data.police.uk/api/
verbose
sets the logger levelfalse
log
should log message be loggedfalse
logger
Logger object.Logger
Usage
Find Exchange Rate:
crime_fetcher = CrimeFetcher.new(lat: 52.629729, lng: -1.131592, date: Date.today)
# => #<CrimeFetcher:0x007f985c021f10>
crime_fetcher.street
# => #<CrimeFetcher::Street:0x007f985c021f10>
crime_fetcher.street.as_hash
# => { ... }
Testing
# Includes Rubocop
$ bin/rspec
Development
After checking out the repo, run bin/setup
to install dependencies. Then, run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
to create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Contributing
- Fork it ( https://github.com/[my-github-username]/CrimeFetcher/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