eaternet 0.4.6 → 0.4.7

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: cee1dfd59cbfd4d2ff5914c0f4a05aa4f0df68bf
4
- data.tar.gz: bb7a292eb048bb501557c871fae04c891ab5c80c
3
+ metadata.gz: fc17111a80609816dddf66515267734e22085088
4
+ data.tar.gz: 6df34dc57c4faadf6d754d933194f4a5cfc8da0e
5
5
  SHA512:
6
- metadata.gz: 90c77526acf205fff1be2570ce163806c2cbd3e75aa12a2f232fc130bafabce2363fc77c1d696f89a8717c890f5c070b14e78532a894ba3b5857af0865765d07
7
- data.tar.gz: 0e56fa6989291aabf01b83e2dee206696287f3a002aa7139e6dd348e6fbc00f185b5fffaa8fd72a63fe2c4cb16750890175eafd91d11c52db8882faccbf4e662
6
+ metadata.gz: 3b13979c1ef4944117a68deb206c81b5c573f71dd53f8017e27336fa22d227dac2001c1c5851e26acc4671c8633ee808e88f17effd8ff55b73ad5d86e1924977
7
+ data.tar.gz: a121ff06cae73d6c1ed22e041c7019e02bf2cc803d7556caa143b455f43ddf3228a7ebd6a15e34530fc78ca0943e362a4c622c19a263a90e6f17ebc135269fb3
@@ -161,9 +161,9 @@ module Eaternet
161
161
 
162
162
  Business.new do |b|
163
163
  b.business_id = business_id(row)
164
- b.name = Eaternet::Util.cleanup_title(row['DBA'])
165
- b.address = Eaternet::Util.cleanup_title(address)
166
- b.city = Eaternet::Util.cleanup_title(row['BORO'])
164
+ b.name = row['DBA']
165
+ b.address = address
166
+ b.city = row['BORO']
167
167
  b.postal_code = row['ZIPCODE']
168
168
  b.state = 'NY'
169
169
  b.phone_number = row['PHONE']
@@ -109,7 +109,7 @@ module Eaternet
109
109
  end
110
110
 
111
111
  def csv_reader(path:, headers:)
112
- file = open(path)
112
+ file = open(path, encoding: 'utf-8')
113
113
  file.readline # Skip the non-standard header line
114
114
  CSV.new(
115
115
  file,
@@ -43,9 +43,9 @@ module Eaternet
43
43
  def business(proto)
44
44
  Business.new do |b|
45
45
  b.business_id = proto.orig_key
46
- b.name = Eaternet::Util.cleanup_title(proto.name)
47
- b.address = Eaternet::Util.cleanup_title(proto.address)
48
- b.city = Eaternet::Util.cleanup_title(proto.city)
46
+ b.name = proto.name
47
+ b.address = proto.address
48
+ b.city = proto.city
49
49
  b.postal_code = proto.zipcode
50
50
  b.state = 'NV'
51
51
  end
@@ -79,7 +79,7 @@ module Eaternet
79
79
 
80
80
  def _violations
81
81
  violation_kinds = {}
82
- @prototype.violation_kinds.to_a.each do |vk|
82
+ @prototype.violation_kinds.each do |vk|
83
83
  violation_kinds[vk.orig_key] = vk
84
84
  end
85
85
 
data/lib/eaternet/util.rb CHANGED
@@ -61,23 +61,6 @@ module Eaternet
61
61
  end
62
62
  end
63
63
 
64
- # Remove extraneous whitespace and ensure capitalization
65
- # is correct for a proper name or title.
66
- #
67
- # @return [String] the cleaned up string
68
- def self.cleanup_title(a_string)
69
- return nil if a_string.nil?
70
- titleize(cleanup(a_string))
71
- end
72
-
73
- # Remove extraneous whitespace from the string
74
- #
75
- # @return [String] the cleaned up string
76
- def self.cleanup(a_string)
77
- return nil if a_string.nil?
78
- a_string.strip.gsub(/ +/, ' ')
79
- end
80
-
81
64
  # @return [Float]
82
65
  def self.file_age_in_days(path)
83
66
  (Time.now - File.mtime(path)).to_i / 86_400.0
@@ -100,50 +83,5 @@ module Eaternet
100
83
  `mkdir -p #{cache_dir}`
101
84
  cache_dir
102
85
  end
103
-
104
- #
105
- # A titleize that creates a usable title according to grammar rules.
106
- #
107
- ARTICLES = Set.new %w(a an and by di et for in is not of on or over the to under with)
108
-
109
- def self.titleize(a_string)
110
- # Only fix if all uppercase
111
- return a_string unless all_uppercase?(a_string)
112
-
113
- result = []
114
-
115
- for word in a_string.downcase.split(/[[:space:]]/) # handle unicode
116
- if irish?(word)
117
- result << inflect_irish(word)
118
- else
119
- word = word.capitalize unless ARTICLES.include? word
120
- result << word
121
- end
122
- end
123
-
124
- just_capitalize(result.join(' '))
125
- end
126
-
127
- def self.all_uppercase?(a_string)
128
- a_string.upcase == a_string
129
- end
130
-
131
- def self.irish?(a_string)
132
- a_string =~ /^((ma?c)|(o')).+$/ && !italian?(a_string)
133
- end
134
-
135
- def self.italian?(a_string)
136
- %w(macaron macaroni macchiato machiavelli).include? a_string
137
- end
138
-
139
- def self.inflect_irish(a_string)
140
- a_string =~ /^((ma?c)|(o'))(.+)$/
141
- Regexp.last_match(1).capitalize + Regexp.last_match(4).capitalize
142
- end
143
-
144
- def self.just_capitalize(a_string)
145
- head, tail = a_string.split(//, 2)
146
- head.upcase + tail
147
- end
148
86
  end
149
87
  end
@@ -1,3 +1,3 @@
1
1
  module Eaternet
2
- VERSION = '0.4.6'
2
+ VERSION = '0.4.7'
3
3
  end
@@ -32,9 +32,9 @@ class NycAdapterTest < Minitest::Test
32
32
  def test_businesses_returns_lives_attributes
33
33
  b = @@nyc.businesses.first
34
34
  assert_equal '30075445', b.business_id
35
- assert_equal 'Morris Park Bake Shop', b.name
36
- assert_equal '1007 Morris Park Ave', b.address
37
- assert_equal 'Bronx', b.city
35
+ assert_equal 'MORRIS PARK BAKE SHOP', b.name
36
+ assert_equal '1007 MORRIS PARK AVE', b.address
37
+ assert_equal 'BRONX', b.city
38
38
  assert_equal '10462', b.postal_code
39
39
  assert_equal 'NY', b.state
40
40
  assert_equal '7188924968', b.phone_number
@@ -44,17 +44,6 @@ class NycAdapterTest < Minitest::Test
44
44
  assert_equal 1, @@nyc.businesses.to_a.size
45
45
  end
46
46
 
47
- def test_cleans_up_whitespace_1
48
- b = @@nyc.business(@may_may_data)
49
- assert_equal '1269 Sutter Avenue', b.address
50
- end
51
-
52
- def test_cleans_up_whitespace_2
53
- @may_may_data['STREET'] = 'EAST 52 STREET '
54
- b = @@nyc.business(@may_may_data)
55
- assert_equal '1269 East 52 Street', b.address
56
- end
57
-
58
47
  #
59
48
  # Inspections
60
49
  #
@@ -44,71 +44,4 @@ class UtilTest < Minitest::Test
44
44
  assert_requested :get, @url, times: 2
45
45
  end
46
46
 
47
- #
48
- # #cleanup_title
49
- #
50
-
51
- def assert_cleans_up_to(output, input)
52
- assert_equal output, Eaternet::Util.cleanup_title(input)
53
- end
54
-
55
- def test_doesnt_mess_up_numeric_streets
56
- assert_cleans_up_to '1654 86th St', '1654 86TH ST'
57
- end
58
-
59
- # Irish
60
-
61
- def test_mcdonald_avenue
62
- assert_cleans_up_to '1158 McDonald Avenue', '1158 MCDONALD AVENUE'
63
- end
64
-
65
- def test_mckennas_pub
66
- assert_cleans_up_to "McKenna's Pub", "MCKENNA'S PUB"
67
- end
68
-
69
- def test_macdougal_street
70
- assert_cleans_up_to '122 MacDougal St', '122 MACDOUGAL ST'
71
- end
72
-
73
- def test_o_sullivans_pub
74
- assert_cleans_up_to "O'Sullivan's Pub", "O'SULLIVAN'S PUB"
75
- end
76
-
77
- def test_mc_sorleys
78
- assert_cleans_up_to "McSorley's Old Ale House", "MCSORLEY'S OLD ALE HOUSE"
79
- end
80
-
81
- # Italian
82
-
83
- def test_macchiato
84
- assert_cleans_up_to 'Macchiato Espresso Bar', 'MACCHIATO ESPRESSO BAR'
85
- end
86
-
87
- def test_di_vittorio
88
- assert_cleans_up_to 'La Lanterna di Vittorio', 'LA LANTERNA DI VITTORIO'
89
- end
90
-
91
- def test_machiavelli
92
- assert_cleans_up_to 'Machiavelli', 'MACHIAVELLI'
93
- end
94
-
95
- def test_macaroni
96
- assert_cleans_up_to 'Macaroni', 'MACARONI'
97
- end
98
-
99
- # French
100
-
101
- def test_rouge_et_blanc
102
- assert_cleans_up_to 'Rouge et Blanc', 'ROUGE ET BLANC'
103
- end
104
-
105
- def test_macaron
106
- assert_cleans_up_to 'Macaron', 'MACARON'
107
- end
108
-
109
- # Weird
110
-
111
- def test_weird_stuff
112
- assert_cleans_up_to 'aBcDeFg', 'aBcDeFg'
113
- end
114
47
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eaternet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.6
4
+ version: 0.4.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robb Shecter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-30 00:00:00.000000000 Z
11
+ date: 2015-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler