From 75cb7bb1792e88d9b92ad95649652e91b5d46bef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Belin?= Date: Sat, 20 Jun 2015 23:30:09 +0200 Subject: [PATCH] Fixed the usage of `Author.role` property --- CHANGELOG.md | 3 ++- lib/client.js | 2 +- lib/comment.js | 23 ++++++++++++----------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 987061da..868b2f75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,9 @@ This file contains highlights of what changes on each version of the [Akismet.js](https://www.npmjs.com/package/akismet-js) library. #### Version 0.6.1 +- Fixed the usage of `Author.role` property. - Fixed the usage of `Client.isTest` property. -- Fixed a unit test +- Fixed a unit test. #### Version 0.6.0 - Added `role` property to `Author` class. diff --git a/lib/client.js b/lib/client.js index 51b30345..e0a6fbdf 100644 --- a/lib/client.js +++ b/lib/client.js @@ -92,7 +92,7 @@ Blog.prototype.toJSON=function(space) { * @return {String} The string representation of this object. */ Blog.prototype.toString=function() { - return this.constructor.name+' '+JSON.stringify(this, null, 2); + return this.constructor.name+' '+this.toJSON(2); }; /** diff --git a/lib/comment.js b/lib/comment.js index 5eb77ada..cb5e5ef4 100644 --- a/lib/comment.js +++ b/lib/comment.js @@ -67,6 +67,15 @@ function Author(options) { * @type String */ this.name=null; + + /** + * The role of the author. + * If you set it to `"administrator"`, Akismet will always return `false`. + * @property role + * @type String + * @default null + */ + this.role=null; /** * The URL of the author's website. @@ -81,15 +90,6 @@ function Author(options) { * @type String */ this.userAgent=null; - - /** - * The role of the author. - * If you set it to `"administrator"`, Akismet will always return `false`. - * @property role - * @type String - * @default null - */ - this.role=null; // Initialize the instance. if(typeof options=='object' && options) { @@ -138,6 +138,7 @@ Author.prototype.toJSON=function(space) { if(typeof this.url=='string') map.comment_author_url=this.url; if(typeof this.userAgent=='string') map.user_agent=this.userAgent; if(typeof this.ipAddress=='string') map.user_ip=this.ipAddress; + if(typeof this.role=='string') map.user_role=this.role; return JSON.stringify(map, null, space); }; @@ -147,7 +148,7 @@ Author.prototype.toJSON=function(space) { * @return {String} The string representation of this object. */ Author.prototype.toString=function() { - return this.constructor.name+' '+JSON.stringify(this, null, 2); + return this.constructor.name+' '+this.toJSON(2); }; /** @@ -281,7 +282,7 @@ Comment.prototype.toJSON=function(space) { * @return {String} The string representation of this object. */ Comment.prototype.toString=function() { - return this.constructor.name+' '+JSON.stringify(this, null, 2); + return this.constructor.name+' '+this.toJSON(2); }; // Public interface.