socrata 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/socrata.rb +2 -35
  2. data/lib/socrata/data.rb +13 -0
  3. metadata +6 -6
data/lib/socrata.rb CHANGED
@@ -25,7 +25,7 @@ require 'pp'
25
25
  # Dynamically load dependencies
26
26
  dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
27
27
  require File.join(dir, 'socrata/data')
28
-
28
+ require File.join(dir, 'ext')
29
29
  class Socrata
30
30
  include HTTParty
31
31
 
@@ -39,7 +39,7 @@ class Socrata
39
39
  }
40
40
 
41
41
  def initialize(params = {})
42
- @config = DEFAULT_CONFIG.merge(symbolize_keys(params))
42
+ @config = DEFAULT_CONFIG.merge(Util.symbolize_keys(params))
43
43
  @logger = @config[:logger] || Logger.new(STDOUT)
44
44
  @batching = false
45
45
  @batch_queue = []
@@ -174,37 +174,4 @@ class Socrata
174
174
  return JSON.parse(c.body_str)
175
175
  end
176
176
 
177
- def symbolize_keys(obj)
178
- case obj
179
- when Array
180
- obj.inject([]){|res, val|
181
- res << case val
182
- when Hash, Array
183
- symbolize_keys(val)
184
- else
185
- val
186
- end
187
- res
188
- }
189
- when Hash
190
- obj.inject({}){|res, (key, val)|
191
- nkey = case key
192
- when String
193
- key.to_sym
194
- else
195
- key
196
- end
197
- nval = case val
198
- when Hash, Array
199
- symbolize_keys(val)
200
- else
201
- val
202
- end
203
- res[nkey] = nval
204
- res
205
- }
206
- else
207
- obj
208
- end
209
- end
210
177
  end
data/lib/socrata/data.rb CHANGED
@@ -76,5 +76,18 @@ class Socrata
76
76
  def get_row(row_id)
77
77
  return get_request("/views/#{self.id}/rows/#{row_id}.json")
78
78
  end
79
+
80
+ def filter(filter = {})
81
+ inline = {
82
+ :name => "Inline Filter for #{self.id}",
83
+ :id => self.id,
84
+ :original_view_id => self.id,
85
+ :query => filter
86
+ }
87
+
88
+ return post_request("/views/INLINE/rows.json?method=index",
89
+ {:body => Util.camelize_keys(inline).to_json} )["data"]
90
+ end
79
91
  end
80
92
  end
93
+
metadata CHANGED
@@ -4,17 +4,17 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
7
+ - 2
8
8
  - 0
9
- version: 0.1.0
9
+ version: 0.2.0
10
10
  platform: ruby
11
11
  authors:
12
- - Aiden Scandella
12
+ - Chris Metcalf
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-08-21 00:00:00 -07:00
17
+ date: 2010-08-22 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -61,7 +61,7 @@ dependencies:
61
61
  type: :runtime
62
62
  version_requirements: *id003
63
63
  description: Access the Socrata data platform via Ruby
64
- email: aiden.scandella@socrata.com
64
+ email: chris.metcalf@socrata.com
65
65
  executables: []
66
66
 
67
67
  extensions: []
@@ -73,7 +73,7 @@ files:
73
73
  - lib/socrata/data.rb
74
74
  - lib/socrata/user.rb
75
75
  has_rdoc: true
76
- homepage: http://api.socrata.com/
76
+ homepage: http://dev.socrata.com/
77
77
  licenses: []
78
78
 
79
79
  post_install_message: