plus_codes 0.1.1 → 0.1.2
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 +4 -4
- data/lib/plus_codes/open_location_code.rb +7 -10
- data/lib/plus_codes/version.rb +1 -1
- data/test/plus_codes_test.rb +5 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69d6043d4051f33ae155cb1659af7e8e533054ae
|
4
|
+
data.tar.gz: 2eddbf67c2fd1e8ae3b230150868a074d173d41a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a1d9f99221ae07169b7dcd1145b7a0a2a863636043fa5f6d602abd919c992e614cd9a2c2f332abd7feb5abb2267406816f4632273f6c93948055c3bb76c632c
|
7
|
+
data.tar.gz: d81015cd0361126dc140b86590bdd28bee3a6f6f26caff6a78a9ef77154c6ced5ebf5992b2b9366a74be16cf56a638b014daa287524feee91fd7c3c30ff4f752
|
@@ -25,16 +25,13 @@ module PlusCodes
|
|
25
25
|
# We can have an even number of padding characters before the separator,
|
26
26
|
# but then it must be the final character.
|
27
27
|
if code.include?(PADDING)
|
28
|
-
# Not allowed to start with them!
|
29
28
|
return false if code.start_with?(PADDING)
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
return false if
|
34
|
-
|
35
|
-
return false if
|
36
|
-
|
37
|
-
# If the code is long enough to end with a separator, make sure it does.
|
29
|
+
pad_match = code.scan(/#{PADDING}+/)
|
30
|
+
return false unless pad_match.one?
|
31
|
+
padding = pad_match[0]
|
32
|
+
return false if padding.length.odd?
|
33
|
+
return false if padding.length > SEPARATOR_POSITION - 2
|
34
|
+
return false if code[-2] != PADDING
|
38
35
|
return false if code[-1] != SEPARATOR
|
39
36
|
end
|
40
37
|
|
@@ -312,7 +309,7 @@ module PlusCodes
|
|
312
309
|
lng_place_value = GRID_SIZE_DEGREES
|
313
310
|
(0...code.length).each do |i|
|
314
311
|
code_index = DECODE[code[i].ord]
|
315
|
-
row = (code_index / GRID_COLUMNS).floor
|
312
|
+
row = (code_index / GRID_COLUMNS).floor
|
316
313
|
col = code_index % GRID_COLUMNS
|
317
314
|
|
318
315
|
lat_place_value /= GRID_ROWS
|
data/lib/plus_codes/version.rb
CHANGED
data/test/plus_codes_test.rb
CHANGED
@@ -18,7 +18,7 @@ class PlusCodesTest < Test::Unit::TestCase
|
|
18
18
|
is_valid_olc = @olc.valid?(code)
|
19
19
|
is_short_olc = @olc.short?(code)
|
20
20
|
is_full_olc = @olc.full?(code)
|
21
|
-
result =
|
21
|
+
result = is_valid_olc == is_valid && is_short_olc == is_short && is_full_olc == is_full
|
22
22
|
assert_true(result)
|
23
23
|
end
|
24
24
|
end
|
@@ -74,6 +74,10 @@ class PlusCodesTest < Test::Unit::TestCase
|
|
74
74
|
@olc.recover_nearest('9C3W9QCJ+2VX', 51.3708675, -1.217765625)
|
75
75
|
end
|
76
76
|
|
77
|
+
def test_valid?_with_speacial_case
|
78
|
+
assert_false(@olc.valid?('3W00CJJJ+'))
|
79
|
+
end
|
80
|
+
|
77
81
|
def read_csv_lines(csv_file)
|
78
82
|
f = File.open(File.join(@test_data_folder_path, csv_file), 'r')
|
79
83
|
f.each_line.lazy.select { |line| line !~ /^\s*#/ }.map { |line| line.chop }
|