geoloqi 0.9.19 → 0.9.21

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,2 +1,6 @@
1
1
  source :rubygems
2
2
  gemspec
3
+
4
+ platform :jruby do
5
+ gem 'jruby-openssl'
6
+ end
data/README.markdown CHANGED
@@ -11,14 +11,25 @@ Installation
11
11
 
12
12
  Basic Usage
13
13
  ---
14
- Geoloqi uses OAuth2 for authentication, but if you're only working with your own account, you don't need to go through the authorization steps! Simply go to your account settings on the [Geoloqi site](http://geoloqi.com), click on "Connections" and copy the OAuth 2 Access Token. You can use this token to run the following examples:
14
+ Geoloqi uses OAuth2 for authentication, but if you're only working with your own account, you don't need to go through the authorization steps! Simply go to your account settings on the [Geoloqi site](http://geoloqi.com), click on "Connections" and copy the OAuth 2 Access Token. You can use this token to run the following examples.
15
+
16
+ If you just need to make simple requests, you can just make a simple get or post request from Geoloqi:
17
+
18
+ require 'geoloqi'
19
+ result = Geoloqi.get 'YOUR ACCESS TOKEN', 'layer/info/Gx'
20
+ puts response.inspect
21
+
22
+ # or a POST!
23
+ result = Geoloqi.post 'YOUR ACCESS TOKEN', 'layer/create', :name => 'Test Layer'
24
+
25
+ If you're using Geoloqi with OAuth or making multiple requests, we recommend using the Geoloqi::Session class:
15
26
 
16
27
  require 'geoloqi'
17
- geoloqi = Geoloqi::Session.new :access_token => 'YOUR OAUTH2 ACCESS TOKEN GOES HERE'
28
+ geoloqi = Geoloqi::Session.new :access_token => 'YOUR ACCESS TOKEN'
18
29
  response = geoloqi.get 'layer/info/Gx'
19
30
  puts response.inspect
20
31
 
21
- This example returns a hash with the following:
32
+ Which returns a hash with the following:
22
33
 
23
34
  {"layer_id"=>"Gx", "user_id"=>"4", "type"=>"normal", "name"=>"USGS Earthquakes",
24
35
  "description"=>"Real-time notifications of earthquakes near you.",
data/lib/geoloqi.rb CHANGED
@@ -17,15 +17,29 @@ module Geoloqi
17
17
  @@enable_logging = false
18
18
  @@config = Config.new
19
19
 
20
- def self.config(opts=nil)
21
- return @@config if opts.nil?
22
- @@config = Config.new opts
23
- end
20
+ class << self
21
+ def config(opts=nil)
22
+ return @@config if opts.nil?
23
+ @@config = Config.new opts
24
+ end
25
+
26
+ def get(access_token, path, args={})
27
+ run :get, access_token, path, args
28
+ end
29
+
30
+ def post(access_token, path, args={})
31
+ run :post, access_token, path, args
32
+ end
33
+
34
+ def run(meth, access_token, path, args={})
35
+ Session.new(:access_token => access_token).run meth, path, args
36
+ end
24
37
 
25
- def self.authorize_url(client_id=nil, redirect_uri=@@config.redirect_uri, opts={})
26
- raise "client_id required to authorize url. Pass with Geoloqi.config" unless client_id
27
- url = "#{OAUTH_URL}?response_type=code&client_id=#{Rack::Utils.escape client_id}&redirect_uri=#{Rack::Utils.escape redirect_uri}"
28
- url += "&#{Rack::Utils.build_query opts}" unless opts.empty?
29
- url
38
+ def authorize_url(client_id=nil, redirect_uri=@@config.redirect_uri, opts={})
39
+ raise "client_id required to authorize url. Pass with Geoloqi.config" unless client_id
40
+ url = "#{OAUTH_URL}?response_type=code&client_id=#{Rack::Utils.escape client_id}&redirect_uri=#{Rack::Utils.escape redirect_uri}"
41
+ url += "&#{Rack::Utils.build_query opts}" unless opts.empty?
42
+ url
43
+ end
30
44
  end
31
45
  end
@@ -1,5 +1,5 @@
1
1
  module Geoloqi
2
2
  def self.version
3
- '0.9.19'
3
+ '0.9.21'
4
4
  end
5
5
  end
data/spec/geoloqi_spec.rb CHANGED
@@ -48,6 +48,25 @@ describe Geoloqi do
48
48
  "scope=can_party_hard" }
49
49
  end
50
50
  end
51
+
52
+ it 'makes get request' do
53
+ stub_request(:get, "https://api.geoloqi.com/1/quick_get?lol=cats").
54
+ with(:headers => {'Authorization'=>'OAuth access_token1234'}).
55
+ to_return(:body => {:result => 'ok'}.to_json)
56
+
57
+ response = Geoloqi.get ACCESS_TOKEN, '/quick_get', :lol => 'cats'
58
+ expect { response['result'] == 'ok' }
59
+ end
60
+
61
+ it 'makes post request' do
62
+ stub_request(:post, "https://api.geoloqi.com/1/quick_post").
63
+ with(:headers => {'Authorization'=>'OAuth access_token1234'},
64
+ :body => {:lol => 'dogs'}.to_json).
65
+ to_return(:body => {:result => 'ok'}.to_json)
66
+
67
+ response = Geoloqi.post ACCESS_TOKEN, '/quick_post', :lol => 'dogs'
68
+ expect { response['result'] == 'ok' }
69
+ end
51
70
  end
52
71
 
53
72
  describe Geoloqi::ApiError do
metadata CHANGED
@@ -2,99 +2,99 @@
2
2
  name: geoloqi
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.9.19
5
+ version: 0.9.21
6
6
  platform: ruby
7
7
  authors:
8
- - Kyle Drake
9
- - Aaron Parecki
8
+ - Kyle Drake
9
+ - Aaron Parecki
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2011-08-08 00:00:00 -07:00
14
+ date: 2011-08-17 00:00:00 -07:00
15
15
  default_executable:
16
16
  dependencies:
17
- - !ruby/object:Gem::Dependency
18
- name: json
19
- prerelease: false
20
- requirement: &id001 !ruby/object:Gem::Requirement
21
- none: false
22
- requirements:
23
- - - ">="
24
- - !ruby/object:Gem::Version
25
- version: "0"
26
- type: :runtime
27
- version_requirements: *id001
28
- - !ruby/object:Gem::Dependency
29
- name: faraday
30
- prerelease: false
31
- requirement: &id002 !ruby/object:Gem::Requirement
32
- none: false
33
- requirements:
34
- - - ">="
35
- - !ruby/object:Gem::Version
36
- version: 0.6.1
37
- type: :runtime
38
- version_requirements: *id002
39
- - !ruby/object:Gem::Dependency
40
- name: rake
41
- prerelease: false
42
- requirement: &id003 !ruby/object:Gem::Requirement
43
- none: false
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: "0"
48
- type: :development
49
- version_requirements: *id003
50
- - !ruby/object:Gem::Dependency
51
- name: wrong
52
- prerelease: false
53
- requirement: &id004 !ruby/object:Gem::Requirement
54
- none: false
55
- requirements:
56
- - - "="
57
- - !ruby/object:Gem::Version
58
- version: 0.5.0
59
- type: :development
60
- version_requirements: *id004
61
- - !ruby/object:Gem::Dependency
62
- name: minitest
63
- prerelease: false
64
- requirement: &id005 !ruby/object:Gem::Requirement
65
- none: false
66
- requirements:
67
- - - "="
68
- - !ruby/object:Gem::Version
69
- version: 2.2.2
70
- type: :development
71
- version_requirements: *id005
72
- - !ruby/object:Gem::Dependency
73
- name: webmock
74
- prerelease: false
75
- requirement: &id006 !ruby/object:Gem::Requirement
76
- none: false
77
- requirements:
78
- - - "="
79
- - !ruby/object:Gem::Version
80
- version: 1.6.4
81
- type: :development
82
- version_requirements: *id006
83
- - !ruby/object:Gem::Dependency
84
- name: hashie
85
- prerelease: false
86
- requirement: &id007 !ruby/object:Gem::Requirement
87
- none: false
88
- requirements:
89
- - - "="
90
- - !ruby/object:Gem::Version
91
- version: 1.0.0
92
- type: :development
93
- version_requirements: *id007
17
+ - !ruby/object:Gem::Dependency
18
+ name: json
19
+ prerelease: false
20
+ requirement: &id001 !ruby/object:Gem::Requirement
21
+ none: false
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: "0"
26
+ type: :runtime
27
+ version_requirements: *id001
28
+ - !ruby/object:Gem::Dependency
29
+ name: faraday
30
+ prerelease: false
31
+ requirement: &id002 !ruby/object:Gem::Requirement
32
+ none: false
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 0.6.1
37
+ type: :runtime
38
+ version_requirements: *id002
39
+ - !ruby/object:Gem::Dependency
40
+ name: rake
41
+ prerelease: false
42
+ requirement: &id003 !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: "0"
48
+ type: :development
49
+ version_requirements: *id003
50
+ - !ruby/object:Gem::Dependency
51
+ name: wrong
52
+ prerelease: false
53
+ requirement: &id004 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - "="
57
+ - !ruby/object:Gem::Version
58
+ version: 0.5.0
59
+ type: :development
60
+ version_requirements: *id004
61
+ - !ruby/object:Gem::Dependency
62
+ name: minitest
63
+ prerelease: false
64
+ requirement: &id005 !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - "="
68
+ - !ruby/object:Gem::Version
69
+ version: 2.2.2
70
+ type: :development
71
+ version_requirements: *id005
72
+ - !ruby/object:Gem::Dependency
73
+ name: webmock
74
+ prerelease: false
75
+ requirement: &id006 !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - "="
79
+ - !ruby/object:Gem::Version
80
+ version: 1.6.4
81
+ type: :development
82
+ version_requirements: *id006
83
+ - !ruby/object:Gem::Dependency
84
+ name: hashie
85
+ prerelease: false
86
+ requirement: &id007 !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - "="
90
+ - !ruby/object:Gem::Version
91
+ version: 1.0.0
92
+ type: :development
93
+ version_requirements: *id007
94
94
  description: Powerful, flexible, lightweight interface to the awesome Geoloqi platform API! Uses Faraday, and can be used with Ruby 1.9 and EM-Synchrony for really fast, highly concurrent development.
95
95
  email:
96
- - kyledrake@gmail.com
97
- - aaron@parecki.com
96
+ - kyledrake@gmail.com
97
+ - aaron@parecki.com
98
98
  executables: []
99
99
 
100
100
  extensions: []
@@ -102,23 +102,23 @@ extensions: []
102
102
  extra_rdoc_files: []
103
103
 
104
104
  files:
105
- - .gitignore
106
- - .travis.yml
107
- - Gemfile
108
- - README.markdown
109
- - Rakefile
110
- - examples/simple.rb
111
- - examples/sinatra.rb
112
- - examples/sinatra_synchrony.rb
113
- - geoloqi.gemspec
114
- - lib/geoloqi.rb
115
- - lib/geoloqi/config.rb
116
- - lib/geoloqi/error.rb
117
- - lib/geoloqi/response.rb
118
- - lib/geoloqi/session.rb
119
- - lib/geoloqi/version.rb
120
- - license.txt
121
- - spec/geoloqi_spec.rb
105
+ - .gitignore
106
+ - .travis.yml
107
+ - Gemfile
108
+ - README.markdown
109
+ - Rakefile
110
+ - examples/simple.rb
111
+ - examples/sinatra.rb
112
+ - examples/sinatra_synchrony.rb
113
+ - geoloqi.gemspec
114
+ - lib/geoloqi.rb
115
+ - lib/geoloqi/config.rb
116
+ - lib/geoloqi/error.rb
117
+ - lib/geoloqi/response.rb
118
+ - lib/geoloqi/session.rb
119
+ - lib/geoloqi/version.rb
120
+ - license.txt
121
+ - spec/geoloqi_spec.rb
122
122
  has_rdoc: true
123
123
  homepage: http://github.com/geoloqi/geoloqi-ruby
124
124
  licenses: []
@@ -127,23 +127,23 @@ post_install_message:
127
127
  rdoc_options: []
128
128
 
129
129
  require_paths:
130
- - lib
130
+ - lib
131
131
  required_ruby_version: !ruby/object:Gem::Requirement
132
132
  none: false
133
133
  requirements:
134
- - - ">="
135
- - !ruby/object:Gem::Version
136
- version: "0"
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: "0"
137
137
  required_rubygems_version: !ruby/object:Gem::Requirement
138
138
  none: false
139
139
  requirements:
140
- - - ">="
141
- - !ruby/object:Gem::Version
142
- version: 1.3.4
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: 1.3.4
143
143
  requirements: []
144
144
 
145
145
  rubyforge_project: geoloqi
146
- rubygems_version: 1.5.2
146
+ rubygems_version: 1.5.1
147
147
  signing_key:
148
148
  specification_version: 3
149
149
  summary: Powerful, flexible, lightweight interface to the awesome Geoloqi platform API