'use strict';

var path = require('path');
var _ = require('lodash');

function convertToUnixPath(dir) {
  if (!_.isString(dir)) {
    throw new Error('Expected path to be a string');
  }

  if (path.sep === '\\') {
    dir = path.normalize(dir);
    dir = dir.split(path.sep).join('/');
  }

  return dir;
}

function generateModuleNames(moduleName, prefix) {
  return _buildNameObject(moduleName, 'module', prefix);
}

function generateRouteNames(routeName, prefix) {
  return _buildNameObject(routeName, 'route', prefix);
}

function generateConfigurationNames(configurationName, prefix) {
  return _buildNameObject(configurationName, 'configuration', prefix);
}

function generateRunNames(runName, prefix) {
  return _buildNameObject(runName, 'run', prefix);
}

function generateServiceNames(serviceName, prefix) {
  return _buildNameObject(serviceName, 'service', prefix);
}

function generateProviderNames(providerName, prefix) {
  return _buildNameObject(providerName, 'provider', prefix);
}

function generateControllerNames(controllerName, prefix) {
  return _buildNameObject(controllerName, 'controller', prefix);
}

function generateDirectiveNames(directiveName, prefix) {
  return _buildNameObject(directiveName, 'directive', prefix);
}

function getServiceTemplatePath() 


function getControllerTemplatePath() {
  return path.join('controller', '_controller.ts');
}

function _buildNameObject(name, type, prefix) {
  name = _.camelCase(name);
  prefix = prefix || '';

  var objectName = name + _.capitalize(type);
  if (prefix.length !== 0) {
    objectName = prefix + _.upperFirst(objectName);
  }

  return {
    name: objectName,
    className: _.upperFirst(name) + _.capitalize(type),
    fileName: _.upperFirst(name) + '.' + type + '.ts'
  };
}

module.exports = {
  convertToUnixPath: convertToUnixPath,
  generateModuleNames: generateModuleNames,
  generateRouteNames: generateRouteNames,
  generateConfigurationNames: generateConfigurationNames,
  generateRunNames: generateRunNames,
  generateServiceNames: generateServiceNames,
  generateProviderNames: generateProviderNames,
  generateControllerNames: generateControllerNames,
  generateDirectiveNames: generateDirectiveNames,
  getServiceTemplatePath: getServiceTemplatePath,
  getControllerTemplatePath: getControllerTemplatePath
};

{
  return path.join('service', '_service.ts');
}