Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hubot-mood

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hubot-mood - npm Package Compare versions

Comparing version 0.2.3 to 0.3.0

22

lib/index.js

@@ -40,2 +40,9 @@ /*global module*/

}
if (filters.mood) {
if (Array.isArray(filters.mood)) {
included = included && filters.mood.indexOf(mood.mood) !== -1;
} else {
included = included && mood.mood === filters.mood;
}
}
return included;

@@ -135,2 +142,5 @@ });

}
if (data.info) {
this.info = data.info.replace(/\s/g, ' ') || undefined;
}
this.mood = data.mood;

@@ -140,3 +150,7 @@ };

Mood.prototype.serialize = function serialize() {
return format('%s:%s:%s', dateUtil.datetime(this.date), this.user, this.mood);
return format('%s:%s:%s%s',
this.date,
this.user,
this.mood,
this.info ? format(":%s", this.info) : "");
};

@@ -159,3 +173,3 @@

var formattedDate = formatDate(this.date);
return format("%s, %s %s in a %s mood %s",
return format("%s, %s %s in a %s mood %s%s",
formattedDate,

@@ -165,3 +179,4 @@ this.user,

this.mood,
this.symbol());
this.symbol(),
this.info ? format(" (%s)", this.info) : "");
};

@@ -175,2 +190,3 @@

, mood: parts[2]
, info: parts[3]
});

@@ -177,0 +193,0 @@ };

2

package.json
{
"name": "hubot-mood",
"version": "0.2.3",
"version": "0.3.0",
"author": "n1k0",

@@ -5,0 +5,0 @@ "keywords": [

@@ -11,3 +11,3 @@ // Description:

// Commands:
// hubot mood set "<sunny|cloudy|rainy|stormy>" - set your current mood for today
// hubot mood set <sunny|cloudy|rainy|stormy> (info) - set your current mood for today
// hubot mood of <(nickname)|me> - show your current mood if it's been set already

@@ -58,6 +58,7 @@ // hubot mood today - show team's mood for today

robot.respond(/mood set (\w+)$/i, function(msg) {
robot.respond(/mood set (\w+)\s?(.*)$/i, function(msg) {
var user = nickname(msg)
, mood = msg.match[1].toLowerCase();
engine.store({ user: user, mood: mood }, function(err, stored) {
, mood = msg.match[1].toLowerCase()
, info = msg.match[2];
engine.store({ user: user, mood: mood, info: info }, function(err, stored) {
if (err) return msg.send(err);

@@ -64,0 +65,0 @@ msg.send(format('Recorded entry: %s', stored));

@@ -30,11 +30,15 @@ /*global describe it*/

assert.doesNotThrow(createMood({ user: "x", mood: "sunny" }));
var mood = createMood({ user: "x", mood: "sunny" })();
assert.doesNotThrow(createMood({ user: "x", mood: "sunny", info: "plop" }));
var mood = createMood({ user: "x", mood: "sunny", info: "plop" })();
assert.strictEqual(mood.date, dateUtil.today());
assert.strictEqual(mood.user, "x");
assert.strictEqual(mood.mood, "sunny");
assert.strictEqual(mood.info, "plop");
});
it('should serialize data', function() {
var mood = createMood({ user: "x", mood: "sunny", date: "2013-01-01" })();
assert.strictEqual(mood.serialize(), "2013-01-01:x:sunny");
var mood1 = createMood({ user: "x", mood: "sunny", date: "2013-01-01" })();
assert.strictEqual(mood1.serialize(), "2013-01-01:x:sunny");
var mood2 = createMood({ user: "x", mood: "sunny", date: "2013-01-01", info: "plop" })();
assert.strictEqual(mood2.serialize(), "2013-01-01:x:sunny:plop");
});

@@ -63,2 +67,4 @@

"Today, x is in a cloudy mood ☁");
assert.strictEqual(createMood({ user: "x", mood: "sunny", date: "2013-01-01", info: "plop" })().toString(),
"On 2013-01-01, x was in a sunny mood ☀ (plop)");
});

@@ -93,2 +99,14 @@

it("should store a user's mood with info", function(done) {
engine.store({ user: "mark", mood: "sunny", info: "plop" }, function(err) {
assert.ifError(err);
engine.query({ user: "mark" }, function(err, moods) {
assert.ifError(err);
assert.strictEqual(moods[0].user, "mark");
assert.strictEqual(moods[0].info, "plop");
done();
});
});
});
it("shouldn't store a user's mood twice", function(done) {

@@ -101,2 +119,9 @@ engine.store({ user: "john", mood: "sunny" }, function(err) {

it("shouldn't store a user's mood with info twice", function(done) {
engine.store({ user: "mark", mood: "sunny", info: "plop" }, function(err) {
assert(err);
done();
});
});
it("shouldn't store an invalid mood", function(done) {

@@ -127,3 +152,3 @@ engine.store({ user: "bill", mood: "superman" }, function(err) {

{ user: "bill", mood: "sunny" },
{ user: "jane", mood: "rainy" }
{ user: "jane", mood: "rainy", info: "plop" }
];

@@ -147,3 +172,4 @@ async.map(moods, engine.store.bind(engine), function(err, results) {

return mood.user === "jane" && mood.mood === "rainy" &&
mood.date === dateUtil.today();
mood.date === dateUtil.today() &&
mood.info === "plop";
}));

@@ -188,3 +214,3 @@ done();

var moods = [
{ user: "john", mood: "sunny", date: dateUtil.today()},
{ user: "john", mood: "sunny", date: dateUtil.today(), info: "plop"},
{ user: "john", mood: "cloudy", date: dateUtil.daysBefore(1)},

@@ -191,0 +217,0 @@ { user: "john", mood: "rainy", date: dateUtil.daysBefore(2)},

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc