Chicrime
Chicrime is a ruby gem that wraps the soda-ruby library with easy to use methods. The purpose of Chicrime is to enable users to easily access Chicago's crime data.
Installation
Add this line to your application's Gemfile:
gem 'chicrime'
And then execute:
$ bundle
Or install it yourself as:
$ gem install chicrime
Usage
chicrime = Chicrime::Dataset.new(<OPTIONAL API TOKEN>)
# Add queries with where, select, query, and order
# where
chicrime.where("year = '2014'")
# select
chicrime.select('date', 'arrest', 'location')
# limit
chicrime.limit(5)
# order
chicrime.order("id", :DESC)
# search
chicrime.search("Kingsbury St")
# Chain queries
chicrime.where("year = '2014'", "community_area = '1'").limit(100)
chicrime.where("within_circle(location, 41.8719708, -87.6492965, 500)").order("date")
# Get results
chicrime.where("year = '2014'", "community_area = '1'").order("date").results
# New semi-working DSL, use at your own risk
# where is the only parameter with a block implemented
# available operators include: equals, less_than, greater_than, not_equal
chicrime.query do
where do
year greater_than 2013
arrest equals false
ward not_equal 15
end
search "Kingsbury St"
order :id, :desc
limit 15
select :arrest, :date, :location
end
Resources
Development
TODO
- Implement group parameter
- Documentation
- Hash support for method queries
Contributing
- Fork it ( https://github.com/[my-github-username]/chicrime/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