eaternet 0.3.13 → 0.3.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/eaternet/agencies/nyc.rb +2 -1
- data/lib/eaternet/agencies/snhd.rb +2 -0
- data/lib/eaternet/agencies/snhd_config.rb +1 -0
- data/lib/eaternet/prototype.rb +3 -2
- data/lib/eaternet/util.rb +10 -4
- data/lib/eaternet/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 909fb5a4626a18c37b4d3694bd0fdf1a8f8b69a7
|
4
|
+
data.tar.gz: b6a05cf7dc6d76a5f10b4dc2e949c03d277da7da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e45b4ee75bf988fb28461b3cc19267ada7963e43967b80bb87537055b6f96a119829eafab6029bff68ede7830f433f129065a43a8a26827f51a09a4c9b81204c
|
7
|
+
data.tar.gz: 2cb9c2a9f6e221c52c8a8905e501aefd3b7f0a28cc4ff2e3d0a477726644eba9779c383aefefe94b988686265125b4ce70585b7f15136858835dbc9e397c4bec
|
@@ -16,13 +16,14 @@ module Eaternet
|
|
16
16
|
# retrieves the latest CSV export from
|
17
17
|
# [the official source](https://data.cityofnewyork.us/Health/DOHMH-New-York-City-Restaurant-Inspection-Results/xx67-kt59)
|
18
18
|
# and makes it easy to work with. The downloaded CSV is cached for twelve
|
19
|
-
# hours in a temporary file
|
19
|
+
# hours in a temporary file.
|
20
20
|
#
|
21
21
|
# This library conforms to the
|
22
22
|
# [LIVES 1.0 standard](http://www.yelp.com/healthscores) developed by
|
23
23
|
# Yelp and the cities of San Francisco and New York.
|
24
24
|
#
|
25
25
|
# @example Print the names of all the restaurants in New York City
|
26
|
+
# require 'eaternet'
|
26
27
|
# nyc = Eaternet::Nyc.new
|
27
28
|
# puts nyc.businesses.map(&:name)
|
28
29
|
#
|
data/lib/eaternet/prototype.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
module Eaternet
|
2
2
|
# A first pass at a health scores mini-framework which
|
3
|
-
# is
|
3
|
+
# is normalized and provides some more information than
|
4
4
|
# LIVES.
|
5
|
-
|
5
|
+
#
|
6
|
+
# @private
|
6
7
|
module Prototype
|
7
8
|
module AbstractAdapter
|
8
9
|
# @return [Enumerable<BusinessData>]
|
data/lib/eaternet/util.rb
CHANGED
@@ -17,13 +17,15 @@ module Eaternet
|
|
17
17
|
|
18
18
|
# Create a temporary directory which is automatically
|
19
19
|
# deleted when the program exits.
|
20
|
+
#
|
21
|
+
# @return [String] the directory path
|
20
22
|
def self.make_temp_dir
|
21
23
|
dir = Dir.mktmpdir
|
22
24
|
at_exit { FileUtils.remove_entry dir }
|
23
25
|
dir
|
24
26
|
end
|
25
27
|
|
26
|
-
# Download a file from the network,
|
28
|
+
# Download a file from the network, using a 12-hour cache.
|
27
29
|
#
|
28
30
|
# @param [String] source the URL to retrieve
|
29
31
|
# @param [String] dest pathname in which to save the file
|
@@ -60,24 +62,28 @@ module Eaternet
|
|
60
62
|
|
61
63
|
# Remove extraneous whitespace and ensure capitalization
|
62
64
|
# is correct for a proper name or title.
|
65
|
+
#
|
66
|
+
# @return [String] the cleaned up string
|
63
67
|
def self.cleanup_title(a_string)
|
64
68
|
return nil if a_string.nil?
|
65
69
|
cleanup(a_string).titleize
|
66
70
|
end
|
67
71
|
|
68
72
|
# Remove extraneous whitespace from the string
|
73
|
+
#
|
74
|
+
# @return [String] the cleaned up string
|
69
75
|
def self.cleanup(a_string)
|
70
76
|
return nil if a_string.nil?
|
71
77
|
a_string.strip.gsub(/ +/, ' ')
|
72
78
|
end
|
73
79
|
|
80
|
+
# @return [Float]
|
74
81
|
def self.file_age_in_days(path)
|
75
82
|
(Time.now - File.mtime(path)).to_i / 86_400.0
|
76
83
|
end
|
77
84
|
|
78
|
-
|
79
|
-
|
80
|
-
#
|
85
|
+
|
86
|
+
private
|
81
87
|
|
82
88
|
def self.expired?(cache_path)
|
83
89
|
!File.exist?(cache_path) || file_age_in_days(cache_path) > 0.5
|
data/lib/eaternet/version.rb
CHANGED