lib/ng-directive-parser.js
function Directive(filename, directiveArguments) {
  this.filename = filename;
  this.name = directiveArguments[0].value;
  var directiveConfiguration = directiveArguments[1];
  // Extract the last attribute of the array
  if (directiveConfiguration.type === 'ArrayExpression' && directiveConfiguration.elements.length) {
    directiveConfiguration = directiveConfiguration.elements[directiveConfiguration.elements.length - 1];
  }
  // Parse the function
  if (directiveConfiguration && directiveConfiguration.type === 'FunctionExpression') {
    directiveConfiguration = esprimaHelper.getFirstReturnStatement(directiveConfiguration);
  }
  // Get the returnStatement
  if (directiveConfiguration && directiveConfiguration.type === 'ReturnStatement') {
    directiveConfiguration = directiveConfiguration.argument;
  }
  // Parse the object
  if (directiveConfiguration && directiveConfiguration.type === 'ObjectExpression') {
    var properties = esprimaHelper.parseObjectExpressions(directiveConfiguration);
    this.replace = !!properties.replace;
    this.transclude = !!properties.transclude;
    this.template = properties.template;
    this.templateUrl = properties.templateUrl;
    if (properties.restrict) {
      this.restrict = {
        A: properties.restrict.toUpperCase().indexOf('A') >= 0,
        E: properties.restrict.toUpperCase().indexOf('E') >= 0,
        C: properties.restrict.toUpperCase().indexOf('C') >= 0
      };
    }
  }
  // Add parse warning
  if (!this.restrict) {
    module.exports.logger('no restriction set for', this.filename, this.name);
    this.restrict = {
      A: true,
      E: false,
      C: false
    };
  }
}
function Directive(filename, directiveArguments) {
  this.filename = filename;
  this.name = directiveArguments[0].value;
  var directiveConfiguration = directiveArguments[1];
  // Extract the last attribute of the array
  if (directiveConfiguration.type === 'ArrayExpression' && directiveConfiguration.elements.length) {
    directiveConfiguration = directiveConfiguration.elements[directiveConfiguration.elements.length - 1];
  }
  // Parse the function
  if (directiveConfiguration && directiveConfiguration.type === 'FunctionExpression') {
    directiveConfiguration = esprimaHelper.getFirstReturnStatement(directiveConfiguration);
  }
  // Get the returnStatement
  if (directiveConfiguration && directiveConfiguration.type === 'ReturnStatement') {
    directiveConfiguration = directiveConfiguration.argument;
  }
  // Parse the object
  if (directiveConfiguration && directiveConfiguration.type === 'ObjectExpression') {
    var properties = esprimaHelper.parseObjectExpressions(directiveConfiguration);
    this.replace = !!properties.replace;
    this.transclude = !!properties.transclude;
    this.template = properties.template;
    this.templateUrl = properties.templateUrl;
    if (properties.restrict) {
      this.restrict = {
        A: properties.restrict.toUpperCase().indexOf('A') >= 0,
        E: properties.restrict.toUpperCase().indexOf('E') >= 0,
        C: properties.restrict.toUpperCase().indexOf('C') >= 0
      };
    }
  }
  // Add parse warning
  if (!this.restrict) {
    module.exports.logger('no restriction set for', this.filename, this.name);
    this.restrict = {
      A: true,
      E: false,
      C: false
    };
  }
}
function Directive ( filename , directiveArguments ) { this . filename = filename ; this . name = directiveArguments [ 0 ] . value ; var directiveConfiguration = directiveArguments [ 1 ] ; // Extract the last attribute of the array if ( directiveConfiguration . type === 'ArrayExpression' && directiveConfiguration . elements . length ) { directiveConfiguration = directiveConfiguration . elements [ directiveConfiguration . elements . length - 1 ] ; } // Parse the function if ( directiveConfiguration && directiveConfiguration . type === 'FunctionExpression' ) { directiveConfiguration = esprimaHelper . getFirstReturnStatement ( directiveConfiguration ) ; } // Get the returnStatement if ( directiveConfiguration && directiveConfiguration . type === 'ReturnStatement' ) { directiveConfiguration = directiveConfiguration . argument ; } // Parse the object if ( directiveConfiguration && directiveConfiguration . type === 'ObjectExpression' ) { var properties = esprimaHelper . parseObjectExpressions ( directiveConfiguration ) ; this . replace = ! ! properties . replace ; this . transclude = ! ! properties . transclude ; this . template = properties . template ; this . templateUrl = properties . templateUrl ; if ( properties . restrict ) { this . restrict = { A : properties . restrict . toUpperCase ( ) . indexOf ( 'A' ) >= 0 , E : properties . restrict . toUpperCase ( ) . indexOf ( 'E' ) >= 0 , C : properties . restrict . toUpperCase ( ) . indexOf ( 'C' ) >= 0 } ; } } // Add parse warning if ( ! this . restrict ) { module . exports . logger ( 'no restriction set for' , this . filename , this . name ) ; this . restrict = { A : true , E : false , C : false } ; } }
Class for a directive information bundle
@param filename
@param directiveArguments
@constructor
Class for a directive information bundle