melissa 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/melissa/addr_obj.rb +4 -1
- data/lib/melissa/addr_obj_mock.rb +1 -0
- data/lib/melissa/config.rb +14 -0
- data/lib/melissa/geo_point.rb +2 -21
- data/lib/melissa/geo_point_mock.rb +3 -6
- data/lib/melissa/version.rb +1 -1
- data/test/addr_obj_test.rb +2 -0
- data/test/geo_point_test.rb +4 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38aa1440526f55f5a85a72c7f8474cffeedc34f9
|
4
|
+
data.tar.gz: 8f618410d0d128f51273b1b7f8a7e19d3070698b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9437c18332658936df21a8c11ca0a05e1d92ce49c4cc928fbfabf6eb76d98f97318eb36dab36718524e71717643fcedba6ad2146179ac60081677e203a35eb1
|
7
|
+
data.tar.gz: 9b6b1801c36d49882e1e481715c59167f7ab50501674ea5af1285e985d9cb791ab0fd5c5999707326b31050727da02d9efa7031d925151500dc8e4eb71dfdd0d
|
data/Gemfile.lock
CHANGED
data/lib/melissa/addr_obj.rb
CHANGED
@@ -57,7 +57,10 @@ module Melissa
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def time_zone_offset
|
60
|
-
|
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
|
data/lib/melissa/config.rb
CHANGED
@@ -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
|
data/lib/melissa/geo_point.rb
CHANGED
@@ -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
|
-
|
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(
|
13
|
+
def initialize(opts)
|
14
14
|
@is_valid = false
|
15
|
-
|
16
|
-
|
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
|
data/lib/melissa/version.rb
CHANGED
data/test/addr_obj_test.rb
CHANGED
@@ -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
|
data/test/geo_point_test.rb
CHANGED
@@ -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
|
-
|
25
|
-
|
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
|
-
|
42
|
-
|
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.
|
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-
|
12
|
+
date: 2015-05-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|