Skip to content

Commit

Permalink
Merge branch 'release/v0.1.11'
Browse files Browse the repository at this point in the history
  • Loading branch information
nicosommi committed Nov 17, 2015
2 parents e87fda7 + b97ddb4 commit 4c783f4
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 12 deletions.
7 changes: 3 additions & 4 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"no-duplicate-case": 2,
"no-else-return": 0,
"no-empty": 2,
"no-empty-class": 2,
"no-empty-character-class": 2,
"no-empty-label": 2,
"no-eq-null": 0,
"no-eval": 2,
Expand All @@ -42,7 +42,7 @@
"no-extra-boolean-cast": 2,
"no-extra-parens": 0,
"no-extra-semi": 2,
"no-extra-strict": 2,
"strict": 2,
"no-fallthrough": 2,
"no-floating-decimal": 0,
"no-func-assign": 2,
Expand Down Expand Up @@ -108,7 +108,6 @@
"no-var": 0,
"no-warning-comments": [0, { "terms": ["todo", "fixme", "xxx"], "location": "start" }],
"no-with": 2,
"no-wrap-func": 2,

"block-scoped-var": 0,
"brace-style": [0, "1tbs"],
Expand Down Expand Up @@ -172,4 +171,4 @@
"wrap-regex": 0,
"yoda": [2, "never"]
}
}
}
6 changes: 5 additions & 1 deletion es5/lib/jsonApiModelFormatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ var _dovima = require("dovima");

var _dovima2 = _interopRequireDefault(_dovima);

var _jargon = require("jargon");

var _jargon2 = _interopRequireDefault(_jargon);

function convertModel(model) {
if (model && typeof model.toJSON === "function" || model instanceof _dovima2["default"]) {
var attributes = model.toJSON();
var id = attributes.id;
delete attributes.id; //so it's just on the root
return {
type: model.constructor.name,
type: (0, _jargon2["default"])(model.constructor.name).camel.toString(),
id: id,
attributes: attributes
};
Expand Down
2 changes: 1 addition & 1 deletion es5/spec/jsonApiModelFormatter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe("jsonApiModelFormatter", function () {
});

it("should add the model type to the root", function () {
(0, _libJsonApiModelFormatterJs2["default"])(user).type.should.equal("User");
(0, _libJsonApiModelFormatterJs2["default"])(user).type.should.equal("user");
});

it("should add the model id to the root", function () {
Expand Down
4 changes: 2 additions & 2 deletions es6/lib/jsonApiModelFormatter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Model from "dovima";
import {Collection} from "dovima";
import inflect from "jargon";

function convertModel(model) {
if((model && typeof (model.toJSON) === "function")
Expand All @@ -8,7 +8,7 @@ function convertModel(model) {
const id = attributes.id;
delete attributes.id; //so it's just on the root
return {
type: model.constructor.name,
type: inflect(model.constructor.name).camel.toString(),
id: id,
attributes: attributes
};
Expand Down
2 changes: 1 addition & 1 deletion es6/spec/jsonApiModelFormatter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe("jsonApiModelFormatter", () => {
});

it("should add the model type to the root", () => {
jsonApiModelFormatter(user).type.should.equal("User");
jsonApiModelFormatter(user).type.should.equal("user");
});

it("should add the model id to the root", () => {
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jsonapi-model-formatter",
"version": "0.1.10",
"version": "0.1.11",
"description": "JSON API formatter for dovima models.",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -33,8 +33,9 @@
"url": "https://github.com/FreeAllMedia/jsonapi-model-formatter/issues"
},
"homepage": "https://github.com/FreeAllMedia/jsonapi-model-formatter",
"dependencies": {
"dovima": "^0.3.0"
"dependencies": {
"dovima": "^0.3.0",
"jargon": "^0.1.22"
},
"devDependencies": {
"babel": "^5.5.6",
Expand Down

0 comments on commit 4c783f4

Please sign in to comment.