eaternet 1.3.5 → 1.3.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -2
- data/Gemfile +0 -1
- data/eaternet.gemspec +1 -0
- data/lib/eaternet.rb +1 -0
- data/lib/eaternet/agencies/snhd.rb +5 -3
- data/lib/eaternet/agencies/snhd_config.rb +3 -55
- data/lib/eaternet/agencies/snhd_prototype.rb +10 -14
- data/lib/eaternet/lives_1_0/csv_parser.rb +5 -7
- data/lib/eaternet/loggable.rb +1 -1
- data/lib/eaternet/util.rb +0 -2
- data/lib/eaternet/version.rb +1 -1
- data/lib/ext/enumerator.rb +1 -1
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d9f6681a4904685bd6678d202b705258be40c4d
|
4
|
+
data.tar.gz: a4d61b8baed63e2185500b1cba50deffdd45ecaa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d7e8d871a4be9318533c1fe0c8530d619d5ee477b97993e25544342425dac0973efb423a637bae84291d6d08c49950abfeb96c2ff777170f50a7cf3251a91fe
|
7
|
+
data.tar.gz: 850f79dd5b1f41f452cf0554f45bf8409764a437c31e71aefd519ae3cf5735578361ec069a86e100f09109901ea9bb987fc8a7b45084cbdb23b8e2873e75fc64
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/eaternet.gemspec
CHANGED
@@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_development_dependency 'guard-minitest'
|
25
25
|
spec.add_development_dependency 'minitest'
|
26
26
|
spec.add_development_dependency 'minitest-perf'
|
27
|
+
spec.add_development_dependency 'minitest-utils'
|
27
28
|
spec.add_development_dependency 'pry'
|
28
29
|
spec.add_development_dependency 'rake', '~> 10'
|
29
30
|
spec.add_development_dependency 'timecop'
|
data/lib/eaternet.rb
CHANGED
@@ -21,12 +21,14 @@ module Eaternet
|
|
21
21
|
|
22
22
|
def businesses
|
23
23
|
@prototype.businesses
|
24
|
-
|
24
|
+
.map { |proto| try_to_create(:business, from_csv_row: proto) }
|
25
|
+
.compact
|
25
26
|
end
|
26
27
|
|
27
28
|
def inspections
|
28
29
|
@prototype.inspections
|
29
|
-
|
30
|
+
.map { |proto| try_to_create(:inspection, from_csv_row: proto) }
|
31
|
+
.compact
|
30
32
|
end
|
31
33
|
|
32
34
|
def business(proto)
|
@@ -88,7 +90,7 @@ module Eaternet
|
|
88
90
|
end
|
89
91
|
end
|
90
92
|
end
|
91
|
-
result
|
93
|
+
result.compact
|
92
94
|
end
|
93
95
|
end
|
94
96
|
end
|
@@ -2,61 +2,9 @@ module Eaternet
|
|
2
2
|
module Agencies
|
3
3
|
# @private
|
4
4
|
class SnhdConfig
|
5
|
-
DOWNLOAD_URL = 'http://southernnevadahealthdistrict.org/restaurants/download/restaurants.zip'
|
6
|
-
COLUMN_SEPARATOR = ';'
|
7
|
-
QUOTE_CHARACTER = '|'
|
8
|
-
|
9
|
-
# The SNHD CSV does not have a true header row. And so, this data
|
10
|
-
# structure provides the column names.
|
11
|
-
CSV_SCHEMA = {
|
12
|
-
'restaurant_inspections.csv' => %w(
|
13
|
-
serial_number
|
14
|
-
permit_number
|
15
|
-
inspection_date
|
16
|
-
inspection_time
|
17
|
-
employee_id
|
18
|
-
inspection_type_id
|
19
|
-
inspection_demerits
|
20
|
-
inspection_grade
|
21
|
-
permit_status
|
22
|
-
inspection_result
|
23
|
-
violations
|
24
|
-
record_updated
|
25
|
-
),
|
26
|
-
'restaurant_establishments.csv' => %w(
|
27
|
-
permit_number
|
28
|
-
facility_id
|
29
|
-
PE
|
30
|
-
restaurant_name
|
31
|
-
location_name
|
32
|
-
address
|
33
|
-
latitude
|
34
|
-
longitude
|
35
|
-
city_id
|
36
|
-
city_name
|
37
|
-
zip_code
|
38
|
-
nciaa
|
39
|
-
plan_review
|
40
|
-
record_status
|
41
|
-
current_grade
|
42
|
-
current_demerits
|
43
|
-
date_current
|
44
|
-
previous_grade
|
45
|
-
date_previous
|
46
|
-
),
|
47
|
-
'restaurant_inspection_violations.csv' => %w(
|
48
|
-
inspection_violation_id
|
49
|
-
inspection_id
|
50
|
-
inspection_violation
|
51
|
-
),
|
52
|
-
'restaurant_violations.csv' => %w(
|
53
|
-
violation_id
|
54
|
-
violation_code
|
55
|
-
violation_sort
|
56
|
-
violation_demerits
|
57
|
-
violation_description
|
58
|
-
)
|
59
|
-
}
|
5
|
+
DOWNLOAD_URL = 'http://southernnevadahealthdistrict.org/restaurants/download/restaurants.zip'.freeze
|
6
|
+
COLUMN_SEPARATOR = ';'.freeze
|
7
|
+
QUOTE_CHARACTER = '|'.freeze # TODO: Verify this with SNHD.
|
60
8
|
end
|
61
9
|
end
|
62
10
|
end
|
@@ -31,11 +31,11 @@ module Eaternet
|
|
31
31
|
# (see Eaternet::Prototype::AbstractAdapter#inspections)
|
32
32
|
def inspections
|
33
33
|
lazy_csv_map('restaurant_inspections.csv') do |row|
|
34
|
-
if row['violations']
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
34
|
+
violations = if row['violations']
|
35
|
+
row['violations'].split(',')
|
36
|
+
else
|
37
|
+
[]
|
38
|
+
end
|
39
39
|
Eaternet::Prototype::InspectionData.new(
|
40
40
|
orig_key: row['serial_number'],
|
41
41
|
business_orig_key: row['permit_number'],
|
@@ -73,23 +73,19 @@ module Eaternet
|
|
73
73
|
|
74
74
|
private
|
75
75
|
|
76
|
-
def lazy_csv_map(filename
|
77
|
-
csv_rows(filename).lazy.map { |row|
|
76
|
+
def lazy_csv_map(filename)
|
77
|
+
csv_rows(filename).lazy.map { |row| yield(row) }
|
78
78
|
end
|
79
79
|
|
80
80
|
def csv_rows(filename)
|
81
|
-
csv_reader(
|
82
|
-
path: File.join(zip_dir, filename),
|
83
|
-
headers: SnhdConfig::CSV_SCHEMA[filename]
|
84
|
-
)
|
81
|
+
csv_reader path: File.join(zip_dir, filename)
|
85
82
|
end
|
86
83
|
|
87
|
-
def csv_reader(path
|
84
|
+
def csv_reader(path:)
|
88
85
|
file = open(path, encoding: 'utf-8')
|
89
|
-
file.readline # Skip the non-standard header line
|
90
86
|
CSV.new(
|
91
87
|
file,
|
92
|
-
headers:
|
88
|
+
headers: true,
|
93
89
|
col_sep: SnhdConfig::COLUMN_SEPARATOR,
|
94
90
|
quote_char: SnhdConfig::QUOTE_CHARACTER
|
95
91
|
)
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module Eaternet
|
2
2
|
module Lives_1_0
|
3
3
|
module CsvParser
|
4
|
-
|
5
4
|
def adapter_name
|
6
5
|
fail 'Override #adapter_name with a name for log output, e.g. "SF"'
|
7
6
|
end
|
@@ -14,14 +13,14 @@ module Eaternet
|
|
14
13
|
csv_map(csv) { |row| try_to_create to_type, from_csv_row: row }
|
15
14
|
end
|
16
15
|
|
17
|
-
def map_csv
|
16
|
+
def map_csv
|
18
17
|
CSV.new(File.open(table_file, encoding: 'utf-8'), headers: true)
|
19
|
-
|
20
|
-
|
18
|
+
.lazy
|
19
|
+
.map { |row| yield(row) }
|
21
20
|
end
|
22
21
|
|
23
|
-
def csv_map(filename
|
24
|
-
csv_rows(filename).lazy.map { |row|
|
22
|
+
def csv_map(filename)
|
23
|
+
csv_rows(filename).lazy.map { |row| yield(row) }
|
25
24
|
end
|
26
25
|
|
27
26
|
def csv_rows(filename)
|
@@ -40,7 +39,6 @@ module Eaternet
|
|
40
39
|
end
|
41
40
|
nil
|
42
41
|
end
|
43
|
-
|
44
42
|
end
|
45
43
|
end
|
46
44
|
end
|
data/lib/eaternet/loggable.rb
CHANGED
data/lib/eaternet/util.rb
CHANGED
data/lib/eaternet/version.rb
CHANGED
data/lib/ext/enumerator.rb
CHANGED
@@ -8,7 +8,7 @@ class Enumerator
|
|
8
8
|
|
9
9
|
# Thanks to u/0x0dea for the lazy implementation.
|
10
10
|
#
|
11
|
-
# @author u/0x0dea
|
11
|
+
# @author u/0x0dea
|
12
12
|
# @see http://www.reddit.com/r/ruby/comments/37jpnz/is_this_the_best_laziest_way_to_add_compact_and/crnckrv Discussion thread
|
13
13
|
# @return [Enumerator] only my unique elements
|
14
14
|
def uniq
|
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.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: 2016-
|
11
|
+
date: 2016-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: minitest-utils
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: pry
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -301,7 +315,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
301
315
|
version: '0'
|
302
316
|
requirements: []
|
303
317
|
rubyforge_project:
|
304
|
-
rubygems_version: 2.
|
318
|
+
rubygems_version: 2.6.4
|
305
319
|
signing_key:
|
306
320
|
specification_version: 4
|
307
321
|
summary: Regional adapters for restaurant health scores
|