eaternet 1.3.7 → 1.3.8
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 +10 -10
- data/lib/eaternet/agencies/sf.rb +5 -5
- data/lib/eaternet/agencies/snhd_prototype.rb +14 -14
- data/lib/eaternet/lives_1_0/csv_parser.rb +1 -1
- data/lib/eaternet/lives_1_0/inspection.rb +1 -1
- data/lib/eaternet/util.rb +5 -4
- data/lib/eaternet/version.rb +1 -1
- data/test/eaternet/agencies/sf_test.rb +12 -10
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f260d5eccf43b6198afa53dbfb57b95a64606e15
|
4
|
+
data.tar.gz: 7ef2ce141bcda76e95d4f93ade84ae7fb68493f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29ea9910630f0225e4f835631396d95c47677485fcaecdc62f034a0a749132cab2c2871243f451fac8aca58a9f88588f24edd6527fe283467faafe7537a3ce47
|
7
|
+
data.tar.gz: 1a963f7b6143f797644bb1345d85f46a19738a5f9cdebca77797997d1d18445ee80646961d0a24f37feef93f2670646950f732b71e7e1d576261fb3d0ad1a6d1
|
@@ -139,12 +139,12 @@ module Eaternet
|
|
139
139
|
address = "#{row['BUILDING']} #{row['STREET']}"
|
140
140
|
|
141
141
|
Eaternet::Lives_1_0::Business.new do |b|
|
142
|
-
b.business_id =
|
143
|
-
b.name =
|
144
|
-
b.address =
|
145
|
-
b.city =
|
146
|
-
b.postal_code =
|
147
|
-
b.state =
|
142
|
+
b.business_id = business_id(row)
|
143
|
+
b.name = row['DBA']
|
144
|
+
b.address = address
|
145
|
+
b.city = row['BORO']
|
146
|
+
b.postal_code = row['ZIPCODE']
|
147
|
+
b.state = 'NY'
|
148
148
|
b.phone_number = row['PHONE']
|
149
149
|
end
|
150
150
|
end
|
@@ -154,8 +154,8 @@ module Eaternet
|
|
154
154
|
def violation(row)
|
155
155
|
Eaternet::Lives_1_0::Violation.new do |v|
|
156
156
|
v.business_id = business_id(row)
|
157
|
-
v.date =
|
158
|
-
v.code =
|
157
|
+
v.date = Date.strptime(row['INSPECTION DATE'], '%m/%d/%Y')
|
158
|
+
v.code = violation_code(row)
|
159
159
|
v.description = row['VIOLATION DESCRIPTION']
|
160
160
|
end
|
161
161
|
end
|
@@ -163,8 +163,8 @@ module Eaternet
|
|
163
163
|
def inspection(row)
|
164
164
|
Eaternet::Lives_1_0::Inspection.new do |i|
|
165
165
|
i.business_id = business_id(row)
|
166
|
-
i.date =
|
167
|
-
i.score =
|
166
|
+
i.date = Date.strptime(row['INSPECTION DATE'], '%m/%d/%Y')
|
167
|
+
i.score = 100 - row['SCORE'].to_i
|
168
168
|
end
|
169
169
|
end
|
170
170
|
|
data/lib/eaternet/agencies/sf.rb
CHANGED
@@ -26,11 +26,11 @@ module Eaternet
|
|
26
26
|
|
27
27
|
def feed_info
|
28
28
|
Eaternet::Lives_1_0::FeedInfo.new do |fi|
|
29
|
-
fi.feed_date =
|
30
|
-
fi.feed_version =
|
29
|
+
fi.feed_date = Date.today
|
30
|
+
fi.feed_version = '1.0'
|
31
31
|
fi.municipality_name = 'San Francisco'
|
32
|
-
fi.municipality_url =
|
33
|
-
fi.contact_email =
|
32
|
+
fi.municipality_url = 'https://www.sfdph.org/dph/EH/Food/Score/default.asp'
|
33
|
+
fi.contact_email = 'contact@sfdph.org'
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
@@ -57,7 +57,7 @@ module Eaternet
|
|
57
57
|
csv_row.headers.each do |header|
|
58
58
|
b.send("#{header.downcase}=", csv_row[header])
|
59
59
|
b.date = Date.parse(csv_row['date'])
|
60
|
-
b.score = csv_row['
|
60
|
+
b.score = csv_row['score'].to_i
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
@@ -20,10 +20,10 @@ module Eaternet
|
|
20
20
|
lazy_csv_map('restaurant_establishments.csv') do |row|
|
21
21
|
Eaternet::Prototype::BusinessData.new(
|
22
22
|
orig_key: row['permit_number'],
|
23
|
-
name:
|
24
|
-
address:
|
25
|
-
city:
|
26
|
-
zipcode:
|
23
|
+
name: row['restaurant_name'],
|
24
|
+
address: row['address'],
|
25
|
+
city: row['city_name'],
|
26
|
+
zipcode: row['zip_code']
|
27
27
|
)
|
28
28
|
end
|
29
29
|
end
|
@@ -37,12 +37,12 @@ module Eaternet
|
|
37
37
|
[]
|
38
38
|
end
|
39
39
|
Eaternet::Prototype::InspectionData.new(
|
40
|
-
orig_key:
|
40
|
+
orig_key: row['serial_number'],
|
41
41
|
business_orig_key: row['permit_number'],
|
42
|
-
score:
|
43
|
-
demerits:
|
44
|
-
date:
|
45
|
-
violations:
|
42
|
+
score: row['inspection_grade'],
|
43
|
+
demerits: row['inspection_demerits'],
|
44
|
+
date: row['inspection_date'],
|
45
|
+
violations: violations
|
46
46
|
)
|
47
47
|
end
|
48
48
|
end
|
@@ -51,8 +51,8 @@ module Eaternet
|
|
51
51
|
def violations
|
52
52
|
lazy_csv_map('restaurant_inspection_violations.csv') do |row|
|
53
53
|
Eaternet::Prototype::ViolationData.new(
|
54
|
-
orig_key:
|
55
|
-
inspection_id:
|
54
|
+
orig_key: row['inspection_violation_id'],
|
55
|
+
inspection_id: row['inspection_id'],
|
56
56
|
violation_kind_id: row['inspection_violation']
|
57
57
|
)
|
58
58
|
end
|
@@ -63,9 +63,9 @@ module Eaternet
|
|
63
63
|
def violation_kinds
|
64
64
|
lazy_csv_map('restaurant_violations.csv') do |row|
|
65
65
|
Eaternet::Prototype::ViolationKindData.new(
|
66
|
-
orig_key:
|
67
|
-
code:
|
68
|
-
demerits:
|
66
|
+
orig_key: row['violation_id'],
|
67
|
+
code: row['violation_code'],
|
68
|
+
demerits: row['violation_demerits'],
|
69
69
|
description: row['violation_description']
|
70
70
|
)
|
71
71
|
end
|
data/lib/eaternet/util.rb
CHANGED
@@ -32,10 +32,11 @@ module Eaternet
|
|
32
32
|
# @param [String] dest pathname in which to save the file
|
33
33
|
# @return [File] the file
|
34
34
|
def self.download_and_cache(source:, dest:)
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
35
|
+
download(source: source, dest: dest)
|
36
|
+
# cache_path = generate_cache_path(source)
|
37
|
+
# download(source: source, dest: cache_path) if expired? cache_path
|
38
|
+
# FileUtils.cp cache_path, dest
|
39
|
+
# File.open dest
|
39
40
|
end
|
40
41
|
|
41
42
|
# Download a file from the network.
|
data/lib/eaternet/version.rb
CHANGED
@@ -26,7 +26,7 @@ class SfTest < Minitest::Test
|
|
26
26
|
assert_equal 'CA', b.state
|
27
27
|
assert_equal 37.791116, b.latitude
|
28
28
|
assert_equal -122.403816, b.longitude
|
29
|
-
assert_equal '', b.phone_number
|
29
|
+
assert_equal '+14154217044', b.phone_number
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
@@ -39,15 +39,16 @@ class SfTest < Minitest::Test
|
|
39
39
|
assert enumerable_of? Eaternet::Lives_1_0::Inspection, @@sf.inspections
|
40
40
|
end
|
41
41
|
end
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
42
|
+
|
43
|
+
def test_inspections_returns_lives_attributes
|
44
|
+
VCR.use_cassette(SF_CASSETTE) do
|
45
|
+
chosen_inspection = @@sf.inspections
|
46
|
+
.select { |i| i.business_id == "19" && i.date == Date.new(2016, 5, 13) }
|
47
|
+
.first
|
48
|
+
raise "Couldn't find the chosen inspection" if chosen_inspection.nil?
|
49
|
+
assert_equal 94, chosen_inspection.score
|
50
|
+
end
|
51
|
+
end
|
51
52
|
|
52
53
|
#
|
53
54
|
# Violations
|
@@ -59,6 +60,7 @@ class SfTest < Minitest::Test
|
|
59
60
|
end
|
60
61
|
end
|
61
62
|
|
63
|
+
# TODO: Fix this test
|
62
64
|
# def test_violations_returns_lives_attributes
|
63
65
|
# VCR.use_cassette(SF_CASSETTE) do
|
64
66
|
# v = @@sf.violations.first
|
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: 1.3.
|
4
|
+
version: 1.3.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robb Shecter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -315,7 +315,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
315
315
|
version: '0'
|
316
316
|
requirements: []
|
317
317
|
rubyforge_project:
|
318
|
-
rubygems_version: 2.
|
318
|
+
rubygems_version: 2.5.1
|
319
319
|
signing_key:
|
320
320
|
specification_version: 4
|
321
321
|
summary: Regional adapters for restaurant health scores
|