gcoder 0.10.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +5 -2
- data/gcoder.gemspec +3 -3
- data/lib/gcoder/storage.rb +30 -2
- data/lib/gcoder/version.rb +1 -1
- metadata +6 -5
data/README.md
CHANGED
@@ -49,7 +49,8 @@ More info [here](http://code.google.com/apis/maps/documentation/geocoding/#Viewp
|
|
49
49
|
|
50
50
|
### `:client`
|
51
51
|
|
52
|
-
To access the special features of Google Maps API Premier, you must provide a
|
52
|
+
To access the special features of Google Maps API Premier, you must provide a
|
53
|
+
client ID. All client IDs begin with a gme- prefix.
|
53
54
|
|
54
55
|
### `:storage`
|
55
56
|
|
@@ -71,6 +72,7 @@ disable caching of results.
|
|
71
72
|
* `:storage => nil` - Disable caching (default.)
|
72
73
|
* `:storage => :heap` - Saves cached values in an in-memory Hash.
|
73
74
|
* `:storage => :redis` - Saves cached values within Redis.
|
75
|
+
* `:storage => :rails_cache` - Saves cached values via Rails's cache interface.
|
74
76
|
|
75
77
|
### Adapter Configuration
|
76
78
|
|
@@ -144,7 +146,8 @@ Now we can use our adapter as a caching layer by specifying it like this:
|
|
144
146
|
## Authors
|
145
147
|
|
146
148
|
* Carsten Nielsen
|
147
|
-
* Christos Pappas (Added support for Google Maps API Premier
|
149
|
+
* Christos Pappas (Added support for Google Maps API Premier and Rails.cache
|
150
|
+
adapter.)
|
148
151
|
|
149
152
|
## Notes
|
150
153
|
|
data/gcoder.gemspec
CHANGED
@@ -5,11 +5,11 @@ Gem::Specification.new do |s|
|
|
5
5
|
s.name = 'gcoder'
|
6
6
|
s.version = GCoder::VERSION
|
7
7
|
s.platform = Gem::Platform::RUBY
|
8
|
-
s.authors = ['Carsten Nielsen']
|
8
|
+
s.authors = ['Carsten Nielsen', 'Christos Pappas']
|
9
9
|
s.email = ['heycarsten@gmail.com']
|
10
10
|
s.homepage = 'http://github.com/heycarsten/gcoder'
|
11
|
-
s.summary = %q{A nice library for geocoding stuff with Google
|
12
|
-
s.description = %q{Uses Google
|
11
|
+
s.summary = %q{A nice library for geocoding stuff with Google Maps API V3}
|
12
|
+
s.description = %q{Uses Google Maps Geocoding API (V3) to geocode stuff and optionally caches the results somewhere.}
|
13
13
|
|
14
14
|
s.required_rubygems_version = '>= 1.3.6'
|
15
15
|
s.rubyforge_project = 'gcoder'
|
data/lib/gcoder/storage.rb
CHANGED
@@ -50,7 +50,6 @@ module GCoder
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
-
|
54
53
|
class HeapAdapter < Adapter
|
55
54
|
def connect
|
56
55
|
@heap = {}
|
@@ -69,7 +68,6 @@ module GCoder
|
|
69
68
|
end
|
70
69
|
end
|
71
70
|
|
72
|
-
|
73
71
|
class RedisAdapter < Adapter
|
74
72
|
def connect
|
75
73
|
require 'redis'
|
@@ -100,8 +98,38 @@ module GCoder
|
|
100
98
|
end
|
101
99
|
end
|
102
100
|
|
101
|
+
class RailsCacheAdapter < Adapter
|
102
|
+
def connect
|
103
|
+
@cache = Rails.cache
|
104
|
+
@keyspace = "#{config[:keyspace] || 'gcoder'}:"
|
105
|
+
end
|
106
|
+
|
107
|
+
def clear
|
108
|
+
@cache.keys(@keyspace + '*').each { |key| @cache.del(key) }
|
109
|
+
end
|
110
|
+
|
111
|
+
def get(key)
|
112
|
+
@cache.read(keyns(key))
|
113
|
+
end
|
114
|
+
|
115
|
+
def set(key, value)
|
116
|
+
if (ttl = config[:key_ttl])
|
117
|
+
@cache.write(keyns(key), nval(value), :expires_in => ttl)
|
118
|
+
else
|
119
|
+
@cache.write(keyns(key), nval(value))
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
private
|
124
|
+
|
125
|
+
def keyns(key)
|
126
|
+
"#{@keyspace}#{nkey(key)}"
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
103
130
|
register :heap, HeapAdapter
|
104
131
|
register :redis, RedisAdapter
|
132
|
+
register :rails_cache, RailsCacheAdapter
|
105
133
|
|
106
134
|
end
|
107
135
|
end
|
data/lib/gcoder/version.rb
CHANGED
metadata
CHANGED
@@ -4,17 +4,18 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
7
|
+
- 11
|
8
8
|
- 0
|
9
|
-
version: 0.
|
9
|
+
version: 0.11.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Carsten Nielsen
|
13
|
+
- Christos Pappas
|
13
14
|
autorequire:
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2011-02-
|
18
|
+
date: 2011-02-17 00:00:00 -05:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
@@ -43,7 +44,7 @@ dependencies:
|
|
43
44
|
version: "0"
|
44
45
|
type: :runtime
|
45
46
|
version_requirements: *id002
|
46
|
-
description: Uses Google
|
47
|
+
description: Uses Google Maps Geocoding API (V3) to geocode stuff and optionally caches the results somewhere.
|
47
48
|
email:
|
48
49
|
- heycarsten@gmail.com
|
49
50
|
executables: []
|
@@ -109,7 +110,7 @@ rubyforge_project: gcoder
|
|
109
110
|
rubygems_version: 1.3.7
|
110
111
|
signing_key:
|
111
112
|
specification_version: 3
|
112
|
-
summary: A nice library for geocoding stuff with Google
|
113
|
+
summary: A nice library for geocoding stuff with Google Maps API V3
|
113
114
|
test_files:
|
114
115
|
- spec/gcoder/geocoder_spec.rb
|
115
116
|
- spec/gcoder/resolver_spec.rb
|