Skip to content

Commit

Permalink
Changed Air Quality string regex to account for single value (e.g. "4…
Browse files Browse the repository at this point in the history
… to 7" as well as just "7").
  • Loading branch information
ronalddddd committed Feb 16, 2015
1 parent f6ab43b commit d71d28f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@
uvIntensityRegex = /Intensity of UV radiation : ([^\r|\n|$]*)/,
warningRegex = /(.*) \((\d\d):(\d\d) HKT (\d\d)\/(\d\d)\/(\d\d\d\d)\)/,
aqDateRegex = /HKSAR Air Quality Health Index at : (.* \+0800)/, // HKSAR Air Quality Health Index at : Sun, 15 Feb 2015 16:30:00 +0800 Current Condition
aqGeneralRegex = /General Stations: (\d*) to (\d*)/, // General Stations: 4 to 7 (Health Risk: Moderate to High)</p><p>Roadside Stations: 6 to 10 (Health Risk: Moderate to Very High)
aqRoadRegex = /Roadside Stations: (\d*) to (\d*)/; // General Stations: 4 to 7 (Health Risk: Moderate to High)</p><p>Roadside Stations: 6 to 10 (Health Risk: Moderate to Very High)
aqGeneralRegex = /General Stations: (\d*)( to (\d*))?/, // General Stations: 4 to 7 (Health Risk: Moderate to High)</p><p>Roadside Stations: 6 to 10 (Health Risk: Moderate to Very High)
aqRoadRegex = /Roadside Stations: (\d*)( to (\d*))?/; // General Stations: 4 to 7 (Health Risk: Moderate to High)</p><p>Roadside Stations: 6 to 10 (Health Risk: Moderate to Very High)

return bluebird.all([
// Current Weather from HKO
Expand Down Expand Up @@ -133,9 +133,9 @@

weather.air_quality.date = new Date(aqDateMatch[1]);
weather.air_quality.general.from = parseInt(aqGeneralMatch[1]) || undefined;
weather.air_quality.general.to = parseInt(aqGeneralMatch[2]) || undefined;
weather.air_quality.general.to = parseInt(aqGeneralMatch[3]) || undefined;
weather.air_quality.roadside.from = parseInt(aqRoadSideMatch[1]) || undefined;
weather.air_quality.roadside.to = parseInt(aqRoadSideMatch[2]) || undefined;
weather.air_quality.roadside.to = parseInt(aqRoadSideMatch[3]) || undefined;
}).catch(function(err){
console.error("Error parsing Air Quality data!",err, err.stack.toString());
})
Expand Down
2 changes: 2 additions & 0 deletions test/indexSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
expect(weather.degrees_c).to.exist;
expect(weather.degrees_c).to.be.a.number;
done();

console.log(weather);
});

// TODO: Check all other fields.
Expand Down

0 comments on commit d71d28f

Please sign in to comment.