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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3b1d19c28ca82eb87cf6ec648d23326efb82c8c80e351af2e98c8e26d1dcc57d
4
- data.tar.gz: 63245c71ac96ee49bf69823614315bb6ea752b605d8c670d54fef792fa65e494
3
+ metadata.gz: 5585912cbe804676b364ed0479bdd68aad683550502a17517124c567e611b2b8
4
+ data.tar.gz: 95177885630267acddf06e386888331d0951577203837a82e03303a6a9873959
5
5
  SHA512:
6
- metadata.gz: 3714614b273560adb699b9ea6a9493d457cbb71ce20e3542886c0e7431e44b06ba2d28d1aabeac9d52883960c2dae3fd27a741409e82c2bb65ed0696520eca71
7
- data.tar.gz: bec40fd36b93ec1a745f001fda04b9997567d3c2ae2d60e507bfb8ce6f828c07b2c2619585e1e8f750e76749eb3a6e3f8617f056b69912328598e089468d3122
6
+ metadata.gz: 76b27bb7675df86c7bcbaab037cd925ae0b38d5d7b02634dd596776d039c7af22377c3cc2f868afa07d6e86260b632ea112c404efbffffcb9c815c10ff263002
7
+ data.tar.gz: 4bb8c017c50005483deabac163d9df33bfbb3ac6b43522444fc9cc8c9ef24a4ec675d072282fe8635787c4e48731c57396335a0350217b125530e93d173e6471
@@ -1,5 +1,5 @@
1
1
  module DynamodbGeo
2
2
  class Version
3
- STRING = '0.1.2'
3
+ STRING = '0.2.0'
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'])
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,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['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]
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
@@ -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.2
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: '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.2
130
+ summary: dynamodb_geo-0.2.0
131
131
  test_files:
132
132
  - spec/dynamodb_geo_spec.rb
133
133
  - spec/geohash_spec.rb