geoloqi 0.9.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -45,6 +45,12 @@ This returns response['place_id'], which you can use to store and/or remove the
45
45
 
46
46
  Which returns response['result'] with a value of "ok".
47
47
 
48
+ You can send query string parameters with get requests too:
49
+
50
+ geoloqi.get 'location/history', :count => 2
51
+ # or
52
+ geoloqi.get 'location/history?count=2'
53
+
48
54
  Implementing OAuth2
49
55
  ---
50
56
 
@@ -31,25 +31,26 @@ module Geoloqi
31
31
  Geoloqi.authorize_url @config.client_id, redirect_uri
32
32
  end
33
33
 
34
- def get(path)
35
- run :get, path
34
+ def get(path, query=nil)
35
+ run :get, path, query
36
36
  end
37
37
 
38
- def post(path, body=nil)
39
- run :post, path, body
38
+ def post(path, query=nil)
39
+ run :post, path, query
40
40
  end
41
41
 
42
- def run(meth, path, body=nil)
42
+ def run(meth, path, query=nil)
43
+ query = Rack::Utils.parse_query query if query.is_a?(String)
43
44
  renew_access_token! if auth[:expires_at] && auth[:expires_at] <= Time.now
44
-
45
- body = body.to_json if [Hash, Array].include? body.class
46
-
47
45
  retry_attempt = 0
48
46
  begin
49
47
  response = @connection.send(meth) do |req|
50
48
  req.url "/#{API_VERSION.to_s}/#{path.gsub(/^\//, '')}"
51
49
  req.headers = headers
52
- req.body = body if body
50
+
51
+ if query
52
+ meth == :get ? req.params = query : req.body = query.to_json
53
+ end
53
54
  end
54
55
 
55
56
  json = JSON.parse response.body
@@ -1,3 +1,3 @@
1
1
  module Geoloqi
2
- VERSION = '0.9.2'
2
+ VERSION = '0.9.3'
3
3
  end
data/spec/geoloqi_spec.rb CHANGED
@@ -65,13 +65,11 @@ describe Geoloqi::Session do
65
65
  end
66
66
 
67
67
  it 'successfully makes call to api with forward slash' do
68
- response = @session.get '/layer/info/Gx'
69
- expect { response['layer_id'] == 'Gx' }
68
+ expect { @session.get('/layer/info/Gx')['layer_id'] == 'Gx' }
70
69
  end
71
70
 
72
71
  it 'successfully makes call to api without forward slash' do
73
- response = @session.get 'layer/info/Gx'
74
- expect { response['layer_id'] == 'Gx' }
72
+ expect { @session.get('layer/info/Gx')['layer_id'] == 'Gx' }
75
73
  end
76
74
 
77
75
  it 'creates a layer, reads its info, and then deletes the layer' do
@@ -84,6 +82,18 @@ describe Geoloqi::Session do
84
82
  expect { layer_info['name'] == 'Test Layer' }
85
83
  expect { layer_delete['result'] == 'ok' }
86
84
  end
85
+
86
+ it 'makes a location/history call with get and hash params' do
87
+ expect { @session.get('location/history', :count => 2)['points'].count == 2 }
88
+ end
89
+
90
+ it 'makes a location/history call with get and query string directly in path' do
91
+ expect { @session.get('location/history?count=2')['points'].count == 2 }
92
+ end
93
+
94
+ it 'makes a location/history call with get and query string params' do
95
+ expect { @session.get('location/history', 'count=2')['points'].count == 2 }
96
+ end
87
97
  end
88
98
 
89
99
  describe 'with oauth id, secret, and access token via Geoloqi::Config' do
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geoloqi
3
3
  version: !ruby/object:Gem::Version
4
- hash: 63
5
4
  prerelease:
6
- segments:
7
- - 0
8
- - 9
9
- - 2
10
- version: 0.9.2
5
+ version: 0.9.3
11
6
  platform: ruby
12
7
  authors:
13
8
  - Kyle Drake
@@ -16,7 +11,7 @@ autorequire:
16
11
  bindir: bin
17
12
  cert_chain: []
18
13
 
19
- date: 2011-06-06 00:00:00 -07:00
14
+ date: 2011-06-11 00:00:00 -07:00
20
15
  default_executable:
21
16
  dependencies:
22
17
  - !ruby/object:Gem::Dependency
@@ -27,9 +22,6 @@ dependencies:
27
22
  requirements:
28
23
  - - ">="
29
24
  - !ruby/object:Gem::Version
30
- hash: 3
31
- segments:
32
- - 0
33
25
  version: "0"
34
26
  type: :runtime
35
27
  version_requirements: *id001
@@ -41,9 +33,6 @@ dependencies:
41
33
  requirements:
42
34
  - - ">="
43
35
  - !ruby/object:Gem::Version
44
- hash: 3
45
- segments:
46
- - 0
47
36
  version: "0"
48
37
  type: :runtime
49
38
  version_requirements: *id002
@@ -55,11 +44,6 @@ dependencies:
55
44
  requirements:
56
45
  - - "="
57
46
  - !ruby/object:Gem::Version
58
- hash: 11
59
- segments:
60
- - 0
61
- - 5
62
- - 0
63
47
  version: 0.5.0
64
48
  type: :development
65
49
  version_requirements: *id003
@@ -71,11 +55,6 @@ dependencies:
71
55
  requirements:
72
56
  - - "="
73
57
  - !ruby/object:Gem::Version
74
- hash: 3
75
- segments:
76
- - 2
77
- - 2
78
- - 2
79
58
  version: 2.2.2
80
59
  type: :development
81
60
  version_requirements: *id004
@@ -87,11 +66,6 @@ dependencies:
87
66
  requirements:
88
67
  - - "="
89
68
  - !ruby/object:Gem::Version
90
- hash: 7
91
- segments:
92
- - 1
93
- - 6
94
- - 4
95
69
  version: 1.6.4
96
70
  type: :development
97
71
  version_requirements: *id005
@@ -134,20 +108,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
134
108
  requirements:
135
109
  - - ">="
136
110
  - !ruby/object:Gem::Version
137
- hash: 3
138
- segments:
139
- - 0
140
111
  version: "0"
141
112
  required_rubygems_version: !ruby/object:Gem::Requirement
142
113
  none: false
143
114
  requirements:
144
115
  - - ">="
145
116
  - !ruby/object:Gem::Version
146
- hash: 19
147
- segments:
148
- - 1
149
- - 3
150
- - 4
151
117
  version: 1.3.4
152
118
  requirements: []
153
119