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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c897d6faf9805e3e8d4c2c2ff8c71200d95bffe4
4
- data.tar.gz: d8f203475413d0f7fa2c1cb1a47b4abd29cf035d
3
+ metadata.gz: 8d9f6681a4904685bd6678d202b705258be40c4d
4
+ data.tar.gz: a4d61b8baed63e2185500b1cba50deffdd45ecaa
5
5
  SHA512:
6
- metadata.gz: 4f15fa3e30d5721253882acd667191917a8f77293573d134bf9665939bcd603ea293b2274b0c6c2ccb6b6423c846b08493a1af1f37328235d9956287bef082c8
7
- data.tar.gz: ad6cf99e1c02b3fe5f2ef6c6517cb265d5c6e9e6641a48204dce759992c439b980e8b0be9bb539cc37f5c1d1199978dbf23ec52c8556bd964b2d70d2f0b8b03c
6
+ metadata.gz: 1d7e8d871a4be9318533c1fe0c8530d619d5ee477b97993e25544342425dac0973efb423a637bae84291d6d08c49950abfeb96c2ff777170f50a7cf3251a91fe
7
+ data.tar.gz: 850f79dd5b1f41f452cf0554f45bf8409764a437c31e71aefd519ae3cf5735578361ec069a86e100f09109901ea9bb987fc8a7b45084cbdb23b8e2873e75fc64
@@ -1,5 +1,4 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.1
4
- - 2.2.1
5
3
  - 2.2.2
4
+ - 2.3.1
data/Gemfile CHANGED
@@ -1,4 +1,3 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'minitest-utils', git: 'https://github.com/dogweather/minitest-utils.git'
4
3
  gemspec
@@ -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'
@@ -1,3 +1,4 @@
1
+ require 'eaternet/version'
1
2
  require 'eaternet/agencies/multco'
2
3
  require 'eaternet/agencies/nyc'
3
4
  require 'eaternet/agencies/sf'
@@ -21,12 +21,14 @@ module Eaternet
21
21
 
22
22
  def businesses
23
23
  @prototype.businesses
24
- .map { |proto| try_to_create(:business, from_csv_row: proto) }
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
- .map { |proto| try_to_create(:inspection, from_csv_row: proto) }
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 = '|' # TODO: Verify this with SNHD.
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
- violations = row['violations'].split(',')
36
- else
37
- violations = []
38
- end
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, &block)
77
- csv_rows(filename).lazy.map { |row| block.call(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:, headers:)
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: 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(&row_handler)
16
+ def map_csv
18
17
  CSV.new(File.open(table_file, encoding: 'utf-8'), headers: true)
19
- .lazy
20
- .map { |row| row_handler.call(row) }
18
+ .lazy
19
+ .map { |row| yield(row) }
21
20
  end
22
21
 
23
- def csv_map(filename, &block)
24
- csv_rows(filename).lazy.map { |row| block.call(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
@@ -12,7 +12,7 @@ module Eaternet
12
12
  logger = Logger.new(ENV['EATERNET_LOG_FILE'] || $stderr)
13
13
  logger.datetime_format = '%Y-%m-%d %H:%M:%S'
14
14
  logger.progname = 'Eaternet'
15
- logger.level = Logger::ERROR
15
+ logger.level = Logger::WARN
16
16
  logger
17
17
  end
18
18
  end
@@ -71,8 +71,6 @@ module Eaternet
71
71
  (Time.now - File.mtime(path)).to_i / 86_400.0
72
72
  end
73
73
 
74
- private
75
-
76
74
  def self.expired?(cache_path)
77
75
  !File.exist?(cache_path) || file_age_in_days(cache_path) > 0.5
78
76
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Eaternet
3
- VERSION = '1.3.5'.freeze
3
+ VERSION = '1.3.7'
4
4
  end
@@ -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.5
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-04-24 00:00:00.000000000 Z
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.5.0
318
+ rubygems_version: 2.6.4
305
319
  signing_key:
306
320
  specification_version: 4
307
321
  summary: Regional adapters for restaurant health scores