-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"projects": { | ||
"default": "trojan-dining" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
firebase-debug.log* | ||
|
||
# Firebase cache | ||
.firebase/ | ||
|
||
# Firebase config | ||
|
||
# Uncomment this if you'd like others to create their own Firebase project. | ||
# For a team working on the same Firebase project(s), it is recommended to leave | ||
# it commented so all members can deploy to the same project(s) in .firebaserc. | ||
# .firebaserc | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"functions": { | ||
"predeploy": [ | ||
"npm --prefix \"$RESOURCE_DIR\" run lint" | ||
] | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
{ | ||
"parserOptions": { | ||
// Required for certain syntax usages | ||
"ecmaVersion": 2017 | ||
}, | ||
"plugins": [ | ||
"promise" | ||
], | ||
"extends": "eslint:recommended", | ||
"rules": { | ||
// Removed rule "disallow the use of console" from recommended eslint rules | ||
"no-console": "off", | ||
|
||
// Removed rule "disallow multiple spaces in regular expressions" from recommended eslint rules | ||
"no-regex-spaces": "off", | ||
|
||
// Removed rule "disallow the use of debugger" from recommended eslint rules | ||
"no-debugger": "off", | ||
|
||
// Removed rule "disallow unused variables" from recommended eslint rules | ||
"no-unused-vars": "off", | ||
|
||
// Removed rule "disallow mixed spaces and tabs for indentation" from recommended eslint rules | ||
"no-mixed-spaces-and-tabs": "off", | ||
|
||
// Removed rule "disallow the use of undeclared variables unless mentioned in /*global */ comments" from recommended eslint rules | ||
"no-undef": "off", | ||
|
||
// Warn against template literal placeholder syntax in regular strings | ||
"no-template-curly-in-string": 1, | ||
|
||
// Warn if return statements do not either always or never specify values | ||
"consistent-return": 1, | ||
|
||
// Warn if no return statements in callbacks of array methods | ||
"array-callback-return": 1, | ||
|
||
// Require the use of === and !== | ||
"eqeqeq": 2, | ||
|
||
// Disallow the use of alert, confirm, and prompt | ||
"no-alert": 2, | ||
|
||
// Disallow the use of arguments.caller or arguments.callee | ||
"no-caller": 2, | ||
|
||
// Disallow null comparisons without type-checking operators | ||
"no-eq-null": 2, | ||
|
||
// Disallow the use of eval() | ||
"no-eval": 2, | ||
|
||
// Warn against extending native types | ||
"no-extend-native": 1, | ||
|
||
// Warn against unnecessary calls to .bind() | ||
"no-extra-bind": 1, | ||
|
||
// Warn against unnecessary labels | ||
"no-extra-label": 1, | ||
|
||
// Disallow leading or trailing decimal points in numeric literals | ||
"no-floating-decimal": 2, | ||
|
||
// Warn against shorthand type conversions | ||
"no-implicit-coercion": 1, | ||
|
||
// Warn against function declarations and expressions inside loop statements | ||
"no-loop-func": 1, | ||
|
||
// Disallow new operators with the Function object | ||
"no-new-func": 2, | ||
|
||
// Warn against new operators with the String, Number, and Boolean objects | ||
"no-new-wrappers": 1, | ||
|
||
// Disallow throwing literals as exceptions | ||
"no-throw-literal": 2, | ||
|
||
// Require using Error objects as Promise rejection reasons | ||
"prefer-promise-reject-errors": 2, | ||
|
||
// Enforce “for” loop update clause moving the counter in the right direction | ||
"for-direction": 2, | ||
|
||
// Enforce return statements in getters | ||
"getter-return": 2, | ||
|
||
// Disallow await inside of loops | ||
"no-await-in-loop": 2, | ||
|
||
// Disallow comparing against -0 | ||
"no-compare-neg-zero": 2, | ||
|
||
// Warn against catch clause parameters from shadowing variables in the outer scope | ||
"no-catch-shadow": 1, | ||
|
||
// Disallow identifiers from shadowing restricted names | ||
"no-shadow-restricted-names": 2, | ||
|
||
// Enforce return statements in callbacks of array methods | ||
"callback-return": 2, | ||
|
||
// Require error handling in callbacks | ||
"handle-callback-err": 2, | ||
|
||
// Warn against string concatenation with __dirname and __filename | ||
"no-path-concat": 1, | ||
|
||
// Prefer using arrow functions for callbacks | ||
"prefer-arrow-callback": 1, | ||
|
||
// Return inside each then() to create readable and reusable Promise chains. | ||
// Forces developers to return console logs and http calls in promises. | ||
"promise/always-return": 2, | ||
|
||
//Enforces the use of catch() on un-returned promises | ||
"promise/catch-or-return": 2, | ||
|
||
// Warn against nested then() or catch() statements | ||
"promise/no-nesting": 1 | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
const he = require('he'); | ||
|
||
class MenuBuilder { | ||
|
||
constructor() { | ||
this.menu = []; | ||
|
||
this.currentMeal = null; | ||
this.currentHall = null; | ||
this.currentSect = null; | ||
this.currentFood = null; | ||
|
||
this.readingMeal = false; | ||
this.readingHall = false; | ||
this.readingSect = false; | ||
this.readingFood = false; | ||
} | ||
|
||
processNewText(text) { | ||
// NOTE: this method relies on currentMeal, currentHall, currentSect, and currentFood being set to nil upon successful population | ||
|
||
// when readingMeal becomes true, use first encountered text as meal name | ||
if (this.readingMeal) { | ||
if (this.mealIsNil()) this.initializeMeal(text); | ||
// when readingHall becomes true, use first encountered text as hall name | ||
else if (this.readingHall) { | ||
if (this.hallIsNil()) this.initializeHall(text); | ||
// when readingSect becomes true, use first encountered text as sect name | ||
else if (this.readingSect) { | ||
if (this.sectIsNil()) this.initializeSect(text); | ||
// when readingFood becomes true, use first encountered text as food name | ||
else if (this.readingFood) { | ||
if (this.foodIsNil()) {this.initializeFood(text);} | ||
// use other text to populate allergens | ||
else {this.currentFood.allergens.push(text);} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
processNewTag(tag) { | ||
switch (tag) { | ||
case MenuBuilder.HTMLMeal.startTag: | ||
this.saveMeal(); | ||
this.resetMeal(); this.resetHall(); this.resetSect(); this.resetFood(); | ||
break; | ||
|
||
case MenuBuilder.HTMLHall.startTag: if (this.readingMeal) this.readingHall = true; break; | ||
case MenuBuilder.HTMLSect.startTag: if (this.readingHall) this.readingSect = true; break; | ||
case MenuBuilder.HTMLFood.startTag: if (this.readingSect) this.readingFood = true; break; | ||
case MenuBuilder.HTMLFood.endTag: if (this.readingFood) {this.saveFood(); this.resetFood();} break; | ||
case MenuBuilder.HTMLSect.endTag: if (this.readingSect) {this.saveSect(); this.resetSect();} break; | ||
case MenuBuilder.HTMLHall.endTag: if (this.readingHall) {this.saveHall(); this.resetHall();} break; | ||
} | ||
} | ||
|
||
mealIsNil() {return this.currentMeal === null;} | ||
hallIsNil() {return this.currentHall === null;} | ||
sectIsNil() {return this.currentSect === null;} | ||
foodIsNil() {return this.currentFood === null;} | ||
|
||
initializeMeal(name) {this.currentMeal = new MenuBuilder.HTMLMeal(name, []);} | ||
initializeHall(name) {this.currentHall = new MenuBuilder.HTMLHall(name, []);} | ||
initializeSect(name) {this.currentSect = new MenuBuilder.HTMLSect(name, []);} | ||
initializeFood(name) {this.currentFood = new MenuBuilder.HTMLFood(name, []);} | ||
|
||
saveMeal() { | ||
if (!this.mealIsNil() && this.currentMeal.halls.length === 3) { | ||
this.menu.push(this.currentMeal); | ||
} | ||
} | ||
saveHall() {if (!this.hallIsNil()) this.currentMeal.halls.push(this.currentHall);} | ||
saveSect() {if (!this.sectIsNil()) this.currentHall.sects.push(this.currentSect);} | ||
saveFood() {if (!this.foodIsNil()) this.currentSect.foods.push(this.currentFood);} | ||
|
||
resetMeal() {this.currentMeal = null; this.readingMeal = true;} | ||
resetHall() {this.currentHall = null; this.readingHall = false;} | ||
resetSect() {this.currentSect = null; this.readingSect = false;} | ||
resetFood() {this.currentFood = null; this.readingFood = false;} | ||
} | ||
|
||
MenuBuilder.HTMLMeal = class { | ||
constructor(name, halls) { | ||
this.name = name; | ||
this.halls = halls; | ||
} | ||
|
||
shortName() { | ||
// e.g. "Breakfast" | ||
return this.name.split(" ")[0]; | ||
} | ||
|
||
dateText() { | ||
// MMMM d, YYYY | ||
return this.name.split("- ")[1]; | ||
} | ||
}; | ||
MenuBuilder.HTMLMeal.startTag = "<span class=\"fw-accordion-title-inner\">"; | ||
|
||
MenuBuilder.HTMLHall = class { | ||
constructor(name, sects) { | ||
this.name = name; | ||
this.sects = sects; | ||
} | ||
|
||
decodedName() { | ||
return he.decode(this.name) | ||
} | ||
}; | ||
MenuBuilder.HTMLHall.startTag = "<h3 class=\"menu-venue-title\">"; | ||
MenuBuilder.HTMLHall.endTag = "</div>"; | ||
|
||
MenuBuilder.HTMLSect = class { | ||
constructor(name, foods) { | ||
this.name = name; | ||
this.foods = foods; | ||
} | ||
|
||
shortName() { | ||
return this.name.replace('/', ' ').replace(/[^a-z0-9 ]/gi,'') | ||
} | ||
} | ||
MenuBuilder.HTMLSect.startTag = "<h4>"; | ||
MenuBuilder.HTMLSect.endTag = "</ul>"; | ||
|
||
MenuBuilder.HTMLFood = class { | ||
constructor(name, allergens) { | ||
this.name = name; | ||
this.allergens = allergens; | ||
} | ||
}; | ||
MenuBuilder.HTMLFood.startTag = "<li>"; | ||
MenuBuilder.HTMLFood.endTag = "</li>"; | ||
|
||
module.exports = MenuBuilder; |