dynamodb_geo 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dynamodb_geo/version.rb +1 -1
- data/lib/dynamodb_manager.rb +26 -5
- data/lib/store.rb +21 -11
- data/spec/dynamodb_geo_spec.rb +1 -1
- metadata +15 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5585912cbe804676b364ed0479bdd68aad683550502a17517124c567e611b2b8
|
4
|
+
data.tar.gz: 95177885630267acddf06e386888331d0951577203837a82e03303a6a9873959
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76b27bb7675df86c7bcbaab037cd925ae0b38d5d7b02634dd596776d039c7af22377c3cc2f868afa07d6e86260b632ea112c404efbffffcb9c815c10ff263002
|
7
|
+
data.tar.gz: 4bb8c017c50005483deabac163d9df33bfbb3ac6b43522444fc9cc8c9ef24a4ec675d072282fe8635787c4e48731c57396335a0350217b125530e93d173e6471
|
data/lib/dynamodb_geo/version.rb
CHANGED
data/lib/dynamodb_manager.rb
CHANGED
@@ -11,7 +11,7 @@ class DynamodbManager
|
|
11
11
|
|
12
12
|
credentials = Aws::SharedCredentials.new(profile_name: profile_name).credentials if access_key_id.nil? && secret_access_key.nil?
|
13
13
|
end
|
14
|
-
credentials = Aws::Credentials.new(access_key_id, secret_access_key)
|
14
|
+
credentials = Aws::Credentials.new(access_key_id, secret_access_key, ENV['AWS_SESSION_TOKEN'])
|
15
15
|
|
16
16
|
@table_name = table_name
|
17
17
|
@hash_key = 'hashkey'
|
@@ -56,7 +56,7 @@ class DynamodbManager
|
|
56
56
|
phone: store.phone,
|
57
57
|
name: store.name,
|
58
58
|
}
|
59
|
-
put_point(hash, json)
|
59
|
+
put_point(hash, json, store.uuid)
|
60
60
|
end
|
61
61
|
|
62
62
|
def get_stores(lat, long)
|
@@ -69,7 +69,28 @@ class DynamodbManager
|
|
69
69
|
neighbours.each do |neighbour|
|
70
70
|
resp = query(neighbour)
|
71
71
|
resp.items.each do |item|
|
72
|
-
|
72
|
+
latitude = item[@geojson]['latitude']
|
73
|
+
longitude = item[@geojson]['longitude']
|
74
|
+
address = item[@geojson]['address']
|
75
|
+
city = item[@geojson]['city']
|
76
|
+
state = item[@geojson]['state']
|
77
|
+
zip = item[@geojson]['zip']
|
78
|
+
area_code = item[@geojson]['area_code']
|
79
|
+
phone = item[@geojson]['phone']
|
80
|
+
name = item[@geojson]['name']
|
81
|
+
geohash = item[@geohash_key]
|
82
|
+
all_stores << Store.new(
|
83
|
+
latitude: latitude,
|
84
|
+
longitude: longitude,
|
85
|
+
address: address,
|
86
|
+
city: city,
|
87
|
+
state: state,
|
88
|
+
zip: zip,
|
89
|
+
area_code: area_code,
|
90
|
+
phone: phone,
|
91
|
+
name: name,
|
92
|
+
geohash: geohash
|
93
|
+
)
|
73
94
|
end
|
74
95
|
break if all_stores.length >= max_item_return
|
75
96
|
end
|
@@ -97,8 +118,8 @@ class DynamodbManager
|
|
97
118
|
})
|
98
119
|
end
|
99
120
|
|
100
|
-
def put_point(hash, json)
|
101
|
-
uuid
|
121
|
+
def put_point(hash, json, uuid = nil)
|
122
|
+
uuid ||= SecureRandom.uuid
|
102
123
|
|
103
124
|
@client.put_item({
|
104
125
|
table_name: @table_name,
|
data/lib/store.rb
CHANGED
@@ -1,15 +1,25 @@
|
|
1
1
|
class Store
|
2
|
-
attr_accessor :lat, :long, :address, :city, :state, :zip, :area_code, :phone, :name, :geohash
|
2
|
+
attr_accessor :lat, :long, :address, :city, :state, :zip, :area_code, :phone, :name, :geohash, :uuid
|
3
3
|
def initialize(store_data)
|
4
|
-
@lat = store_data[
|
5
|
-
@long = store_data[
|
6
|
-
@address = store_data[
|
7
|
-
@city = store_data[
|
8
|
-
@state = store_data[
|
9
|
-
@zip = store_data[
|
10
|
-
@area_code = store_data[
|
11
|
-
@phone = store_data[
|
12
|
-
@name = store_data[
|
13
|
-
@geohash = store_data[
|
4
|
+
@lat = store_data[:latitude]
|
5
|
+
@long = store_data[:longitude]
|
6
|
+
@address = store_data[:address]
|
7
|
+
@city = store_data[:city]
|
8
|
+
@state = store_data[:state]
|
9
|
+
@zip = store_data[:zip]
|
10
|
+
@area_code = store_data[:area_code]
|
11
|
+
@phone = store_data[:phone]
|
12
|
+
@name = store_data[:name]
|
13
|
+
@geohash = store_data[:geohash] || Geohash.encode(lat, long, 10)
|
14
|
+
@uuid = store_data[:uuid]
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_h
|
18
|
+
temp = instance_variables.map do |v|
|
19
|
+
value = self.send(v.to_s.sub('@',''))
|
20
|
+
value = value.class == BigDecimal ? value.to_f : value
|
21
|
+
Hash[v.to_s.sub('@','').to_sym, value]
|
22
|
+
end
|
23
|
+
Hash[*temp.collect{|h| h.to_a}.flatten]
|
14
24
|
end
|
15
25
|
end
|
data/spec/dynamodb_geo_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dynamodb_geo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Ahn
|
@@ -14,44 +14,44 @@ dependencies:
|
|
14
14
|
name: rspec
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '3.9'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '3.9'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: byebug
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '11.1'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '11.1'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake-compiler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '1.1'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '1.1'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: aws-sdk-dynamodb
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -104,7 +104,7 @@ files:
|
|
104
104
|
- spec/dynamodb_geo_spec.rb
|
105
105
|
- spec/geohash_spec.rb
|
106
106
|
- spec/spec_helper.rb
|
107
|
-
homepage:
|
107
|
+
homepage: https://github.com/JA-Soonahn/dynamodb_geo
|
108
108
|
licenses:
|
109
109
|
- Beerware
|
110
110
|
metadata:
|
@@ -127,7 +127,7 @@ requirements: []
|
|
127
127
|
rubygems_version: 3.1.2
|
128
128
|
signing_key:
|
129
129
|
specification_version: 4
|
130
|
-
summary: dynamodb_geo-0.
|
130
|
+
summary: dynamodb_geo-0.2.0
|
131
131
|
test_files:
|
132
132
|
- spec/dynamodb_geo_spec.rb
|
133
133
|
- spec/geohash_spec.rb
|