Skip to content
This repository has been archived by the owner on Oct 8, 2018. It is now read-only.

codyjroberts/chicrime

Repository files navigation

Chicrime

Coverage Status Build Status Gem Version

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

API Documentation

SoQL Queries

Location functions

Development

TODO

  • Implement group parameter
  • Documentation
  • Hash support for method queries

Contributing

  1. Fork it ( https://github.com/[my-github-username]/chicrime/fork )
  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 a new Pull Request