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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8d9f6681a4904685bd6678d202b705258be40c4d
4
- data.tar.gz: a4d61b8baed63e2185500b1cba50deffdd45ecaa
3
+ metadata.gz: f260d5eccf43b6198afa53dbfb57b95a64606e15
4
+ data.tar.gz: 7ef2ce141bcda76e95d4f93ade84ae7fb68493f1
5
5
  SHA512:
6
- metadata.gz: 1d7e8d871a4be9318533c1fe0c8530d619d5ee477b97993e25544342425dac0973efb423a637bae84291d6d08c49950abfeb96c2ff777170f50a7cf3251a91fe
7
- data.tar.gz: 850f79dd5b1f41f452cf0554f45bf8409764a437c31e71aefd519ae3cf5735578361ec069a86e100f09109901ea9bb987fc8a7b45084cbdb23b8e2873e75fc64
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 = 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'
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 = Date.strptime(row['INSPECTION DATE'], '%m/%d/%Y')
158
- v.code = violation_code(row)
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 = Date.strptime(row['INSPECTION DATE'], '%m/%d/%Y')
167
- i.score = 100 - row['SCORE'].to_i
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
 
@@ -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 = Date.today
30
- fi.feed_version = '1.0'
29
+ fi.feed_date = Date.today
30
+ fi.feed_version = '1.0'
31
31
  fi.municipality_name = 'San Francisco'
32
- fi.municipality_url = 'https://www.sfdph.org/dph/EH/Food/Score/default.asp'
33
- fi.contact_email = 'contact@sfdph.org'
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['Score'].to_i
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: row['restaurant_name'],
24
- address: row['address'],
25
- city: row['city_name'],
26
- zipcode: row['zip_code']
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: row['serial_number'],
40
+ orig_key: row['serial_number'],
41
41
  business_orig_key: row['permit_number'],
42
- score: row['inspection_grade'],
43
- demerits: row['inspection_demerits'],
44
- date: row['inspection_date'],
45
- violations: 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: row['inspection_violation_id'],
55
- inspection_id: row['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: row['violation_id'],
67
- code: row['violation_code'],
68
- demerits: row['violation_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
@@ -10,7 +10,7 @@ module Eaternet
10
10
  end
11
11
 
12
12
  def convert(csv:, to_type:)
13
- csv_map(csv) { |row| try_to_create to_type, from_csv_row: row }
13
+ csv_map(csv) { |row| try_to_create to_type, from_csv_row: row }.compact
14
14
  end
15
15
 
16
16
  def map_csv
@@ -58,7 +58,7 @@ module Eaternet
58
58
  # @return [String]
59
59
  attr_accessor :type
60
60
  validates :type,
61
- inclusion: { in: %w(initial routine followup complaint) },
61
+ format: { with: /initial|routine|followup|complaint/i },
62
62
  allow_nil: true
63
63
 
64
64
  # @return [String]
@@ -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
- cache_path = generate_cache_path(source)
36
- download(source: source, dest: cache_path) if expired? cache_path
37
- FileUtils.cp cache_path, dest
38
- File.open dest
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.
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Eaternet
3
- VERSION = '1.3.7'
3
+ VERSION = '1.3.8'
4
4
  end
@@ -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
- # def test_inspections_returns_lives_attributes
44
- # VCR.use_cassette(SF_CASSETTE) do
45
- # i = @@sf.inspections.first(6).last
46
- # assert_equal '17', i.business_id
47
- # assert_equal Date.new(2012, 8, 23), i.date
48
- # assert_equal 100, i.score
49
- # end
50
- # end
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.7
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-08 00:00:00.000000000 Z
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.6.4
318
+ rubygems_version: 2.5.1
319
319
  signing_key:
320
320
  specification_version: 4
321
321
  summary: Regional adapters for restaurant health scores