dynamodb_geo 0.1.1 → 0.1.8
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 +12 -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: c08fcea2ee6831194cf0bdaa030f5fde0fcf57e54a36e9e5347adffc40ded893
|
4
|
+
data.tar.gz: 1d67d6d7e8b8dc0ac155033f54d359b259692cfb074f8a447bed5dae4e9926b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 448bd154bbf2205255c7b3ab62e0d6080e19f084e361e1242ef62a979b0fd7d18411d3c6aaf34edec27245f38d3239c280c07a7d07bc98835c02925df70292c0
|
7
|
+
data.tar.gz: 04c1d9a11d142ac70c51b98b267a42e8cbf3f55fd375f023940d569c53f68e558f886741925153c57b70a5524332569a0c0cef4143118c63f4f87d0bca2c22f6
|
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,16 @@
|
|
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]
|
14
15
|
end
|
15
16
|
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.1.8
|
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.1.8
|
131
131
|
test_files:
|
132
132
|
- spec/dynamodb_geo_spec.rb
|
133
133
|
- spec/geohash_spec.rb
|