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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df20011ecbf64926816afdd5e4eaaa1abfa8ca5858b663e81cd690aa2385d284
4
- data.tar.gz: 72af72a1f8de5bce17213d8cbfc452c04df1d9c6ae641e440703a54013ff887d
3
+ metadata.gz: c08fcea2ee6831194cf0bdaa030f5fde0fcf57e54a36e9e5347adffc40ded893
4
+ data.tar.gz: 1d67d6d7e8b8dc0ac155033f54d359b259692cfb074f8a447bed5dae4e9926b4
5
5
  SHA512:
6
- metadata.gz: 330cb41e5276a0f0b67a00eb95c238297812b807332c30f2139b7090b41c9a190f8c2775dffa69f9b45904263aa94c94b5d00f5ba3d497e1481ce8bf7846a7e4
7
- data.tar.gz: 35e9d9f59af12644d402911f1407242aa9eefdad21990bd8fd4a9a63b8f92c4d62a6a177826b086cac5bd9b01d4cdd2b143f07819efae7973c4833f9048919ea
6
+ metadata.gz: 448bd154bbf2205255c7b3ab62e0d6080e19f084e361e1242ef62a979b0fd7d18411d3c6aaf34edec27245f38d3239c280c07a7d07bc98835c02925df70292c0
7
+ data.tar.gz: 04c1d9a11d142ac70c51b98b267a42e8cbf3f55fd375f023940d569c53f68e558f886741925153c57b70a5524332569a0c0cef4143118c63f4f87d0bca2c22f6
@@ -1,5 +1,5 @@
1
1
  module DynamodbGeo
2
2
  class Version
3
- STRING = '0.1.1'
3
+ STRING = '0.1.8'
4
4
  end
5
5
  end
@@ -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
- all_stores << Store.new(item['geoJson'], item['geohash'])
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 = SecureRandom.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,
@@ -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['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)
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
@@ -11,7 +11,7 @@ describe DynamodbGeo do
11
11
  )
12
12
  expect(dynamo).to be_a DynamodbManager
13
13
 
14
- debugger;1
14
+ dynamo.get_stores(37.746825, -122.413637)
15
15
  puts 'foo'
16
16
  end
17
17
  end
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.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: '0'
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: '0'
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: '0'
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: '0'
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: '0'
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: '0'
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.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