Skip to content

Commit

Permalink
Added .title
Browse files Browse the repository at this point in the history
  • Loading branch information
dcrockwell committed May 22, 2016
1 parent d63c8f9 commit 546f1e8
Show file tree
Hide file tree
Showing 5 changed files with 142 additions and 92 deletions.
7 changes: 7 additions & 0 deletions es5/lib/jargon.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ var Inflector = (function () {
return _this;
}
},
"title": {
enumerable: true,
get: function get() {
_.value = _inflection2["default"].titleize(_.value.replace(/[_-]/, " ").replace(/([a-z])([A-Z])/, "$1 $2"));
return _this;
}
},
"foreignKey": {
enumerable: true,
get: function get() {
Expand Down
14 changes: 14 additions & 0 deletions es5/spec/jargon.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,20 @@ describe("jargon(string)", function () {
});
});

describe(".title", function () {
it("should return an inflector object in order to allow chaining", function () {
((0, _libJargonJs2["default"])("appleTree").title instanceof _libJargonJs.Inflector).should.be["true"];
});

it("should provide a way to get a title for a string", function () {
(0, _libJargonJs2["default"])("apple-tree").title.toString().should.equal("Apple Tree");
});

it("should provide a way to get a title for a string", function () {
(0, _libJargonJs2["default"])("appleTree").title.toString().should.equal("Apple Tree");
});
});

describe(".foreignKey", function () {
it("should return an inflector object in order to allow chaining", function () {
((0, _libJargonJs2["default"])("appleTree").foreignKey instanceof _libJargonJs.Inflector).should.be["true"];
Expand Down
11 changes: 11 additions & 0 deletions es6/lib/jargon.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@ export class Inflector {
return this;
}
},
"title": {
enumerable: true,
get: () => {
_.value = inflection.titleize(
_.value
.replace(/[_-]/, " ")
.replace(/([a-z])([A-Z])/, "$1 $2")
);
return this;
}
},
"foreignKey": {
enumerable: true,
get: () => {
Expand Down
14 changes: 14 additions & 0 deletions es6/spec/jargon.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,20 @@ describe("jargon(string)", () => {
});
});

describe(".title", () => {
it("should return an inflector object in order to allow chaining", () => {
(jargon("appleTree").title instanceof Inflector).should.be.true;
});

it("should provide a way to get a title for a string", () => {
jargon("apple-tree").title.toString().should.equal("Apple Tree");
});

it("should provide a way to get a title for a string", () => {
jargon("appleTree").title.toString().should.equal("Apple Tree");
});
});

describe(".foreignKey", () => {
it("should return an inflector object in order to allow chaining", () => {
(jargon("appleTree").foreignKey instanceof Inflector).should.be.true;
Expand Down
188 changes: 96 additions & 92 deletions lcov.info
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
TN:
SF:/Users/dslieker/Documents/source-code/jargon/es5/lib/jargon.js
SF:/Users/dcrockwell/Dropbox/Code/jargon/es5/lib/jargon.js
FN:7,(anonymous_1)
FN:7,defineProperties
FN:7,(anonymous_3)
Expand All @@ -11,103 +11,107 @@ FN:38,get
FN:45,get
FN:49,(anonymous_10)
FN:62,get
FN:71,get
FN:78,get
FN:85,get
FN:95,value
FN:110,toString
FN:120,inflect
FNF:17
FNH:17
FNDA:6,(anonymous_1)
FNDA:6,defineProperties
FNDA:6,(anonymous_3)
FNDA:12,_interopRequireDefault
FNDA:120,_classCallCheck
FNDA:6,(anonymous_6)
FNDA:120,Inflector
FNDA:24,get
FNDA:36,get
FNDA:72,(anonymous_10)
FNDA:30,get
FNDA:18,get
FNDA:12,get
FNDA:12,get
FNDA:36,value
FNDA:78,toString
FNDA:120,inflect
DA:3,6
DA:7,12
DA:9,6
DA:11,12
DA:13,120
DA:15,6
DA:17,6
DA:19,6
DA:21,6
DA:23,6
DA:25,6
DA:27,6
FN:72,get
FN:79,get
FN:86,get
FN:93,get
FN:103,value
FN:118,toString
FN:128,inflect
FNF:18
FNH:18
FNDA:1,(anonymous_1)
FNDA:1,defineProperties
FNDA:1,(anonymous_3)
FNDA:2,_interopRequireDefault
FNDA:23,_classCallCheck
FNDA:1,(anonymous_6)
FNDA:23,Inflector
FNDA:4,get
FNDA:6,get
FNDA:12,(anonymous_10)
FNDA:5,get
FNDA:3,get
FNDA:3,get
FNDA:2,get
FNDA:2,get
FNDA:6,value
FNDA:15,toString
FNDA:23,inflect
DA:3,1
DA:7,2
DA:9,1
DA:11,2
DA:13,23
DA:15,1
DA:17,1
DA:19,1
DA:21,1
DA:23,1
DA:25,1
DA:27,1
DA:28,1
DA:29,120
DA:31,120
DA:33,120
DA:34,120
DA:35,120
DA:39,24
DA:40,24
DA:47,36
DA:49,36
DA:50,72
DA:51,36
DA:53,36
DA:56,36
DA:57,36
DA:63,30
DA:64,30
DA:65,28
DA:66,24
DA:72,17
DA:73,15
DA:79,12
DA:80,12
DA:86,11
DA:87,14
DA:93,21
DA:96,36
DA:97,32
DA:98,26
DA:99,17
DA:100,24
DA:101,34
DA:106,45
DA:111,42
DA:115,5
DA:118,23
DA:120,41
DA:121,60
LF:50
LH:50
BRDA:7,1,0,12
BRDA:7,1,1,12
BRDA:7,2,0,12
DA:29,23
DA:31,23
DA:33,23
DA:34,23
DA:35,23
DA:39,4
DA:40,4
DA:47,6
DA:49,6
DA:50,12
DA:51,6
DA:53,6
DA:56,6
DA:57,6
DA:63,5
DA:64,5
DA:65,5
DA:67,5
DA:73,3
DA:74,3
DA:80,3
DA:81,3
DA:87,2
DA:88,2
DA:94,2
DA:95,2
DA:101,1
DA:104,6
DA:105,6
DA:106,6
DA:107,2
DA:108,4
DA:109,3
DA:114,6
DA:119,15
DA:123,1
DA:126,1
DA:128,1
DA:129,23
LF:52
LH:52
BRDA:7,1,0,2
BRDA:7,1,1,2
BRDA:7,2,0,2
BRDA:7,2,1,0
BRDA:7,3,0,6
BRDA:7,3,0,1
BRDA:7,3,1,0
BRDA:7,4,0,0
BRDA:7,4,1,6
BRDA:7,4,1,1
BRDA:11,5,0,0
BRDA:11,5,1,12
BRDA:11,6,0,12
BRDA:11,6,1,12
BRDA:11,5,1,2
BRDA:11,6,0,2
BRDA:11,6,1,2
BRDA:13,7,0,0
BRDA:13,7,1,120
BRDA:50,8,0,36
BRDA:50,8,1,36
BRDA:98,9,0,12
BRDA:98,9,1,24
BRDA:100,10,0,18
BRDA:100,10,1,6
BRDA:13,7,1,23
BRDA:50,8,0,6
BRDA:50,8,1,6
BRDA:106,9,0,2
BRDA:106,9,1,4
BRDA:108,10,0,3
BRDA:108,10,1,1
BRF:20
BRH:15
end_of_record

0 comments on commit 546f1e8

Please sign in to comment.