geomash 0.3.8 → 0.3.9

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
  SHA1:
3
- metadata.gz: 5b352aa88b7f74448b67dc9aa8bc1e0886483b48
4
- data.tar.gz: 6b217b344779f407b08906f1bb250fcd35f086db
3
+ metadata.gz: 0e61c5deca72356d721f4e23a4a85e0f3c0cb3aa
4
+ data.tar.gz: dfbf8a130fc2074622ad784a6f9449a6d7f6160c
5
5
  SHA512:
6
- metadata.gz: 58b2714da28ec388c7b07e82ea2c51c40b1b2d9fbded27f54bd8f0521cc6561cd3e5115cbc4b370275a51692a18020c9a5a7f78fce04c796e69d3899d5b1513c
7
- data.tar.gz: 881c889566bce33fdcba5109b9efef976f75409c9349ccdef41bc6fc09b0551d2bb6f33d8aa9bb7dd100a6789e95fdc90ab944e31a6d3cf7e2c7ad16c0ec6bdd
6
+ metadata.gz: b3ffdd653f2b124ff2c8ceea4c7b59300762f2b2b721673a57d9ccd99eaaffe45f2cdf123b7016882a0a9dc4bea8e4e6d450dfa8aebaa9612aa2bfdb8b8cca20
7
+ data.tar.gz: 6b041c033c95a04a55683acb016f6416ac54129d18e69888c10c250b0cfc7d621789d08c4f36db54404f2a25db1e00086fb13ae4c3ab2cce971504bc61209eac
@@ -11,7 +11,7 @@ module Geomash
11
11
  return ''
12
12
  end
13
13
 
14
- term_split_list = term.split(/[,\-\(\(]|>/).reject{ |e| e.empty? }
14
+ term_split_list = term.split(/[,\-\(\(>]|>/).reject{ |e| e.empty? }
15
15
  term_split_list.each{ |e| e.gsub!(/[^\w\s]/, "") } #Remove punctuation
16
16
  term_split_list.each{ |e| e.strip! } #Remove any extra remaining whitespace
17
17
  term_split_list.reject{ |e| e.empty? }
@@ -72,7 +72,7 @@ module Geomash
72
72
  end
73
73
  else
74
74
  #if term_split_list.length > 1
75
- geo_term = term.gsub('(', ',').gsub(' ,', ', ').gsub(' >', ',')
75
+ geo_term = term.gsub('(', ',').gsub(' ,', ', ').gsub(' >', ',').gsub(' >', ',')
76
76
  geo_term = geo_term.gsub(')', '')
77
77
  #end
78
78
 
@@ -96,18 +96,18 @@ module Geomash
96
96
  #Replace any four TGN dashes from removing a junk term
97
97
  geo_term = geo_term.gsub('----', '--')
98
98
 
99
- #Replace any semicolons with commas... possible strip them?
100
- geo_term = geo_term.gsub(';', ',')
101
-
102
99
  #Replace > with commas
103
100
  geo_term = geo_term.gsub('>', ',').gsub('>', ',')
104
101
 
102
+ #Replace any semicolons with commas... possible strip them?
103
+ geo_term = geo_term.gsub(';', ',')
104
+
105
105
  #Terms in paranthesis will cause some geographic parsers to freak out. Switch to commas instead.
106
106
  if geo_term.match(/[\(\)]+/)
107
107
  #Attempt to fix address if something like (word)
108
108
  if geo_term.match(/ \(+.*\)+/)
109
109
  #Make this replacement better?
110
- geo_term = geo_term.gsub(/ *\((?=[\S ]+\))/,', ')
110
+ geo_term = geo_term.gsub(/ *\((?=[\S ]*\))/,', ')
111
111
  geo_term = geo_term.gsub(')', '')
112
112
 
113
113
  #Else skip this as data returned likely will be unreliable for now... FIXME when use case occurs.
@@ -1,3 +1,3 @@
1
1
  module Geomash
2
- VERSION = "0.3.8"
2
+ VERSION = "0.3.9"
3
3
  end
data/test/geomash_test.rb CHANGED
@@ -21,6 +21,17 @@ class GeomashTest < ActiveSupport::TestCase
21
21
  assert_equal '4933002', result[:geonames][:id] if Geomash::Geonames.geonames_username != '<username>'
22
22
  assert_equal false, result[:geonames][:original_string_differs] if Geomash::Geonames.geonames_username != '<username>'
23
23
 
24
+ result = Geomash.parse('Massachusetts > Hampden (county) > Chicopee', true)
25
+ assert_equal 'Chicopee', result[:city_part]
26
+ assert_equal 'Massachusetts', result[:state_part]
27
+ assert_equal 'United States', result[:country_part]
28
+ assert_equal nil, result[:neighborhood_part]
29
+ assert_equal nil, result[:street_part]
30
+ assert_equal '2049596', result[:tgn][:id] if Geomash::TGN.tgn_enabled == true
31
+ assert_equal false, result[:tgn][:original_string_differs] if Geomash::TGN.tgn_enabled == true
32
+ assert_equal '4933002', result[:geonames][:id] if Geomash::Geonames.geonames_username != '<username>'
33
+ assert_equal false, result[:geonames][:original_string_differs] if Geomash::Geonames.geonames_username != '<username>'
34
+
24
35
  #Slight variation problem with neighborhood: 11. Bezirk (Vienna, Austria)--Biography
25
36
  result = Geomash.parse('15. Bezirk (Rudolfsheim-Fünfhaus, Vienna, Austria)--Exhibitions', true)
26
37
  assert_equal 'Vienna', result[:city_part]
@@ -57,6 +57,20 @@ class ParserTest < ActiveSupport::TestCase
57
57
 
58
58
  result = Geomash::Standardizer.parse_for_geographic_term('Blah (North Korea)')
59
59
  assert_equal 'Blah, North Korea', result
60
+
61
+ result = Geomash::Standardizer.parse_for_geographic_term('Massachusetts > Hampden (county) > Chicopee')
62
+ assert_equal 'Massachusetts, Hampden, county, Chicopee', result
63
+
64
+ result = Geomash::Standardizer.parse_for_geographic_term('Massachusetts &gt; Hampden (county) &gt; Chicopee')
65
+ assert_equal 'Massachusetts, Hampden, county, Chicopee', result
66
+ end
67
+
68
+ def test_geographic_standardizer
69
+ result = Geomash::Standardizer.standardize_geographic_term('Massachusetts > Hampden (county) > Chicopee')
70
+ assert_equal 'Massachusetts, Hampden, Chicopee', result
71
+
72
+ result = Geomash::Standardizer.standardize_geographic_term('Massachusetts &gt; Hampden (county) &gt; Chicopee')
73
+ assert_equal 'Massachusetts, Hampden, Chicopee', result
60
74
  end
61
75
 
62
76
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geomash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.8
4
+ version: 0.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Boston Public Library
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-25 00:00:00.000000000 Z
11
+ date: 2016-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport