Risto-Stevcev/yumparse

View on GitHub
doc/rules.js.html

Summary

Maintainability
Test Coverage
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>JSDoc: Source: rules.js</title>
    
    <script src="scripts/prettify/prettify.js"> </script>
    <script src="scripts/prettify/lang-css.js"> </script>
    <!--[if lt IE 9]>
      <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>

<body>

<div id="main">
    
    <h1 class="page-title">Source: rules.js</h1>
    
    


    
    <section>
        <article>
            <pre class="prettyprint source"><code>/**
 * @module rules
 * @author Risto Stevcev
 */
var helpers = require('./helpers.js');

/** 
 * An object containing built-in rule factory functions 
 * @memberof module:rules 
 * @property {Object} rules.requiredOrFlags - A rule that compares options that must be passed separately and at least one flag is passed
 * @property {Object} rules.orFlags - A rule that compares options that must be passed separately 
 * @property {Object} rules.andFlagSets - A rule that checks if a single flag in each set of flags is passed
 * @property {Object} rules.andFlags - A rule that compares options that must be passed together
 * @property {Object} rules.fileExists - A rule that checks options to see if the file path exists 
 */
module.exports = {
  requiredOrFlags: function() {
    'use strict';
    var args = Array.prototype.slice.call(arguments);
    return {
      message: function() {
        return 'You must pass either ' + helpers.argsToOptions.call(this, args) + 
               ' as a parameter.';
      },
      check: function() { 
        return helpers.oneFlagPassed.call(this, args);
      }
    };
  },

  orFlags: function() {
    'use strict';
    var args = Array.prototype.slice.call(arguments);
    return {
      message: function() {
        return 'You can only pass ' + helpers.argsToOptions.call(this, args) + 
               ' as a parameter.';
      },
      check: function() { 
        return Object.keys(this.parsedOptions).length ? 
               helpers.oneFlagPassed.call(this, args) : true;
      }
    };
  },

  andFlags: function() {
    'use strict';
    var args = Array.prototype.slice.call(arguments);
    return {
      message: function() {
        return 'You must pass parameters ' + JSON.stringify(args) + ' together.';
      },
      check: function() { 
        return helpers.allFlagsPassed.call(this, args);
      }
    };
  },

  andFlagSets: function() {
    'use strict';
    var args = Array.prototype.slice.call(arguments);
    return {
      message: function() {
        return 'A flag must be passed from each set: ' + JSON.stringify(args);
      },
      check: function() { 
        return helpers.allFlagSetsPassed.call(this, args);
      }
    };
  },

  fileExists: function() {
    'use strict';
    var args = Array.prototype.slice.call(arguments);
    return {
      message: function() {
        return 'One of the following file paths ' + JSON.stringify(args) + ' does not exist.';
      },
      check: function() { 
        return helpers.fileExists.call(this, args);
      }
    };
  }
};
</code></pre>
        </article>
    </section>




</div>

<nav>
    <h2><a href="index.html">Index</a></h2><h3>Modules</h3><ul><li><a href="module-helpers.html">helpers</a></li><li><a href="module-rules.html">rules</a></li><li><a href="module-yumparse.html">yumparse</a></li></ul><h3>Classes</h3><ul><li><a href="module-yumparse.Parser.html">Parser</a></li><li><a href="module-yumparse.Parser-YumparseError.html">YumparseError</a></li></ul>
</nav>

<br clear="both">

<footer>
    Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a> on Mon Dec 29 2014 23:32:09 GMT-0800 (PST)
</footer>

<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>