chicrime 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f69c25653031948cc4523c954cb81c811d1d2027
4
- data.tar.gz: 5c9f5345113f7f8fcc413c30b1d9f88a30da8ab6
3
+ metadata.gz: ecb54e1ff593b6f4920e16a81717d34c4602c38f
4
+ data.tar.gz: d550052aa5f9fed4c0d1d3cd2305e1e629d01909
5
5
  SHA512:
6
- metadata.gz: 15b2527ee7d4be8144035bdcffa36efae959b2630668cf56bc0f84f7cfeb71f34f8c159749ce6ec8d081b7b0793c6466343a1cd7e9582854805eabc5fe5c5896
7
- data.tar.gz: 6d522998fbbb7d2f42b6d89c3ad23b2272a6572298f24c011ef8530358d3adf1b0f87ca4dc8d40789572cf0a837c48e7dd8217423b463371527dd2ef4c80eca7
6
+ metadata.gz: bafd1681485e4551ac7d64d5a2f9fee8c6096b2d7b70702271587803c72ca5da4f8cfccfc25d998ed4ff7d87f11608a628d77507d37c53f8e2f43f0e6735cef1
7
+ data.tar.gz: ce58f376e1396ea57b2f089fdec72877ddd5805d3770f9a67271d22cd9e33c9341f0efaa0dda60ebb96360d65d4bd8cf16128ff15d96ddd403dddc648bafe1d0
data/README.md CHANGED
@@ -39,6 +39,9 @@ chicrime.limit(5)
39
39
  # order
40
40
  chicrime.order("id", :DESC)
41
41
 
42
+ # search
43
+ chicrime.search("Kingsbury St")
44
+
42
45
  # Chain queries
43
46
  chicrime.where("year = '2014'", "community_area = '1'").limit(100)
44
47
  chicrime.where("within_circle(location, 41.8719708, -87.6492965, 500)").order("date")
@@ -46,11 +49,18 @@ chicrime.where("within_circle(location, 41.8719708, -87.6492965, 500)").order("d
46
49
  # Get results
47
50
  chicrime.where("year = '2014'", "community_area = '1'").order("date").results
48
51
 
49
- # New semi-working DSL
52
+ # New semi-working DSL, use at your own risk
53
+ # where is the only parameter with a block implemented
54
+ # available operators include: equals, less_than, greater_than, not_equal
50
55
  chicrime.query do
51
56
  where do
52
- year equals 2014
57
+ year greater_than 2013
58
+ arrest equals false
59
+ ward not_equal 15
53
60
  end
61
+
62
+ search "Kingsbury St"
63
+
54
64
  order :id, :desc
55
65
  limit 15
56
66
  select :arrest, :date, :location
@@ -68,7 +78,7 @@ end
68
78
  ## Development
69
79
 
70
80
  TODO
71
- - Implement group query
81
+ - Implement group parameter
72
82
  - Documentation
73
83
  - Hash support for method queries
74
84
 
data/chicrime.gemspec CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Cody Roberts"]
10
10
  spec.email = ["codyjroberts@gmail.com"]
11
11
 
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 = "http://www.codyjroberts.com"
12
+ spec.summary = %q{Chicrime is a ruby gem that wraps the soda-ruby library with easy to use methods and a DSL. The purpose of Chicrime is to enable users to easily access Chicago's crime data.}
13
+ spec.homepage = "http://www.github.com/bloomyminded/chicrime"
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)/}) }
data/lib/chicrime.rb CHANGED
@@ -18,20 +18,16 @@ module Chicrime
18
18
  results
19
19
  end
20
20
 
21
+ # TODO: only respond when called inside where block
21
22
  def method_missing m, *args, &block
22
23
  if soql["$where"]
23
24
  prev = soql["$where"] + " AND"
25
+ q = "#{prev} #{m} #{args[0]} #{args[1]}".strip
26
+ @soql.store("$where", "#{q}")
24
27
  else
25
- prev = ""
28
+ q = "#{m} #{args[0]} #{args[1]}".strip
29
+ @soql.store("$where", "#{q}")
26
30
  end
27
-
28
- q = "#{prev} #{m} #{args[0]} #{args[1]}".strip
29
-
30
- @soql.store("$where", "#{q}")
31
- end
32
-
33
- def equals data
34
- "= #{data}"
35
31
  end
36
32
 
37
33
  def where *args, &block
@@ -61,9 +57,29 @@ module Chicrime
61
57
  self
62
58
  end
63
59
 
60
+ def search str
61
+ @soql.store("$q", "#{str}")
62
+ self
63
+ end
64
+
64
65
  def results
65
- puts @soql
66
66
  @client.get(@dataset_id, @soql)
67
67
  end
68
+
69
+ def equals data
70
+ "= #{data}"
71
+ end
72
+
73
+ def greater_than data
74
+ "> #{data}"
75
+ end
76
+
77
+ def less_than data
78
+ "< #{data}"
79
+ end
80
+
81
+ def not_equal data
82
+ "!= #{data}"
83
+ end
68
84
  end
69
85
  end
@@ -1,3 +1,3 @@
1
1
  module Chicrime
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  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.2.1
4
+ version: 0.2.2
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-12-01 00:00:00.000000000 Z
11
+ date: 2015-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -214,7 +214,7 @@ files:
214
214
  - example.rb
215
215
  - lib/chicrime.rb
216
216
  - lib/chicrime/version.rb
217
- homepage: http://www.codyjroberts.com
217
+ homepage: http://www.github.com/bloomyminded/chicrime
218
218
  licenses:
219
219
  - MIT
220
220
  metadata: {}
@@ -238,6 +238,6 @@ rubygems_version: 2.4.6
238
238
  signing_key:
239
239
  specification_version: 4
240
240
  summary: Chicrime is a ruby gem that wraps the soda-ruby library with easy to use
241
- methods. The purpose of Chicrime is to enable users to easily access Chicago's crime
242
- data.
241
+ methods and a DSL. The purpose of Chicrime is to enable users to easily access
242
+ Chicago's crime data.
243
243
  test_files: []