geo_mongo 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.md +23 -0
- data/lib/geo_mongo.rb +29 -0
- metadata +82 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Alex Kremer
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
geo_mongo
|
2
|
+
===
|
3
|
+
|
4
|
+
geo_mongo enables the <a href="https://github.com/alexreisner/geocoder">Geocoder gem</a> to use Mongo as a cache.
|
5
|
+
|
6
|
+
Installation
|
7
|
+
------------
|
8
|
+
|
9
|
+
gem install foo
|
10
|
+
|
11
|
+
Usage
|
12
|
+
-----
|
13
|
+
|
14
|
+
In your geocoder.rb initializer, set the following:
|
15
|
+
|
16
|
+
Geocoder::Configuration.cache = GeoMongo::Store.new("mongo-host",27017,"db-name")
|
17
|
+
|
18
|
+
License
|
19
|
+
-------
|
20
|
+
|
21
|
+
Copyright (c) 2012 Alex Kremer.
|
22
|
+
|
23
|
+
Released under the MIT license. See `LICENSE` for details.
|
data/lib/geo_mongo.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'mongo'
|
2
|
+
|
3
|
+
module GeoMongo
|
4
|
+
class Store
|
5
|
+
|
6
|
+
def initialize(server, port, database)
|
7
|
+
@conn = Mongo::Connection.new(server, port).db(database)
|
8
|
+
@coll = @conn.collection("geocache")
|
9
|
+
end
|
10
|
+
|
11
|
+
def [](url)
|
12
|
+
value = @coll.find_one({:url => url}, :fields => {:_id => 0, :url => 0})
|
13
|
+
value["value"] unless value.nil?
|
14
|
+
end
|
15
|
+
|
16
|
+
def []=(url, value)
|
17
|
+
@coll.update({:url => url}, {:url => url, :value => value}, :upsert => true)
|
18
|
+
end
|
19
|
+
|
20
|
+
def keys
|
21
|
+
@coll.find({},:fields => {:_id => 0, :value => 0}).to_a.collect{|k| k["url"]}
|
22
|
+
end
|
23
|
+
|
24
|
+
def del(url)
|
25
|
+
@coll.remove({:url => url})
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: geo_mongo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Alex Kremer
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-02-07 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: mongo
|
16
|
+
requirement: &70232870861940 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70232870861940
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: bson
|
27
|
+
requirement: &70232870861220 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70232870861220
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: bson_ext
|
38
|
+
requirement: &70232870860720 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70232870860720
|
47
|
+
description: ! ' <Allow geocoder to use MongoDB as cache>
|
48
|
+
|
49
|
+
'
|
50
|
+
email: alex@flextrip.com
|
51
|
+
executables: []
|
52
|
+
extensions: []
|
53
|
+
extra_rdoc_files: []
|
54
|
+
files:
|
55
|
+
- LICENSE
|
56
|
+
- README.md
|
57
|
+
- lib/geo_mongo.rb
|
58
|
+
homepage: https://github.com/flextrip/geo_mongo
|
59
|
+
licenses: []
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirements: []
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 1.8.10
|
79
|
+
signing_key:
|
80
|
+
specification_version: 3
|
81
|
+
summary: Allow geocoder to use MongoDB as cache
|
82
|
+
test_files: []
|