Skip to content

Commit

Permalink
Use CRUD name in view, controller and route name
Browse files Browse the repository at this point in the history
  • Loading branch information
jayralencar committed Apr 22, 2016
1 parent e66f362 commit 0837222
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
This change log is started in 0.0.9;

## 0.0.13 (206-04-22)
- Use URL git to clone base repositories
- Show error on create table, if necessary
- Use URL git to clone base repositories.
- Show error on create table, if necessary.
- Use CRUD name in view, controller and route name.

## 0.0.12 (2016-04-21)
- List CRUDS with ``` basel-crud -l ```
Expand Down
36 changes: 33 additions & 3 deletions bin/basel-crud.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ if(basel.error){

function wizard (options) {
var questions = [];
options.controller = options.controller || options.name_+"Controller";
options.view = options.view || options.name_+".html";
var word = shortName(options.name_);
options.controller = options.controller || word+"Controller";
options.view = options.view || word+".html";

if(!options.table){
questions.push({
Expand All @@ -83,7 +84,6 @@ function wizard (options) {
}

if(!options.route){
var word = options.name_.toLowerCase().replace(/ /g,'');
questions.push({
type: 'input',
name: 'route',
Expand Down Expand Up @@ -115,4 +115,34 @@ function wizard (options) {
_.assign(options, results);
crud.init(options);
});
}


function shortName(str){
return removerAcentos(str).toLowerCase().replace(/ /g,'');
}

/**
* Remove acentos de caracteres
* @param {String} stringComAcento [string que contem os acentos]
* @return {String} [string sem acentos]
*/
function removerAcentos( newStringComAcento ) {
var string = newStringComAcento;
var mapaAcentosHex = {
a : /[\xE0-\xE6]/g,
e : /[\xE8-\xEB]/g,
i : /[\xEC-\xEF]/g,
o : /[\xF2-\xF6]/g,
u : /[\xF9-\xFC]/g,
c : /\xE7/g,
n : /\xF1/g
};

for ( var letra in mapaAcentosHex ) {
var expressaoRegular = mapaAcentosHex[letra];
string = string.replace( expressaoRegular, letra );
}

return string;
}

0 comments on commit 0837222

Please sign in to comment.