dynamodb_geo 0.1.4 → 0.2.1
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 +28 -5
- data/lib/store.rb +11 -1
- 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: 7fa8f8e9732cb57f22454364dae1d01f8245eaa2006d2c5c27c3bfbcf9533c6a
|
4
|
+
data.tar.gz: da4ca3769f2ed2e7372693995ebe0061da6eb2eba6009a39631b5c3f89a95fe9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 467828ce5b76c90ad7c2bed7594994fadb5c76e4ee0bc63714ba5878eb4f1779631798cbb610e53fa9a7ba2acd882907559c1c13ed89c7e794d0d14c6aef93f3
|
7
|
+
data.tar.gz: d7c5231aefc7bee490e07b85ea97243dbb2fbeb6d60a451ba1f98062bb83708e99644309fc60437e4b00cd589f3f3334effbd0baa97458184d2059b946b31711
|
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,30 @@ 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
|
+
uuid = item[@range_key]
|
83
|
+
all_stores << Store.new(
|
84
|
+
latitude: latitude,
|
85
|
+
longitude: longitude,
|
86
|
+
address: address,
|
87
|
+
city: city,
|
88
|
+
state: state,
|
89
|
+
zip: zip,
|
90
|
+
area_code: area_code,
|
91
|
+
phone: phone,
|
92
|
+
name: name,
|
93
|
+
geohash: geohash,
|
94
|
+
uuid: uuid
|
95
|
+
)
|
73
96
|
end
|
74
97
|
break if all_stores.length >= max_item_return
|
75
98
|
end
|
@@ -97,8 +120,8 @@ class DynamodbManager
|
|
97
120
|
})
|
98
121
|
end
|
99
122
|
|
100
|
-
def put_point(hash, json)
|
101
|
-
uuid
|
123
|
+
def put_point(hash, json, uuid = nil)
|
124
|
+
uuid ||= SecureRandom.uuid
|
102
125
|
|
103
126
|
@client.put_item({
|
104
127
|
table_name: @table_name,
|
data/lib/store.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
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
4
|
@lat = store_data[:latitude]
|
5
5
|
@long = store_data[:longitude]
|
@@ -11,5 +11,15 @@ class Store
|
|
11
11
|
@phone = store_data[:phone]
|
12
12
|
@name = store_data[:name]
|
13
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.1
|
4
|
+
version: 0.2.1
|
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.1
|
130
|
+
summary: dynamodb_geo-0.2.1
|
131
131
|
test_files:
|
132
132
|
- spec/dynamodb_geo_spec.rb
|
133
133
|
- spec/geohash_spec.rb
|