rice-dining 0.2.1 → 0.2.2
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/rice/dining.rb +8 -4
- data/lib/rice/dining/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: 5ba72d909940c766ae7986376076eff2a7e86e4a
|
4
|
+
data.tar.gz: 4d8a502c61a2d191bdbe46edbdb0ef5c315e2106
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a36d5b22138fe1ee7bc87b0c08ea6d893cf72e9d4e92a968ed1f295e756815d54926a8118f96a29eeb5fd349dee236a5844ac14316b946723898848a68a92a5d
|
7
|
+
data.tar.gz: 97e05d13092ea66bb6f0a942d2d71550cdea48ea37b89bf0273e75c38ca0f5e0e2aebab94a9ae8ecc9ee6d7d36039998c916a4092b87a754bb8f747cad9ec68a
|
data/lib/rice/dining.rb
CHANGED
@@ -115,13 +115,13 @@ module Rice
|
|
115
115
|
|
116
116
|
# stash allergen references in the "key" section
|
117
117
|
doc.css('div#key div.diet'.freeze).each do |allergen_node|
|
118
|
-
|
118
|
+
allergen_reference allergen_node['class'.freeze]
|
119
119
|
end
|
120
120
|
|
121
121
|
# build each location
|
122
122
|
locations = []
|
123
123
|
location_nodes = doc.css('div.item'.freeze)
|
124
|
-
raise
|
124
|
+
raise CreateError, "couldn't find locations".freeze if location_nodes.empty?
|
125
125
|
location_nodes.each do |location_node|
|
126
126
|
# get the servery name
|
127
127
|
name_nodes = location_node.css('div.servery-title h1'.freeze)
|
@@ -141,7 +141,7 @@ module Rice
|
|
141
141
|
item_allergens, item_name = [], item_node.text
|
142
142
|
item_name.strip!
|
143
143
|
item_node.parent.css('div.allergen div.diet'.freeze).each do |allergen_node|
|
144
|
-
allergen =
|
144
|
+
allergen = allergen_reference allergen_node['class'.freeze]
|
145
145
|
item_allergens << allergen if allergen
|
146
146
|
end
|
147
147
|
|
@@ -165,10 +165,12 @@ module Rice
|
|
165
165
|
Rice::Dining::Manifest.new locations, @allergen_map.values
|
166
166
|
else
|
167
167
|
# Problem with the response
|
168
|
-
raise
|
168
|
+
raise CreateError, "got HTTP #{res.code} from #{Rice::Dining::BASE}"
|
169
169
|
end
|
170
170
|
end
|
171
171
|
|
172
|
+
private
|
173
|
+
|
172
174
|
def allergen_reference allergen_class
|
173
175
|
# build the allergen key
|
174
176
|
key = allergen_cleanup allergen_class
|
@@ -198,6 +200,8 @@ module Rice
|
|
198
200
|
return nil if ret.nil?
|
199
201
|
ret[:type].downcase.to_sym
|
200
202
|
end
|
203
|
+
|
204
|
+
CreateError ||= Class.new StandardError
|
201
205
|
end
|
202
206
|
|
203
207
|
def self.manifest
|
data/lib/rice/dining/version.rb
CHANGED