@@ -10,7 +10,7 @@ var util = require('./util');
10
10
var inflect = module . exports ;
11
11
12
12
// Import [inflections](inflections.html) instance
13
- inflect . inflections = require ( './inflections' )
13
+ inflect . inflections = require ( './inflections' ) ;
14
14
15
15
// Gives easy access to add inflections to this class
16
16
inflect . inflect = function ( fn ) {
@@ -31,13 +31,13 @@ inflect.inflect = function (fn) {
31
31
// though there are cases where that does not hold:
32
32
//
33
33
// "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 ) {
35
35
var result ;
36
36
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 ] ) ;
39
39
} ) ;
40
- result = util . string . gsub ( result , / (?: _ ) ( .) / , function ( $ ) {
40
+ result = util . string . gsub ( result , / (?: _ ) ( .) / , function ( $ ) {
41
41
return util . string . upcase ( $ [ 1 ] ) ;
42
42
} ) ;
43
43
if ( first_letter_in_uppercase ) {
@@ -61,8 +61,8 @@ inflect.camelize = function(lower_case_and_underscored_word, first_letter_in_upp
61
61
inflect . underscore = function ( camel_cased_word ) {
62
62
var self ;
63
63
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' ) ;
66
66
self = util . string . gsub ( self , / - / , '_' ) ;
67
67
return self . toLowerCase ( ) ;
68
68
} ;
@@ -93,7 +93,9 @@ inflect.foreign_key = function (class_name, separate_class_name_and_id_with_unde
93
93
if ( separate_class_name_and_id_with_underscore == null ) {
94
94
separate_class_name_and_id_with_underscore = true ;
95
95
}
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
+ ) ;
97
99
} ;
98
100
99
101
// Turns a number into an ordinal string used to denote the position in an
@@ -109,17 +111,17 @@ inflect.ordinalize = function (number) {
109
111
var _ref ;
110
112
number = parseInt ( number ) ;
111
113
if ( ( _ref = Math . abs ( number ) % 100 ) === 11 || _ref === 12 || _ref === 13 ) {
112
- return "" + number + "th" ;
114
+ return '' + number + 'th' ;
113
115
} else {
114
116
switch ( Math . abs ( number ) % 10 ) {
115
117
case 1 :
116
- return "" + number + "st" ;
118
+ return '' + number + 'st' ;
117
119
case 2 :
118
- return "" + number + "nd" ;
120
+ return '' + number + 'nd' ;
119
121
case 3 :
120
- return "" + number + "rd" ;
122
+ return '' + number + 'rd' ;
121
123
default :
122
- return "" + number + "th" ;
124
+ return '' + number + 'th' ;
123
125
}
124
126
}
125
127
} ;
@@ -129,8 +131,8 @@ inflect.ordinalize = function (number) {
129
131
// "money".uncountability() // => true
130
132
// "my money".uncountability() // => true
131
133
inflect . 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 ;
134
136
} ) ;
135
137
} ;
136
138
@@ -190,8 +192,8 @@ inflect.humanize = function (lower_case_and_underscored_word) {
190
192
human = inflect . inflections . humans [ i ] ;
191
193
result = util . string . gsub ( result , human [ 0 ] , human [ 1 ] ) ;
192
194
}
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 , / _ / , ' ' ) ;
195
197
return util . string . capitalize ( result , true ) ;
196
198
} ;
197
199
@@ -229,4 +231,4 @@ inflect.tableize = function (class_name) {
229
231
// "business".classify() // => "Busines"
230
232
inflect . classify = function ( table_name ) {
231
233
return inflect . camelize ( inflect . singularize ( util . string . gsub ( table_name , / .* \. / , '' ) ) ) ;
232
- }
234
+ } ;
0 commit comments