@@ -10,7 +10,7 @@ var util = require('./util');
1010var inflect = module . exports ;
1111
1212// Import [inflections](inflections.html) instance
13- inflect . inflections = require ( './inflections' )
13+ inflect . inflections = require ( './inflections' ) ;
1414
1515// Gives easy access to add inflections to this class
1616inflect . inflect = function ( fn ) {
@@ -31,13 +31,13 @@ inflect.inflect = function (fn) {
3131// though there are cases where that does not hold:
3232//
3333// "SSLError".underscore.camelize // => "SslError"
34- inflect . camelize = function ( lower_case_and_underscored_word , first_letter_in_uppercase ) {
34+ inflect . camelize = function ( lower_case_and_underscored_word , first_letter_in_uppercase ) {
3535 var result ;
3636 if ( first_letter_in_uppercase == null ) first_letter_in_uppercase = true ;
37- result = util . string . gsub ( lower_case_and_underscored_word , / \/ ( .? ) / , function ( $ ) {
38- return "." + ( util . string . upcase ( $ [ 1 ] ) ) ;
37+ result = util . string . gsub ( lower_case_and_underscored_word , / \/ ( .? ) / , function ( $ ) {
38+ return '.' + util . string . upcase ( $ [ 1 ] ) ;
3939 } ) ;
40- result = util . string . gsub ( result , / (?: _ ) ( .) / , function ( $ ) {
40+ result = util . string . gsub ( result , / (?: _ ) ( .) / , function ( $ ) {
4141 return util . string . upcase ( $ [ 1 ] ) ;
4242 } ) ;
4343 if ( first_letter_in_uppercase ) {
@@ -61,8 +61,8 @@ inflect.camelize = function(lower_case_and_underscored_word, first_letter_in_upp
6161inflect . underscore = function ( camel_cased_word ) {
6262 var self ;
6363 self = util . string . gsub ( camel_cased_word , / \. / , '/' ) ;
64- self = util . string . gsub ( self , / ( [ A - Z ] + ) ( [ A - Z ] [ a - z ] ) / , " $1_$2" ) ;
65- self = util . string . gsub ( self , / ( [ a - z \d ] ) ( [ A - Z ] ) / , " $1_$2" ) ;
64+ self = util . string . gsub ( self , / ( [ A - Z ] + ) ( [ A - Z ] [ a - z ] ) / , ' $1_$2' ) ;
65+ self = util . string . gsub ( self , / ( [ a - z \d ] ) ( [ A - Z ] ) / , ' $1_$2' ) ;
6666 self = util . string . gsub ( self , / - / , '_' ) ;
6767 return self . toLowerCase ( ) ;
6868} ;
@@ -93,7 +93,9 @@ inflect.foreign_key = function (class_name, separate_class_name_and_id_with_unde
9393 if ( separate_class_name_and_id_with_underscore == null ) {
9494 separate_class_name_and_id_with_underscore = true ;
9595 }
96- return inflect . underscore ( inflect . demodulize ( class_name ) ) + ( separate_class_name_and_id_with_underscore ? "_id" : "id" ) ;
96+ return (
97+ inflect . underscore ( inflect . demodulize ( class_name ) ) + ( separate_class_name_and_id_with_underscore ? '_id' : 'id' )
98+ ) ;
9799} ;
98100
99101// Turns a number into an ordinal string used to denote the position in an
@@ -109,17 +111,17 @@ inflect.ordinalize = function (number) {
109111 var _ref ;
110112 number = parseInt ( number ) ;
111113 if ( ( _ref = Math . abs ( number ) % 100 ) === 11 || _ref === 12 || _ref === 13 ) {
112- return "" + number + "th" ;
114+ return '' + number + 'th' ;
113115 } else {
114116 switch ( Math . abs ( number ) % 10 ) {
115117 case 1 :
116- return "" + number + "st" ;
118+ return '' + number + 'st' ;
117119 case 2 :
118- return "" + number + "nd" ;
120+ return '' + number + 'nd' ;
119121 case 3 :
120- return "" + number + "rd" ;
122+ return '' + number + 'rd' ;
121123 default :
122- return "" + number + "th" ;
124+ return '' + number + 'th' ;
123125 }
124126 }
125127} ;
@@ -129,8 +131,8 @@ inflect.ordinalize = function (number) {
129131// "money".uncountability() // => true
130132// "my money".uncountability() // => true
131133inflect . uncountability = function ( word ) {
132- return inflect . inflections . uncountables . some ( function ( ele , ind , arr ) {
133- return word . match ( new RegExp ( " (\\b|_)" + ele + "$" , 'i' ) ) != null ;
134+ return inflect . inflections . uncountables . some ( function ( ele , ind , arr ) {
135+ return word . match ( new RegExp ( ' (\\b|_)' + ele + '$' , 'i' ) ) != null ;
134136 } ) ;
135137} ;
136138
@@ -190,8 +192,8 @@ inflect.humanize = function (lower_case_and_underscored_word) {
190192 human = inflect . inflections . humans [ i ] ;
191193 result = util . string . gsub ( result , human [ 0 ] , human [ 1 ] ) ;
192194 }
193- result = util . string . gsub ( result , / _ i d $ / , "" ) ;
194- result = util . string . gsub ( result , / _ / , " " ) ;
195+ result = util . string . gsub ( result , / _ i d $ / , '' ) ;
196+ result = util . string . gsub ( result , / _ / , ' ' ) ;
195197 return util . string . capitalize ( result , true ) ;
196198} ;
197199
@@ -229,4 +231,4 @@ inflect.tableize = function (class_name) {
229231// "business".classify() // => "Busines"
230232inflect . classify = function ( table_name ) {
231233 return inflect . camelize ( inflect . singularize ( util . string . gsub ( table_name , / .* \. / , '' ) ) ) ;
232- }
234+ } ;
0 commit comments