From f331d8dc9568d3db8dcaa9958250f6e6664548d3 Mon Sep 17 00:00:00 2001 From: Ruben Beltran del Rio Date: Sun, 4 Apr 2021 01:02:37 +0200 Subject: Move rules to lib --- lib/rule_generator.js | 2 +- lib/rules/business.js | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++ lib/rules/curfew.js | 69 +++++++++++++++++++++++++++++++++++++++++++++++ lib/rules/group.js | 51 +++++++++++++++++++++++++++++++++++ rules/business.js | 74 --------------------------------------------------- rules/curfew.js | 69 ----------------------------------------------- rules/group.js | 51 ----------------------------------- 7 files changed, 195 insertions(+), 195 deletions(-) create mode 100644 lib/rules/business.js create mode 100644 lib/rules/curfew.js create mode 100644 lib/rules/group.js delete mode 100644 rules/business.js delete mode 100644 rules/curfew.js delete mode 100644 rules/group.js diff --git a/lib/rule_generator.js b/lib/rule_generator.js index 407f763..742c915 100644 --- a/lib/rule_generator.js +++ b/lib/rule_generator.js @@ -18,7 +18,7 @@ const internals = { rules: null, currentIndex: 0, - kRulesDirectory: resolve(process.cwd(), 'rules'), + kRulesDirectory: resolve(__dirname, './rules'), async readRules() { diff --git a/lib/rules/business.js b/lib/rules/business.js new file mode 100644 index 0000000..bc12866 --- /dev/null +++ b/lib/rules/business.js @@ -0,0 +1,74 @@ +const internals ={ + + businesses: [ + 'butcher shops', + 'plant shops', + 'balloon factories', + 'pet hotels', + 'sex shops', + 'clothes incineration facilities', + 'city dumps', + 'glass factories', + 'roads', + 'windfarm analysis consultancies', + 'peanut depots', + 'glue factories', + 'bürgeramts', + 'chiropractors', + 'gong bath facilities', + 'wrestling rings', + 'cat cafés', + 'paint your own pottery centers', + 'dungeons', + 'television sets', + 'nasa offices', + 'toilet factories', + 'condom inspection facilities', + 'high school newspapers', + 'dog spas', + 'mink breeding centers', + 'ngos', + 'yoga cults', + 'mi6 safehouses', + 'döner shops', + 'hospitals' + ], + + restrictions: [ + 'are required to work from home', + 'require mandatory testing', + 'must remain closed', + 'must remain open', + 'must offer 50% covid discounts', + 'must become vaccination centers', + 'must pay staff 3x on thursdays', + 'can only meet with one other household', + 'must share facilities', + 'are exempt from mask rules', + ], + + join(array) { + + const firstPart = array.slice(0, -1).join(', ') + const lastPart = array.slice(-1) + + const conjunction = array.length <= 1 ? '' : ', and ' + + return [firstPart, lastPart].join(conjunction) + } +}; + +module.exports = () => { + + const businesses = internals.businesses + .filter(() => true) + .sort(() => Math.random() - 0.5) + .slice(0, Math.floor(Math.random() * 3) + 1) + const restriction = internals.restrictions[Math.floor(Math.random() * internals.restrictions.length)]; + const text = `${internals.join(businesses)} ${restriction}` + + return { + emoji: '🏢', + text: text.charAt(0).toUpperCase() + text.slice(1) + }; +} diff --git a/lib/rules/curfew.js b/lib/rules/curfew.js new file mode 100644 index 0000000..9fc697f --- /dev/null +++ b/lib/rules/curfew.js @@ -0,0 +1,69 @@ +const internals ={ + + activities: [ + 'sex', + 'skinny dipping', + 'playing chess', + 'debating', + 'dancing', + 'breeding horses', + 'laughing', + 'sneezing', + 'cat wrestling', + 'ordering food', + 'remote work', + 'internet usage', + 'sleeping', + 'eating', + 'vacuuming', + 'using a blender', + 'having a party', + 'theft', + 'engaging in economic activity', + 'using ketchup', + 'tailgating', + 'embezzelment', + 'taking the U-Bahn', + 'cutting your hair', + 'using recreational drugs', + 'tipping', + 'interpretive dancing', + 'origami', + 'whittling', + 'going for a walk', + 'working' + ], + + restrictions: [ + 'is not allowed', + 'is mandatory', + 'is optional', + 'requires a mask', + 'is only allowed indoors', + 'is only allowed outdoors', + 'is only allowed in groups larger than seven', + 'requires a license', + 'is allowed under police supervision', + 'is allowed following social distancing rules', + 'is only allowed in Neukölln', + 'is only allowed in Kreuzberg', + 'is only allowed in Charlottenburg', + 'is only allowed in Wedding', + 'is only allowed in Mitte', + 'is only allowed in Prenzlauer Berg', + 'is only allowed in Friedrichshain', + ] +}; + +module.exports = () => { + + const startTime = Math.floor(Math.random() * 23) + 1; + const endTtime = Math.floor(Math.random() * 23) + 1; + const activity = internals.activities[Math.floor(Math.random() * internals.activities.length)]; + const restriction = internals.restrictions[Math.floor(Math.random() * internals.restrictions.length)]; + + return { + emoji: '🕚', + text: `From ${startTime}:00 to ${endTtime}:00 ${activity} ${restriction}` + }; +} diff --git a/lib/rules/group.js b/lib/rules/group.js new file mode 100644 index 0000000..909c378 --- /dev/null +++ b/lib/rules/group.js @@ -0,0 +1,51 @@ +const internals ={ + + groups: [ + 'teenagers', + 'influencers', + 'vegans', + 'tik-tok users', + 'lactose intolerants', + 'households', + 'ice cream vendors', + 'babies', + 'police officers', + 'drug dealers', + 'tech workers', + 'cryptocurrency miners', + 'mexicans', + 'smokers', + 'drug users', + 'octogenarians', + 'public officials', + 'atheists', + 'god fearing parishioners', + 'b-list actors', + 'jugglers', + 'seagulls', + 'lighthouse operators', + 'tram drivers', + 'psychics', + 'magicians', + 'classically trained musicians', + 'food delivery drivers', + 'librarians', + 'doctors', + 'vaccinated cats', + 'balloon artists' + ], +}; + +module.exports = () => { + + const countA = Math.floor(Math.random() * 8) + 2; + const magnitude = Math.random() > 0.5 ? 99 : 5; + const countB = Math.floor(Math.random() * magnitude) + 1; + const groupA = internals.groups[Math.floor(Math.random() * internals.groups.length)]; + const groupB = internals.groups[Math.floor(Math.random() * internals.groups.length)]; + + return { + emoji: '👨', + text: `No more than ${countA} ${groupA} + ${countB} ${groupB} are allowed to meet` + }; +} diff --git a/rules/business.js b/rules/business.js deleted file mode 100644 index bc12866..0000000 --- a/rules/business.js +++ /dev/null @@ -1,74 +0,0 @@ -const internals ={ - - businesses: [ - 'butcher shops', - 'plant shops', - 'balloon factories', - 'pet hotels', - 'sex shops', - 'clothes incineration facilities', - 'city dumps', - 'glass factories', - 'roads', - 'windfarm analysis consultancies', - 'peanut depots', - 'glue factories', - 'bürgeramts', - 'chiropractors', - 'gong bath facilities', - 'wrestling rings', - 'cat cafés', - 'paint your own pottery centers', - 'dungeons', - 'television sets', - 'nasa offices', - 'toilet factories', - 'condom inspection facilities', - 'high school newspapers', - 'dog spas', - 'mink breeding centers', - 'ngos', - 'yoga cults', - 'mi6 safehouses', - 'döner shops', - 'hospitals' - ], - - restrictions: [ - 'are required to work from home', - 'require mandatory testing', - 'must remain closed', - 'must remain open', - 'must offer 50% covid discounts', - 'must become vaccination centers', - 'must pay staff 3x on thursdays', - 'can only meet with one other household', - 'must share facilities', - 'are exempt from mask rules', - ], - - join(array) { - - const firstPart = array.slice(0, -1).join(', ') - const lastPart = array.slice(-1) - - const conjunction = array.length <= 1 ? '' : ', and ' - - return [firstPart, lastPart].join(conjunction) - } -}; - -module.exports = () => { - - const businesses = internals.businesses - .filter(() => true) - .sort(() => Math.random() - 0.5) - .slice(0, Math.floor(Math.random() * 3) + 1) - const restriction = internals.restrictions[Math.floor(Math.random() * internals.restrictions.length)]; - const text = `${internals.join(businesses)} ${restriction}` - - return { - emoji: '🏢', - text: text.charAt(0).toUpperCase() + text.slice(1) - }; -} diff --git a/rules/curfew.js b/rules/curfew.js deleted file mode 100644 index 9fc697f..0000000 --- a/rules/curfew.js +++ /dev/null @@ -1,69 +0,0 @@ -const internals ={ - - activities: [ - 'sex', - 'skinny dipping', - 'playing chess', - 'debating', - 'dancing', - 'breeding horses', - 'laughing', - 'sneezing', - 'cat wrestling', - 'ordering food', - 'remote work', - 'internet usage', - 'sleeping', - 'eating', - 'vacuuming', - 'using a blender', - 'having a party', - 'theft', - 'engaging in economic activity', - 'using ketchup', - 'tailgating', - 'embezzelment', - 'taking the U-Bahn', - 'cutting your hair', - 'using recreational drugs', - 'tipping', - 'interpretive dancing', - 'origami', - 'whittling', - 'going for a walk', - 'working' - ], - - restrictions: [ - 'is not allowed', - 'is mandatory', - 'is optional', - 'requires a mask', - 'is only allowed indoors', - 'is only allowed outdoors', - 'is only allowed in groups larger than seven', - 'requires a license', - 'is allowed under police supervision', - 'is allowed following social distancing rules', - 'is only allowed in Neukölln', - 'is only allowed in Kreuzberg', - 'is only allowed in Charlottenburg', - 'is only allowed in Wedding', - 'is only allowed in Mitte', - 'is only allowed in Prenzlauer Berg', - 'is only allowed in Friedrichshain', - ] -}; - -module.exports = () => { - - const startTime = Math.floor(Math.random() * 23) + 1; - const endTtime = Math.floor(Math.random() * 23) + 1; - const activity = internals.activities[Math.floor(Math.random() * internals.activities.length)]; - const restriction = internals.restrictions[Math.floor(Math.random() * internals.restrictions.length)]; - - return { - emoji: '🕚', - text: `From ${startTime}:00 to ${endTtime}:00 ${activity} ${restriction}` - }; -} diff --git a/rules/group.js b/rules/group.js deleted file mode 100644 index 909c378..0000000 --- a/rules/group.js +++ /dev/null @@ -1,51 +0,0 @@ -const internals ={ - - groups: [ - 'teenagers', - 'influencers', - 'vegans', - 'tik-tok users', - 'lactose intolerants', - 'households', - 'ice cream vendors', - 'babies', - 'police officers', - 'drug dealers', - 'tech workers', - 'cryptocurrency miners', - 'mexicans', - 'smokers', - 'drug users', - 'octogenarians', - 'public officials', - 'atheists', - 'god fearing parishioners', - 'b-list actors', - 'jugglers', - 'seagulls', - 'lighthouse operators', - 'tram drivers', - 'psychics', - 'magicians', - 'classically trained musicians', - 'food delivery drivers', - 'librarians', - 'doctors', - 'vaccinated cats', - 'balloon artists' - ], -}; - -module.exports = () => { - - const countA = Math.floor(Math.random() * 8) + 2; - const magnitude = Math.random() > 0.5 ? 99 : 5; - const countB = Math.floor(Math.random() * magnitude) + 1; - const groupA = internals.groups[Math.floor(Math.random() * internals.groups.length)]; - const groupB = internals.groups[Math.floor(Math.random() * internals.groups.length)]; - - return { - emoji: '👨', - text: `No more than ${countA} ${groupA} + ${countB} ${groupB} are allowed to meet` - }; -} -- cgit