Class: Eaternet::Agencies::Austin
Overview
Class Method Summary
collapse
Instance Method Summary
collapse
#convert, #csv_map, #csv_rows, #map_csv, #try_to_create, #zip_dir, #zip_file_url
Methods included from Loggable
#logger
Constructor Details
#initialize(csv_path: nil) ⇒ Austin
Create an Austin data-source, ready for querying.
19
20
21
|
# File 'lib/eaternet/agencies/austin.rb', line 19
def initialize(csv_path: nil)
@table_file = csv_path
end
|
Class Method Details
.csv_url ⇒ Object
109
110
111
|
# File 'lib/eaternet/agencies/austin.rb', line 109
def self.csv_url
Eaternet::Socrata.csv_url domain: 'data.austintexas.gov', dataset: 'ecmv-9xxi'
end
|
.download_via_url ⇒ Object
105
106
107
|
# File 'lib/eaternet/agencies/austin.rb', line 105
def self.download_via_url
Eaternet::Util.download_and_cache(source: csv_url, dest: Tempfile.new('austin'))
end
|
Instance Method Details
#adapter_name ⇒ Object
113
114
115
|
# File 'lib/eaternet/agencies/austin.rb', line 113
def adapter_name
'Austin'
end
|
#business(row) ⇒ Object
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
# File 'lib/eaternet/agencies/austin.rb', line 71
def business(row)
Eaternet::Lives_1_0::Business.new do |b|
fail ArgumentError, 'No address found' if row['Address'].nil?
address_lines = row['Address'].split("\n")
if address_lines.size != 3
fail ArgumentError,
"Address doesn't have three lines: {row['Address']}"
end
address = address_lines.first
city = address_lines[1].split(',').first
address_lines[2] =~ /^\(([^,]+), (.+)\)$/
lat = Regexp.last_match(1)
lon = Regexp.last_match(2)
b.business_id = row['Facility ID']
b.name = row['Restaurant Name']
b.address = address
b.city = city
b.postal_code = row['Zip Code']
b.state = 'TX'
b.latitude = lat
b.longitude = lon
end
end
|
#businesses ⇒ Enumerable<Business>
28
29
30
31
32
|
# File 'lib/eaternet/agencies/austin.rb', line 28
def businesses
map_csv { |row| try_to_create(:business, from_csv_row: row) }
.uniq
.compact
end
|
#feed_info ⇒ Object
51
52
53
54
55
56
57
58
|
# File 'lib/eaternet/agencies/austin.rb', line 51
def feed_info
Eaternet::Lives_1_0::FeedInfo.new do |fi|
fi.feed_date = Date.today
fi.feed_version = '1.0'
fi.municipality_name = 'Austin'
fi.municipality_url = 'http://www.austintexas.gov/department/health'
end
end
|
#inspection(row) ⇒ Object
62
63
64
65
66
67
68
|
# File 'lib/eaternet/agencies/austin.rb', line 62
def inspection(row)
Eaternet::Lives_1_0::Inspection.new do |i|
i.business_id = row['Facility ID']
i.date = Date.strptime(row['Inspection Date'], '%m/%d/%Y')
i.score = row['Score'].to_i
end
end
|
#inspections ⇒ Object
35
36
37
38
|
# File 'lib/eaternet/agencies/austin.rb', line 35
def inspections
map_csv { |row| try_to_create(:inspection, from_csv_row: row) }
.compact
end
|
#legends ⇒ Object
46
47
48
|
# File 'lib/eaternet/agencies/austin.rb', line 46
def legends
fail Eaternet::UnsupportedError, 'Austin does not assign letter grades'
end
|
#violations ⇒ Object
41
42
43
|
# File 'lib/eaternet/agencies/austin.rb', line 41
def violations
fail Eaternet::UnsupportedError, "Austin doesn't publish violation data"
end
|