Skip to content
This repository
Browse code

[minor] Use inflect for resourceful.common

  • Loading branch information...
commit 7195bcfdcc28fdbed397f75d81321523016b44be 1 parent 1b418f7
Pavan Kumar Sunkara authored June 02, 2012
12  lib/resourceful/common.js
@@ -5,7 +5,9 @@
5 5
  * MIT LICENCE
6 6
  *
7 7
  */
8  
-var util = require('util');
  8
+var util = require('util'),
  9
+    inflect = require('i')();
  10
+
9 11
 var common = exports;
10 12
 
11 13
 common.mixin = function (target) {
@@ -71,10 +73,6 @@ common.typeOf = function (value) {
71 73
   return derived;
72 74
 };
73 75
 
74  
-common.capitalize = function (str) {
75  
-  return str && str[0].toUpperCase() + str.slice(1);
76  
-};
  76
+common.capitalize = inflect.camelize;
77 77
 
78  
-common.pluralize = function (s) {
79  
-  return /s$/.test(s) ? s : s + 's';
80  
-};
  78
+common.pluralize = inflect.pluralize;
1  package.json
@@ -21,6 +21,7 @@
21 21
   },
22 22
   "dependencies": {
23 23
     "cradle": "0.6.x",
  24
+    "i": "0.3.x",
24 25
     "revalidator": "0.1.x"
25 26
   },
26 27
   "devDependencies": {
2  test/relationship-test.js
@@ -105,7 +105,7 @@ function categoryParentTest(name) {
105 105
   return {
106 106
     topic: function(){
107 107
       // FIXME category pluralized should be categories (maybe use https://github.com/MSNexploder/inflect?)
108  
-      this.Category.categorys(parent_id, this.callback);
  108
+      this.Category.categories(parent_id, this.callback);
109 109
     },
110 110
     'should return the children': function(err, children){
111 111
       assert.isNull(err);

0 notes on commit 7195bcf

Please sign in to comment.
Something went wrong with that request. Please try again.