heycarsten-gcoder 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -1,6 +1,40 @@
1
1
  = GCoder
2
2
 
3
- Instead of letting postal codes turn me into a postal coder, I made this gem!
3
+ Geocode stuff using the Google Maps Geocoding API and cache it through Tokyo
4
+ Tyrant to increase speed and throughput. If you're looking for something
5
+ hardcore you should check out GeoKit! [http://github.com/andre/geokit-gem]
6
+
7
+
8
+ == Bon Usage
9
+
10
+ require 'rubygems'
11
+ require 'gcoder'
12
+
13
+ G = GCoder.connect(
14
+ :tt_host => '127.0.0.1',
15
+ :tt_port => 1234,
16
+ :gmaps_api_key => 's3cr37s4uc3-df333dswddfsdf-332223',
17
+ :append_query => 'Ontario Canada')
18
+
19
+ G['dundas and sorauren']
20
+
21
+ # => {:box=>
22
+ # => {:north=>43.6543396,
23
+ # => :south=>43.6480444,
24
+ # => :east=>-79.4421004,
25
+ # => :west=>-79.4483956},
26
+ # => :point=>{:longitude=>-79.445248, :latitude=>43.651192},
27
+ # => :accuracy=>7,
28
+ # => :country=>{:administrative_area=>"ON", :code=>"CA", :name=>"Canada"}}
29
+
30
+
31
+ == TODO
32
+
33
+ * Add dependencies to Gemspec
34
+ * Support for multiple results
35
+ * Better tests
36
+ * General betterment
37
+
4
38
 
5
39
  == Copyright
6
40
 
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :minor: 3
3
- :patch: 0
3
+ :patch: 1
4
4
  :major: 0
data/gcoder.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{gcoder}
5
- s.version = "0.3.0"
5
+ s.version = "0.3.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Carsten Nielsen"]
9
- s.date = %q{2009-06-26}
9
+ s.date = %q{2009-06-27}
10
10
  s.email = %q{heycarsten@gmail.com}
11
11
  s.extra_rdoc_files = [
12
12
  "README.rdoc"
@@ -51,19 +51,19 @@ module GCoder
51
51
  def get
52
52
  return @json_response if @json_response
53
53
  Timeout.timeout(@config[:gmaps_api_timeout]) do
54
- Response.new(http_get)
54
+ Response.new(self)
55
55
  end
56
56
  rescue Timeout::Error
57
57
  raise Errors::RequestTimeoutError, 'The query timed out at ' \
58
58
  "#{@config[:timeout]} second(s)"
59
59
  end
60
60
 
61
- protected
62
-
63
61
  def http_get
64
62
  open(uri).read
65
63
  end
66
64
 
65
+ protected
66
+
67
67
  # Snaked from Rack::Utils which 'stole' it from Camping.
68
68
  def uri_escape(string)
69
69
  string.to_s.gsub(/([^ a-zA-Z0-9_.-]+)/n) do
@@ -87,8 +87,9 @@ module GCoder
87
87
 
88
88
  class Response
89
89
 
90
- def initialize(raw_response)
91
- @response = JSON.parse(raw_response)
90
+ def initialize(request)
91
+ @request = request
92
+ @response = JSON.parse(@request.http_get)
92
93
  end
93
94
 
94
95
  def status
@@ -100,10 +101,11 @@ module GCoder
100
101
  when 400
101
102
  raise Errors::APIMalformedRequestError, 'The GMaps Geo API has ' \
102
103
  'indicated that the request is not formed correctly: ' \
103
- "(#{@response.inspect})"
104
+ "(#{@request.uri})\n\n#{@request.inspect}"
104
105
  when 602
105
106
  raise Errors::APIGeocodingError, 'The GMaps Geo API has indicated ' \
106
- "that it is not able to geocode the request: (#{@response.inspect})"
107
+ "that it is not able to geocode the request: (#{@request.uri})" \
108
+ "\n\n#{@request.inspect}"
107
109
  end
108
110
  end
109
111
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heycarsten-gcoder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carsten Nielsen
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-26 00:00:00 -07:00
12
+ date: 2009-06-27 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15