-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
⚰️ Remove some unused string methods
- Loading branch information
Showing
3 changed files
with
2 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -389,111 +389,6 @@ defString(function modelName(postfix) { | |
return str; | ||
}); | ||
|
||
/** | ||
* Turn a string into a model name, with controller postfix | ||
* | ||
* @author Jelle De Loecker <[email protected]> | ||
* @since 0.1.4 | ||
* @version 0.1.4 | ||
* | ||
* @return {String} | ||
*/ | ||
defString(function modelClassName() { | ||
|
||
var result; | ||
|
||
if (Collection.String.prototype.endsWith.call(this, 'Model')) { | ||
result = this.slice(0, this.length - 5); | ||
} else { | ||
result = this; | ||
} | ||
|
||
result = Collection.String.prototype.modelName.call(result); | ||
|
||
return result + 'Model'; | ||
}); | ||
|
||
/** | ||
* Turn a string into a controller name | ||
* | ||
* @author Jelle De Loecker <[email protected]> | ||
* @since 0.0.1 | ||
* @version 0.1.4 | ||
* | ||
* @param {String} postfix The string to postfix to the name | ||
* | ||
* @return {String} | ||
*/ | ||
defString(function controllerName(postfix) { | ||
|
||
var str = this, | ||
underscores, | ||
capitals, | ||
lower; | ||
|
||
lower = str.toLowerCase(); | ||
|
||
if (lower === 'app') return 'App'; | ||
else if (lower === 'static') return 'Static'; | ||
|
||
if (postfix === true) postfix = 'Controller'; | ||
|
||
capitals = !!S.capitals(str); | ||
underscores = !!(str.indexOf('_') > -1); | ||
|
||
// If there already are capitals, underscore the string | ||
if (capitals) { | ||
str = S.underscore(str); | ||
underscores = true; | ||
} | ||
|
||
// If there still are underscores, or there are no capitals, | ||
// we need to camelize the string | ||
if (underscores || !capitals) { | ||
str = S.camelize(str); | ||
} | ||
|
||
if (S.endsWith(str, 'Controller')) { | ||
str = str.slice(0, str.length-10); | ||
} | ||
|
||
// Do not pluralize 'static' | ||
if (!S.endsWith(str, 'Static')) { | ||
str = S.pluralize(str); | ||
} | ||
|
||
// Append the postfix | ||
if (postfix) { | ||
str = S.postfix(str, postfix); | ||
} | ||
|
||
return str; | ||
}); | ||
|
||
/** | ||
* Turn a string into a controller name, with controller postfix | ||
* | ||
* @author Jelle De Loecker <[email protected]> | ||
* @since 0.1.4 | ||
* @version 0.1.4 | ||
* | ||
* @return {String} | ||
*/ | ||
defString(function controllerClassName() { | ||
|
||
var result; | ||
|
||
if (Collection.String.prototype.endsWith.call(this, 'Controller')) { | ||
result = this.slice(0, this.length - 10); | ||
} else { | ||
result = this; | ||
} | ||
|
||
result = Collection.String.prototype.controllerName.call(result); | ||
|
||
return result + 'Controller'; | ||
}); | ||
|
||
/** | ||
* Camelize a string | ||
* | ||
|
@@ -800,26 +695,6 @@ defString(function titleize(alwaysCapitalize) { | |
return str; | ||
}); | ||
|
||
/** | ||
* Removes module names leaving only class names (Ruby style) | ||
* Example: "Message::Bus::Properties".demodulize() == "Properties" | ||
* | ||
* @author Jelle De Loecker <[email protected]> | ||
* @since 0.0.1 | ||
* @version 0.1.0 | ||
* | ||
* @return {String} | ||
*/ | ||
defString(function demodulize() { | ||
|
||
var str = this, | ||
str_arr = str.split('::'); | ||
|
||
str = str_arr[str_arr.length - 1]; | ||
|
||
return str; | ||
}); | ||
|
||
/** | ||
* Renders strings into their underscored plural form | ||
* | ||
|
@@ -862,8 +737,7 @@ defString(function classify() { | |
* @return {String} | ||
*/ | ||
defString(function foreign_key(dropIdUbar) { | ||
var str = S.demodulize(this); | ||
str = S.underscore(str); | ||
let str = S.underscore(this); | ||
str += ((dropIdUbar) ? ('') : ('_')) + 'id'; | ||
return str; | ||
}); | ||
|
@@ -916,29 +790,4 @@ defString(function ordinalize() { | |
str = str_arr.join(' '); | ||
|
||
return str; | ||
}); | ||
|
||
/** | ||
* De-pluginify a string | ||
* | ||
* @author Jelle De Loecker <[email protected]> | ||
* @since 0.0.1 | ||
* @version 0.0.1 | ||
* | ||
* @return {Boolean} | ||
*/ | ||
defString(function deplugin(str) { | ||
|
||
var s = this.split('.'), | ||
any = false; | ||
obj = {plugin: '', item: '', model: '', field: '', name: ''}; | ||
|
||
if (typeof s[1] != 'undefined') { | ||
obj.plugin = obj.model = obj.name = s[0]; | ||
obj.item = obj.field = s[1]; | ||
} else { | ||
obj.item = obj.field = s[0]; | ||
} | ||
|
||
return obj; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters