melissa 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 625ef678d1c9036881ab0e7b91ebef31bcb1e035
4
- data.tar.gz: f7d15d546fa2f2bb82ac905d661751ed379ac400
3
+ metadata.gz: 38aa1440526f55f5a85a72c7f8474cffeedc34f9
4
+ data.tar.gz: 8f618410d0d128f51273b1b7f8a7e19d3070698b
5
5
  SHA512:
6
- metadata.gz: f1427c544d18ff571008eff0bd169d2da64ba3d883d8c9082efe71ab2e1438e8df626c69d193e3e96c3904a837c231f1257024d67cff08155cd7f20882507850
7
- data.tar.gz: 09730130a065c514854b6fff3ea91d4fccc4d526df0a86dd95178585379a3c36cd14fb39a91754c9e915b329c922916ea46f2445ca3283486d637781f93e3800
6
+ metadata.gz: a9437c18332658936df21a8c11ca0a05e1d92ce49c4cc928fbfabf6eb76d98f97318eb36dab36718524e71717643fcedba6ad2146179ac60081677e203a35eb1
7
+ data.tar.gz: 9b6b1801c36d49882e1e481715c59167f7ab50501674ea5af1285e985d9cb791ab0fd5c5999707326b31050727da02d9efa7031d925151500dc8e4eb71dfdd0d
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- melissa (0.0.2)
4
+ melissa (0.0.3)
5
5
  activesupport
6
6
  ffi
7
7
  minitest
@@ -57,7 +57,10 @@ module Melissa
57
57
  end
58
58
 
59
59
  def time_zone_offset
60
- GeoPoint.time_zone_offset(self.time_zone_code, self.state)
60
+ time_zone = TIME_ZONES[self.time_zone_code]
61
+ return nil unless time_zone
62
+ time_zone = 'US/Arizona' if self.state == 'AZ'
63
+ return Time.now.in_time_zone(time_zone).utc_offset / -60
61
64
  end
62
65
 
63
66
  def address_struct
@@ -18,6 +18,7 @@ module Melissa
18
18
  #@urbanization = opts[:urbanization] || ''
19
19
  @resultcodes = ['AS01']
20
20
  @address_type_string = 'Street'
21
+ @time_zone_code = '05'
21
22
  end
22
23
 
23
24
  #Mock
@@ -4,6 +4,20 @@ module Melissa
4
4
 
5
5
  MODES = [:mock, :live]
6
6
 
7
+ TIME_ZONES = {
8
+ '04' => 'Atlantic/Bermuda',
9
+ '05' => 'US/Eastern',
10
+ '06' => 'US/Central',
11
+ '07' => 'US/Mountain',
12
+ '08' => 'US/Pacific',
13
+ '09' => 'US/Alaska',
14
+ '10' => 'US/Hawaii',
15
+ '11' => 'US/Samoa',
16
+ '13' => 'Pacific/Majuro',
17
+ '14' => 'Pacific/Guam',
18
+ '15' => 'Pacific/Palau'
19
+ }
20
+
7
21
  class Config
8
22
 
9
23
  attr_accessor :mode, :license, :data_path, :addr_obj_lib, :geo_point_lib
@@ -39,20 +39,6 @@ module Melissa
39
39
  #@@bad_codes = ['GE01', 'GE02']
40
40
  @@fatal_codes = ['GE03', 'GE04', 'GE05']
41
41
 
42
- @@time_zones = {
43
- '04' => 'Atlantic/Bermuda',
44
- '05' => 'US/Eastern',
45
- '06' => 'US/Central',
46
- '07' => 'US/Mountain',
47
- '08' => 'US/Pacific',
48
- '09' => 'US/Alaska',
49
- '10' => 'US/Hawaii',
50
- '11' => 'US/Samoa',
51
- '13' => 'Pacific/Majuro',
52
- '14' => 'Pacific/Guam',
53
- '15' => 'Pacific/Palau'
54
- }
55
-
56
42
  def valid?
57
43
  # Make sure there is at least 1 good code
58
44
  @is_valid
@@ -68,13 +54,8 @@ module Melissa
68
54
  @longitude
69
55
  end
70
56
 
71
- def time_zone_offset
72
- GeoPoint.time_zone_offset(self.time_zone_code, @addr_obj.state)
73
- end
74
-
75
- # Hack for AddrObj to share code
76
- def self.time_zone_offset(time_zone_code, state=nil)
77
- time_zone = @@time_zones[time_zone_code]
57
+ def time_zone_offset(state=nil)
58
+ time_zone = TIME_ZONES[self.time_zone_code]
78
59
  return nil unless time_zone
79
60
  time_zone = 'US/Arizona' if state == 'AZ'
80
61
  return Time.now.in_time_zone(time_zone).utc_offset / -60
@@ -10,13 +10,10 @@ module Melissa
10
10
  EOS
11
11
  end
12
12
 
13
- def initialize(addr_obj)
13
+ def initialize(opts)
14
14
  @is_valid = false
15
-
16
- if addr_obj.kind_of?(AddrObj)
17
- @addr_obj = addr_obj
18
- else
19
- raise "Invalid call to GeoPoint, unknown object #{addr_obj.inspect}"
15
+ unless opts.kind_of?(AddrObj) || opts.kind_of?(Hash)
16
+ raise "Invalid call to GeoPoint, unknown object #{opts.inspect}"
20
17
  end
21
18
  @latitude = 27.850397
22
19
  @longitude = -82.659555
@@ -1,3 +1,3 @@
1
1
  module Melissa
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -21,6 +21,8 @@ class AddrObjTest < Minitest::Test
21
21
  assert_equal '2517 Surfwood Dr', valid_address.address
22
22
  assert_equal 'Las Vegas', valid_address.city
23
23
  assert_equal '89128718217', valid_address.delivery_point
24
+ offset = Time.now.in_time_zone('US/Pacific').dst? ? 420 : 480
25
+ assert_equal offset, valid_address.time_zone_offset
24
26
  end
25
27
 
26
28
  it 'flags invalid data' do
@@ -21,11 +21,8 @@ class GeoPointTest < Minitest::Test
21
21
  assert geo_point_obj.valid?
22
22
  assert_includes 36.2..36.3, geo_point_obj.latitude
23
23
  assert_includes -115.3..-115.2, geo_point_obj.longitude
24
- # offset = Time.now.in_time_zone('US/Eastern').dst? ? 240 : 300
25
- # assert_equal offset, geo_point.time_zone_offset
26
- #For the address above:
27
- #g.time_zone_offset
28
- #=> 480
24
+ offset = Time.now.in_time_zone('US/Pacific').dst? ? 420 : 480
25
+ assert_equal offset, geo_point_obj.time_zone_offset(valid_addr_obj.state)
29
26
  end
30
27
  it 'creates valid GeoPoint object from the Hash' do
31
28
  skip "Not run, Melissa library not loaded" unless Melissa::GeoPointLive.lib_loaded?
@@ -38,11 +35,8 @@ class GeoPointTest < Minitest::Test
38
35
  assert geo_point_obj.valid?
39
36
  assert_includes 36.2..36.3, geo_point_obj.latitude
40
37
  assert_includes -115.3..-115.2, geo_point_obj.longitude
41
- # offset = Time.now.in_time_zone('US/Eastern').dst? ? 240 : 300
42
- # assert_equal offset, geo_point.time_zone_offset
43
- #For the address above:
44
- #g.time_zone_offset
45
- #=> 480
38
+ offset = Time.now.in_time_zone('US/Pacific').dst? ? 420 : 480
39
+ assert_equal offset, geo_point_obj.time_zone_offset
46
40
  end
47
41
  end
48
42
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: melissa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brad Pardee
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-05-04 00:00:00.000000000 Z
12
+ date: 2015-05-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport