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 +4 -4
- data/lib/eaternet/agencies/nyc.rb +3 -3
- data/lib/eaternet/agencies/snhd.rb +1 -1
- data/lib/eaternet/agencies/snhd_lives.rb +4 -4
- data/lib/eaternet/util.rb +0 -62
- data/lib/eaternet/version.rb +1 -1
- data/test/eaternet/agencies/nyc_test.rb +3 -14
- data/test/eaternet/util_test.rb +0 -67
- 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: fc17111a80609816dddf66515267734e22085088
|
4
|
+
data.tar.gz: 6df34dc57c4faadf6d754d933194f4a5cfc8da0e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 =
|
165
|
-
b.address =
|
166
|
-
b.city =
|
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']
|
@@ -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 =
|
47
|
-
b.address =
|
48
|
-
b.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.
|
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
|
data/lib/eaternet/version.rb
CHANGED
@@ -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 '
|
36
|
-
assert_equal '1007
|
37
|
-
assert_equal '
|
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
|
#
|
data/test/eaternet/util_test.rb
CHANGED
@@ -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.
|
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-
|
11
|
+
date: 2015-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|