chicago_crimes_one_year 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +47 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/chicago_crimes_one_year.gemspec +25 -0
- data/lib/chicago_crimes_one_year.rb +47 -0
- data/lib/chicago_crimes_one_year/version.rb +3 -0
- metadata +99 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 02eb6274c2fc5d8b24fd1dbc3f70f42c50ff18e5
|
4
|
+
data.tar.gz: 8c0690266f83315a06f2769327f8b0d34288b85b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 95095b49d7be8ccdd5e58c09b91c548ca299e0666b9ce95c03e9340b16845ecc2365b64cfc394534f4efa704fa51395d839e57aee61eda370ffa6cc54982449b
|
7
|
+
data.tar.gz: b54d049d242d670c3c6d52232db673b6481db005a9890ce957927fb427e7c9e9bb8608ae7bb8a602f3b6699d9a7d547f189ebd522b85e427e49784e2d8fa3cfa
|
data/.gitignore
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 writeclubchicago1@yahoo.com
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# ChicagoCrimesOneYear
|
2
|
+
|
3
|
+
This is a gem that allows you to easily access data about crime in Chicago.
|
4
|
+
This is free data available from the city's open data portal at https://data.cityofchicago.org/Public-Safety/Crimes-One-year-prior-to-present/x2n5-8w5q.
|
5
|
+
"This dataset reflects reported incidents of crime (with the exception of murders where data exists for each victim) that have occurred in the City of Chicago over the past year, minus the most recent seven days of data."
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'chicago_crimes_one_year'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install chicago_crimes_one_year
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
To retrieve all the Chicago employees, use this command:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
ChicagoCrimesOneYear::Crime.all
|
29
|
+
```
|
30
|
+
|
31
|
+
To retrieve employees based on a specific search term:
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
ChicagoCrimesOneYear::Crime.find(YOUR-SEARCH-TERM-HERE)
|
35
|
+
example:
|
36
|
+
ChicagoCrimesOneYear::Crime.find(Western)
|
37
|
+
example:
|
38
|
+
ChicagoCrimesOneYear::Crime.find(Robbery)
|
39
|
+
```
|
40
|
+
|
41
|
+
## Contributing
|
42
|
+
|
43
|
+
1. Fork it ( https://github.com/[my-github-username]/chicago_crimes_one_year/fork )
|
44
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
45
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
46
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
47
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "chicago_crimes_one_year"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'chicago_crimes_one_year/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "chicago_crimes_one_year"
|
8
|
+
spec.version = ChicagoCrimesOneYear::VERSION
|
9
|
+
spec.authors = ["Jeff Carpenter"]
|
10
|
+
spec.email = ["writeclubchicago1 at yahoo.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{A free API Wrapper for Chicago Crimes from present searching back one year from the Chicago Open Data Portal.}
|
13
|
+
spec.description = %q{A free API Wrapper for Chicago Crimes from present searching back one year from the Chicago Open Data Portal. See https://data.cityofchicago.org/Public-Safety/Crimes-One-year-prior-to-present/x2n5-8w5q.}
|
14
|
+
spec.homepage = "https://github.com/writeclubchicago/chicago_crimes_one_year"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.8"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
|
24
|
+
spec.add_dependency "unirest"
|
25
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require "chicago_crimes_one_year/version"
|
2
|
+
require "unirest"
|
3
|
+
|
4
|
+
module ChicagoCrimesOneYear
|
5
|
+
|
6
|
+
class Crime
|
7
|
+
|
8
|
+
attr_reader :beat :_secondary_description :fbi_cd :x_coordinate :block :domestic :case_ :_iucr :arrest :ward :y_coordinate :date_of_occurence :_primary_description :_location_description
|
9
|
+
|
10
|
+
def initialize(hash)
|
11
|
+
@case = hash["case_"]
|
12
|
+
@primary_description = hash["_primary_description"]
|
13
|
+
@secondary_description = hash["_secondary_description"]
|
14
|
+
@date_of_occurence = hash["date_of_occurence"]
|
15
|
+
@arrest = hash["arrest"]
|
16
|
+
@location_description = hash["_location_description"]
|
17
|
+
@domestic = hash["domestic"]
|
18
|
+
@block = hash["block"]
|
19
|
+
@beat = hash["beat"]
|
20
|
+
@x_coordinate = hash["x_coordinate"]
|
21
|
+
@y_coordinate = hash["y_coordinate"]
|
22
|
+
@fbi_cd = hash["fbi_cd"]
|
23
|
+
@iucr = hash["_iucr"]
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.all
|
27
|
+
crime_array = Unirest.get("https://data.cityofchicago.org/resource/x2n5-8w5q.json").body
|
28
|
+
generate_crimes(crime_array)
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.find(search_term)
|
32
|
+
employee_array = Unirest.get("https://data.cityofchicago.org/resource/x2n5-8w5q.json?$q=#{search_term}").body
|
33
|
+
generate_crimes(crime_array)
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def self.generate_crimes(crime_array)
|
40
|
+
crimes = []
|
41
|
+
crime_array.each do |crime_hash|
|
42
|
+
crimes << Crime.new(crime_hash)
|
43
|
+
end
|
44
|
+
return crimes
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: chicago_crimes_one_year
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jeff Carpenter
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.8'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.8'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: unirest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: A free API Wrapper for Chicago Crimes from present searching back one
|
56
|
+
year from the Chicago Open Data Portal. See https://data.cityofchicago.org/Public-Safety/Crimes-One-year-prior-to-present/x2n5-8w5q.
|
57
|
+
email:
|
58
|
+
- writeclubchicago1 at yahoo.com
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- CODE_OF_CONDUCT.md
|
65
|
+
- Gemfile
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- bin/console
|
70
|
+
- bin/setup
|
71
|
+
- chicago_crimes_one_year.gemspec
|
72
|
+
- lib/chicago_crimes_one_year.rb
|
73
|
+
- lib/chicago_crimes_one_year/version.rb
|
74
|
+
homepage: https://github.com/writeclubchicago/chicago_crimes_one_year
|
75
|
+
licenses:
|
76
|
+
- MIT
|
77
|
+
metadata: {}
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
requirements: []
|
93
|
+
rubyforge_project:
|
94
|
+
rubygems_version: 2.2.2
|
95
|
+
signing_key:
|
96
|
+
specification_version: 4
|
97
|
+
summary: A free API Wrapper for Chicago Crimes from present searching back one year
|
98
|
+
from the Chicago Open Data Portal.
|
99
|
+
test_files: []
|