chicrime 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/README.md +24 -12
- data/chicrime.gemspec +9 -10
- data/lib/chicrime/version.rb +1 -1
- data/lib/chicrime.rb +21 -20
- metadata +64 -36
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 296f179810cd2694aa58f4f589058d28be6f60f0
|
4
|
+
data.tar.gz: 1fd9f41c5505fe9185933034be471af841e8d883
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f23afe47732fc570ed6aea12f3ab3a7620128012111da6b60f1cc4caf28d99be2c63f4d4f34e2008f3fb1a912b2de3d45c9133b696b8de2eedeb7a9b6bc5ea3e
|
7
|
+
data.tar.gz: 3588317ce41f7941395446a9951893620724fac84a604c048290668566932acebc755ac7b9226652427848802e7f5391fa6041b979012234e23845b1a6200390
|
data/.rspec
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Chicrime
|
2
|
-
[![Coverage Status](https://coveralls.io/repos/bloomyminded/chicrime/badge.svg?branch=master&service=github)](https://coveralls.io/github/bloomyminded/chicrime?branch=master)[![Build Status](https://travis-ci.org/bloomyminded/chicrime.png?branch=master)](https://travis-ci.org/bloomyminded/chicrime)
|
2
|
+
[![Coverage Status](https://coveralls.io/repos/bloomyminded/chicrime/badge.svg?branch=master&service=github)](https://coveralls.io/github/bloomyminded/chicrime?branch=master) [![Build Status](https://travis-ci.org/bloomyminded/chicrime.png?branch=master)](https://travis-ci.org/bloomyminded/chicrime) [![Gem Version](https://badge.fury.io/rb/chicrime.svg)](http://badge.fury.io/rb/chicrime)
|
3
3
|
|
4
4
|
Chicrime is a ruby gem that wraps the [soda-ruby](https://github.com/socrata/soda-ruby) library with easy to use methods. The purpose of Chicrime is to enable users to easily access
|
5
5
|
Chicago's crime [data](http://data.cityofchicago.org).
|
@@ -25,27 +25,39 @@ Or install it yourself as:
|
|
25
25
|
```ruby
|
26
26
|
chicrime = Chicrime::Dataset.new(<OPTIONAL API TOKEN>)
|
27
27
|
|
28
|
+
# Add queries with where, select, query, and order
|
28
29
|
|
29
|
-
|
30
|
-
|
30
|
+
# where
|
31
|
+
chicrime.where("year = '2014'")
|
31
32
|
|
32
|
-
|
33
|
-
|
33
|
+
# select
|
34
|
+
chicrime.select('date', 'arrest', 'location')
|
34
35
|
|
35
|
-
|
36
|
-
|
36
|
+
# limit
|
37
|
+
chicrime.limit(5)
|
37
38
|
|
38
|
-
|
39
|
-
|
39
|
+
# order
|
40
|
+
chicrime.order("id", :DESC)
|
40
41
|
|
41
|
-
|
42
|
-
|
42
|
+
# Chain queries
|
43
|
+
chicrime.where("year = '2014'", "community_area = '1'").limit(100)
|
44
|
+
chicrime.where("within_circle(location, 41.8719708, -87.6492965, 500)").order("date")
|
43
45
|
|
46
|
+
# Get results
|
47
|
+
chicrime.where("year = '2014'", "community_area = '1'").order("date").results
|
44
48
|
```
|
45
49
|
|
50
|
+
## Resources
|
51
|
+
|
52
|
+
[API Documentation](http://dev.socrata.com/foundry/#/data.cityofchicago.org/ijzp-q8t2)
|
53
|
+
|
54
|
+
[SoQL Queries](http://dev.socrata.com/docs/queries.html)
|
55
|
+
|
56
|
+
[Location functions](http://dev.socrata.com/docs/datatypes/location.html)
|
57
|
+
|
46
58
|
## Development
|
47
59
|
|
48
|
-
TODO:
|
60
|
+
TODO: Implement group query & documentation
|
49
61
|
|
50
62
|
## Contributing
|
51
63
|
|
data/chicrime.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["codyjroberts@gmail.com"]
|
11
11
|
|
12
12
|
spec.summary = %q{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.}
|
13
|
-
spec.homepage = ""
|
13
|
+
spec.homepage = "http://www.codyjroberts.com"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
@@ -20,14 +20,13 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.8"
|
22
22
|
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
-
spec.add_development_dependency "rspec"
|
24
|
-
spec.add_development_dependency "rspec-its"
|
25
|
-
spec.add_development_dependency "guard"
|
26
|
-
spec.add_development_dependency "guard-rspec"
|
27
|
-
spec.add_development_dependency "
|
28
|
-
spec.add_development_dependency "pry
|
29
|
-
spec.add_development_dependency "
|
30
|
-
spec.add_development_dependency "coveralls"
|
23
|
+
spec.add_development_dependency "rspec", "~> 3.3", '>= 3.3.0'
|
24
|
+
spec.add_development_dependency "rspec-its", "~> 1.2", '>= 1.2.0'
|
25
|
+
spec.add_development_dependency "guard", "~> 2.13", '>= 2.13.0'
|
26
|
+
spec.add_development_dependency "guard-rspec", "~> 4.6", '>= 4.6.0'
|
27
|
+
spec.add_development_dependency "fuubar", "~> 2.0", '>= 2.0.0'
|
28
|
+
spec.add_development_dependency "pry", "~> 0.10", ">= 0.10.1"
|
29
|
+
spec.add_development_dependency "coveralls", '~> 0.8', ">= 0.8.2"
|
31
30
|
|
32
|
-
spec.add_runtime_dependency "soda-ruby"
|
31
|
+
spec.add_runtime_dependency "soda-ruby", "~> 0.2.13"
|
33
32
|
end
|
data/lib/chicrime/version.rb
CHANGED
data/lib/chicrime.rb
CHANGED
@@ -3,39 +3,40 @@ require "soda/client"
|
|
3
3
|
|
4
4
|
module Chicrime
|
5
5
|
class Dataset
|
6
|
-
attr_accessor :client
|
6
|
+
attr_accessor :client, :query
|
7
7
|
attr_reader :dataset_id
|
8
8
|
|
9
9
|
def initialize token=''
|
10
10
|
@client = SODA::Client.new({:domain => 'data.cityofchicago.org', :app_token => token})
|
11
11
|
@dataset_id = 'ijzp-q8t2'
|
12
|
+
@query = {}
|
12
13
|
end
|
13
14
|
|
14
|
-
def
|
15
|
-
query = args * " AND "
|
16
|
-
|
17
|
-
|
18
|
-
else
|
19
|
-
@client.get(@dataset_id, {})
|
20
|
-
end
|
15
|
+
def where *args
|
16
|
+
query = args.count > 0 ? args * " AND " : ""
|
17
|
+
@query.store("$where", "#{query}")
|
18
|
+
self
|
21
19
|
end
|
22
20
|
|
23
|
-
def
|
24
|
-
query =
|
25
|
-
|
26
|
-
|
27
|
-
else
|
28
|
-
@client.get(@dataset_id, {})
|
29
|
-
end
|
21
|
+
def limit n
|
22
|
+
query = n
|
23
|
+
@query.store("$limit", "#{query}")
|
24
|
+
self
|
30
25
|
end
|
31
|
-
|
32
|
-
def
|
33
|
-
|
26
|
+
|
27
|
+
def select *args
|
28
|
+
query = args.count > 0 ? args * ', ' : ''
|
29
|
+
@query.store("$select", "#{query}")
|
30
|
+
self
|
34
31
|
end
|
35
32
|
|
36
|
-
def
|
37
|
-
@
|
33
|
+
def order column, order=:ASC
|
34
|
+
@query.store("$order", "#{column} #{order}")
|
35
|
+
self
|
38
36
|
end
|
39
37
|
|
38
|
+
def results
|
39
|
+
@client.get(@dataset_id, @query)
|
40
|
+
end
|
40
41
|
end
|
41
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chicrime
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cody Roberts
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -42,128 +42,156 @@ dependencies:
|
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.3'
|
45
48
|
- - ">="
|
46
49
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
50
|
+
version: 3.3.0
|
48
51
|
type: :development
|
49
52
|
prerelease: false
|
50
53
|
version_requirements: !ruby/object:Gem::Requirement
|
51
54
|
requirements:
|
55
|
+
- - "~>"
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '3.3'
|
52
58
|
- - ">="
|
53
59
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
60
|
+
version: 3.3.0
|
55
61
|
- !ruby/object:Gem::Dependency
|
56
62
|
name: rspec-its
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
58
64
|
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '1.2'
|
59
68
|
- - ">="
|
60
69
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
70
|
+
version: 1.2.0
|
62
71
|
type: :development
|
63
72
|
prerelease: false
|
64
73
|
version_requirements: !ruby/object:Gem::Requirement
|
65
74
|
requirements:
|
75
|
+
- - "~>"
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '1.2'
|
66
78
|
- - ">="
|
67
79
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
80
|
+
version: 1.2.0
|
69
81
|
- !ruby/object:Gem::Dependency
|
70
82
|
name: guard
|
71
83
|
requirement: !ruby/object:Gem::Requirement
|
72
84
|
requirements:
|
85
|
+
- - "~>"
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '2.13'
|
73
88
|
- - ">="
|
74
89
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
90
|
+
version: 2.13.0
|
76
91
|
type: :development
|
77
92
|
prerelease: false
|
78
93
|
version_requirements: !ruby/object:Gem::Requirement
|
79
94
|
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '2.13'
|
80
98
|
- - ">="
|
81
99
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
100
|
+
version: 2.13.0
|
83
101
|
- !ruby/object:Gem::Dependency
|
84
102
|
name: guard-rspec
|
85
103
|
requirement: !ruby/object:Gem::Requirement
|
86
104
|
requirements:
|
87
|
-
- - "
|
105
|
+
- - "~>"
|
88
106
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
107
|
+
version: '4.6'
|
94
108
|
- - ">="
|
95
109
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: pry
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
110
|
+
version: 4.6.0
|
104
111
|
type: :development
|
105
112
|
prerelease: false
|
106
113
|
version_requirements: !ruby/object:Gem::Requirement
|
107
114
|
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '4.6'
|
108
118
|
- - ">="
|
109
119
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
120
|
+
version: 4.6.0
|
111
121
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
122
|
+
name: fuubar
|
113
123
|
requirement: !ruby/object:Gem::Requirement
|
114
124
|
requirements:
|
125
|
+
- - "~>"
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '2.0'
|
115
128
|
- - ">="
|
116
129
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
130
|
+
version: 2.0.0
|
118
131
|
type: :development
|
119
132
|
prerelease: false
|
120
133
|
version_requirements: !ruby/object:Gem::Requirement
|
121
134
|
requirements:
|
135
|
+
- - "~>"
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '2.0'
|
122
138
|
- - ">="
|
123
139
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
140
|
+
version: 2.0.0
|
125
141
|
- !ruby/object:Gem::Dependency
|
126
|
-
name: pry
|
142
|
+
name: pry
|
127
143
|
requirement: !ruby/object:Gem::Requirement
|
128
144
|
requirements:
|
145
|
+
- - "~>"
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0.10'
|
129
148
|
- - ">="
|
130
149
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
150
|
+
version: 0.10.1
|
132
151
|
type: :development
|
133
152
|
prerelease: false
|
134
153
|
version_requirements: !ruby/object:Gem::Requirement
|
135
154
|
requirements:
|
155
|
+
- - "~>"
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0.10'
|
136
158
|
- - ">="
|
137
159
|
- !ruby/object:Gem::Version
|
138
|
-
version:
|
160
|
+
version: 0.10.1
|
139
161
|
- !ruby/object:Gem::Dependency
|
140
162
|
name: coveralls
|
141
163
|
requirement: !ruby/object:Gem::Requirement
|
142
164
|
requirements:
|
165
|
+
- - "~>"
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '0.8'
|
143
168
|
- - ">="
|
144
169
|
- !ruby/object:Gem::Version
|
145
|
-
version:
|
170
|
+
version: 0.8.2
|
146
171
|
type: :development
|
147
172
|
prerelease: false
|
148
173
|
version_requirements: !ruby/object:Gem::Requirement
|
149
174
|
requirements:
|
175
|
+
- - "~>"
|
176
|
+
- !ruby/object:Gem::Version
|
177
|
+
version: '0.8'
|
150
178
|
- - ">="
|
151
179
|
- !ruby/object:Gem::Version
|
152
|
-
version:
|
180
|
+
version: 0.8.2
|
153
181
|
- !ruby/object:Gem::Dependency
|
154
182
|
name: soda-ruby
|
155
183
|
requirement: !ruby/object:Gem::Requirement
|
156
184
|
requirements:
|
157
|
-
- - "
|
185
|
+
- - "~>"
|
158
186
|
- !ruby/object:Gem::Version
|
159
|
-
version:
|
187
|
+
version: 0.2.13
|
160
188
|
type: :runtime
|
161
189
|
prerelease: false
|
162
190
|
version_requirements: !ruby/object:Gem::Requirement
|
163
191
|
requirements:
|
164
|
-
- - "
|
192
|
+
- - "~>"
|
165
193
|
- !ruby/object:Gem::Version
|
166
|
-
version:
|
194
|
+
version: 0.2.13
|
167
195
|
description:
|
168
196
|
email:
|
169
197
|
- codyjroberts@gmail.com
|
@@ -185,7 +213,7 @@ files:
|
|
185
213
|
- chicrime.gemspec
|
186
214
|
- lib/chicrime.rb
|
187
215
|
- lib/chicrime/version.rb
|
188
|
-
homepage:
|
216
|
+
homepage: http://www.codyjroberts.com
|
189
217
|
licenses:
|
190
218
|
- MIT
|
191
219
|
metadata: {}
|