[
  {
    "path": ".gitignore",
    "content": "node_modules\n"
  },
  {
    "path": ".jshintrc",
    "content": "{\n    \"browser\": true,\n    \"node\": true,\n    \"esnext\": true,\n    \"bitwise\": false,\n    \"curly\": false,\n    \"eqeqeq\": true,\n    \"eqnull\": true,\n    \"immed\": true,\n    \"latedef\": false,\n    \"laxcomma\": true,\n    \"newcap\": true,\n    \"noarg\": true,\n    \"undef\": true,\n    \"strict\": true,\n    \"trailing\": true,\n    \"smarttabs\": true,\n    \"white\": true\n}\n"
  },
  {
    "path": ".travis.yml",
    "content": "language: node_js\nnode_js:\n   - \"0.10\"\n   - \"0.12\"\n"
  },
  {
    "path": "CHANGELOG.md",
    "content": "== HEAD\n"
  },
  {
    "path": "LICENSE.md",
    "content": "This software is released under the MIT license:\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\nthe Software, and to permit persons to whom the Software is furnished to do so,\nsubject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\nFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\nCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\nIN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE."
  },
  {
    "path": "README.md",
    "content": "# Parker\n\nParker is a stylesheet analysis tool. It runs metrics on your stylesheets and will report on their complexity.\n\n[![Build Status](https://secure.travis-ci.org/katiefenn/parker.png?branch=master)](http://travis-ci.org/katiefenn/parker)\n\n\n## Installation\n\nInstall with npm:\n\n```\nnpm install -g parker\n```\n\n## Usage\n\n### Measuring Local Stylesheets\n\n```\nparker a.css b.css c.css\n```\n```\nparker css/\n```\n\n### Measuring a Remote Stylesheet Using Curl\n\n```\ncurl http://www.katiefenn.co.uk/css/shuttle.css -s | parker -s\n```\n\n### Output JSON\n\n```\nparker example.css --format=json\n```\n\n### Programmatic usage\n\nAfter installing parker as a dependency in your project, you can use it as follows:\n\n```js\nvar Parker = require('parker/lib/Parker');\nvar metrics = require('parker/metrics/All'); // Or an array of the metrics you want to measure\n\nvar file = fs.readFile('test.css', function (err, data) {\n\tif (err) throw err;\n\n\tvar parker = new Parker(metrics);\n\tvar results = parker.run(data.toString());\n\n\t// Do something with results\n});\n```\n\n## Documentation\n\nDocumentation can be found in markdown format the [docs folder](https://github.com/katiefenn/parker/tree/master/docs).\n\n## Testing\n\nFrom the repo root:\n\n```\nnpm install\nnpm test\n```\n\n## Contributing\n\nPull requests, issues, new unit tests, code reviews and good advice are all things that would make a difference to Parker. You can even contribute by telling me how useful Parker is to you; please let me know on Twitter at @katie_fenn. Any time generously donated to helping make Parker better is gratefully accepted, and in return I shall do my best to merge contributions.\n\nPlease target pull requests at the \"develop\" branch.\n\n## About\n\nParker is my first open source project, and your suggestions and feedback are welcome. The project is in a pre-beta phase and is liable to change at any time. Parker is named for the character Parker from Gerry Anderson's Thunderbirds, without which my interest in technology and computers would certainly not be what it is today. Parker is Nosey about your stylesheets.\n"
  },
  {
    "path": "docs/contributing/readme.md",
    "content": "# Contributing\nPull requests, issues, new unit tests, code reviews and good advice are all things that would make a difference to Parker. You can even contribute by telling me how useful Parker is to you; please let me know on Twitter at @katie_fenn. Any time generously donated to helping make Parker better is gratefully accepted, and in return I shall do my best to merge contributions.\n\n<a name=\"github\"></a>\n## GitHub\nThe source-code is hosted at [GitHub](https://github.com/katiefenn/Parker).\n\nWhen creating pull requests, please target the develop branch.\n\n<a name=\"testing\"></a>\n## Testing\nA suite of unit tests are maintained to test Parker. The tools Mocha, Chai and Sinon are among the tools used for testing.\n\nFrom the project root, dependencies can be installed using the following command:\n\n\tnpm install\n\nUnit tests can be run using the following command:\n\n\tnpm test\n"
  },
  {
    "path": "docs/installation/readme.md",
    "content": "# Installation\nParker requires Node.JS and npm to be installed before it can be installed itself.\n\n<a name=\"install-node-js\"></a>\n## Install Node.JS\nNode.JS is a Javascript software platform for use outside of the web browser. It allows tools like Parker to be written in JavaScript and run from the command-line on your computer.\n\nnpm is a package manager for Node.JS and is also installed by Node.JS installer packages.\n\nInstaller packages for Node.JS can be found at the [Node.JS Website](http://nodejs.org/download/) for many operating systems. Node.JS can also be installed using a range of [package managers](https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager).\n\n<a name=\"install-parker\"></a>\n## Install Parker\nInstall with npm:\n\n\tnpm install -g parker"
  },
  {
    "path": "docs/metrics/readme.md",
    "content": "# Metrics\nParker has a suite of metrics that are useful for measuring stylesheets. What follows is a list of all the metrics that are bundled with Parker. Parker's metrics are modular and it's easy to write your own - find out how [here](#authoring-metrics).\n\n1. [Bundled Metrics](#bundled-metrics)\n\t1. [Stylesheet Totals](#stylesheet-totals)\n\t\t1. [Total Stylesheets](#total-stylesheets)\n\t\t2. [Total Stylesheet Size](#total-stylesheet-size)\n\t2. [Stylesheet Elements](#stylesheet-elements)\n\t\t1. [Total Rules](#total-rules)\n\t\t2. [Total Selectors](#total-selectors)\n\t\t3. [Total Identifiers](#total-identifiers)\n\t\t4. [Total Declarations](#total-declarations)\n\t\t5. [Selectors Per Rule](#selectors-per-rule)\n\t\t6. [Identifiers Per Selectors](#identifiers-per-selector)\n\t3. [Specificity](#specificity)\n\t\t1. [Specificity Per Selector](#specificity-per-selector)\n\t\t2. [Top Selector Specificity](#top-selector-specificity)\n\t\t3. [Top Selector Specificity Selector](#top-selector-specificity-selector)\n\t4. [Important Keywords](#important-keywords)\n\t\t1. [Total Important Keywords](#total-important-keywords)\n\t5. [Colors](#colours)\n\t\t1. [Total Unique Colours](#total-unique-colours)\n\t\t2. [Unique Colours](#unique-colours)\n\t6. [Media Queries](#media-queries-heading)\n\t\t1. [Media Queries](#media-queries)\n\t\t2. [Total Media Queries](#total-media-queries)\n\t\n2. [Authoring Metrics](#authoring-metrics)\n\t1. [Attributes](#attributes)\n\t\t1. [id](#id)\n\t\t2. [name](#name)\n\t\t3. [type](#type)\n\t\t4. [aggregate](#aggregate)\n\t\t5. [format](#format)\n\t2. [Methods](#methods)\n\t\t1. [measure](#measure)\n\t\t2. [filter](#filter)\n\t\t3. [iterator](#iterator)\t\n\n<a name=\"bundled-metrics\"></a>\n## [Bundled Metrics](#bundled-metrics)\n\n<a name=\"stylesheet-totals\"></a>\n### Stylesheet Totals\nBasic metrics that influence stylesheet and HTTP performance.\n\n<a name=\"total-stylesheets\"></a>\n#### Total Stylesheets\nThe number of stylesheets measured. This is the number of stylesheets submitted to Parker in a single report, and can be used to track how many stylesheets are requested in your application. Each stylesheet is downloaded over a HTTP request, which affects performance. Generally, fewer HTTP requests improves performance.\n\n- __id__: total-stylesheets\n- __name__: Total Stylesheets\n- __type__: stylesheet\n- __aggregate__: sum\n- __format__: number\n\n<a name=\"stylesheet-size\"></a>\n#### Total Stylesheet Size\nMeasures the total file size of stylesheets measured. Each stylesheet is downloaded over a HTTP request, and the size of the request affects performance. Smaller HTTP request file sizes improves performance.\n\n- __id__: total-stylesheet-size\n- __name__: Total Stylesheet Size\n- __type__: stylesheet\n- __aggregate__: sum\n- __format__: number\n\n<a name=\"stylesheet-elements\"></a>\n### Stylesheet Elements\nStylesheet size can be broken down into the total number of its parts: rules, selectors, identifiers and declarations.\n\n<a name=\"total-rules\"></a>\n#### Total Rules\nMeasures the total number of rules. Each rule defines a specific behaviour of the design. Stylesheets with fewer rules are simpler.\n\n- __id__: total-rules\n- __name__: Total Rules\n- __type__: rule\n- __aggregate__: sum\n- __format__: number\n\n\n#### Total Selectors\nMeasures the total number of selectors. Each selector defines a group of elements affected by the design. Stylesheets with fewer selectors are simpler.\n\n- __id__: total-selectors\n- __name__: Total Selectors\n- __type__: selector\n- __aggregate__: sum\n- __format__: number\n\n<a name=\"total-identifiers\"></a>\n#### Total Identifiers\nMeasures the total number of identifiers. Each identifier defines a group of elements affected by the design. Stylesheets with fewer identifiers are simpler. It can be useful to break measure identifiers as well as identifiers so that small code changes to selectors can be tracked.\n\n- __id__: total-identifiers \n- __name__: Total Identifiers\n- __type__: identifier\n- __aggregate__: sum\n- __format__: number\n\n<a name=\"total-declarations\"></a>\n#### Total Declarations\nMeasures the total number of property declarations. Each property declaration defines a modification of the appearance or function of an element. Stylesheets with fewer property declarations are simpler.\n\n- __id__: total-declarations\n- __name__: Total Declarations\n- __type__: declaration\n- __aggregate__: sum\n- __format__: number\n\n#### Selectors Per Rule\nMeasures the average number of selectors in every rule. Stylesheet rules can be applied to several groups of elements using multiple selectors, separated by a comma. Fewer selectors in a rule makes its properties specific to a smaller group of elements, and also makes a rule easier to read in text editors and developer tools.\n\n- __id__: total-important-keywords\n- __name__: Total Important Keywords\n- __type__: value\n- __aggregate__: sum\n- __format__: number\n\n#### Identifiers Per Selector\nMeasures the average number of identifiers in every selector. Selectors can be made more specific to combinations of elements by adding more identifiers to a selector. Fewer identifiers in a given selector reduces its dependency on certain DOM structures, allowing more changes to your HTML before being forced to change your CSS. Selectors with fewer identifiers are also more readable.\n\n- __id__: identifiers-per-selector\n- __name__: Identifiers Per Selector\n- __type__: selector\n- __aggregate__: mean\n- __format__: number\n\n<a name=\"specificity\"></a>\n### Specificity\nA rule can be overrided by another rule with a more specific selector. Complexity is added to stylesheets when multiple levels of cascading rules are used in stylesheets, because it becomes more difficult to predict which properties apply to a given element without keeping in mind other rules.\n\n<a name=\"specificity-per-selector\"></a>\n#### Specificity Per Selector\nMeasures the average specificity of selectors. Lower average specificity makes it easier to combine and re-use properties defined in other, less-specific rules.\n\n- __id__: specificity-per-selector\n- __name__: Specificity Per Selector\n- __type__: selector\n- __aggregate__: mean\n- __format__: number\n\n<a name=\"top-selector-specificity\"></a>\n#### Top Selector Specificity\nMeasures the specificity of the most specific selector. Reducing the specificity of the most complex selectors is a good way to reducing the overall complexity of a stylesheet.\n\n- __id__: top-selector-specificity\n- __name__: Top Selector Specificity\n- __type__: selector\n- __aggregate__: max\n- __format__: number\n\n<a name=\"top-selector-specificity-selector\"></a>\n#### Top Selector Specificity Selector\nDisplays the most specific selector. Reducing the specificity of the most complex selectors is a good way to reducing the overall complexity of a stylesheet.\n\n- __id__: top-selector-specificity-selector\n- __name__: Top Selector Specificity Selector\n- __type__: selector\n- __aggregate__: max\n- __format__: string\n\n<a name=\"important-keywords\"></a>\n### Important Keywords\nThe !important keyword supersedes selector specificity, even allowing properties to be enforced over properties of rules with high specificity selectors. Because !important is so powerful, it should be reserved for use for architectural purposes, enforcing styles in user stylesheets and utility classes. Using !important to overcome issues with specificity exacerbates the problem.\n\n<a name=\"total-important-keywords\"></a>\n#### Total Important Keywords\nMeasures the total instances of the !important keyword. Fewer !important keywords indicates a simpler stylesheet.\n\n- __id__: total-important-keywords\n- __name__: Total Important Keywords\n- __type__: value\n- __aggregate__: sum\n- __format__: number\n\n<a name=\"colours\"></a>\n### Colours\nColour is an important part of design, and highlights important elements such as buttons, sections and text. A consistent colour scheme is a good way of guiding users around a site. An excessive number of colours indicates an overly-complex colour scheme, or inconsistent use of colour that forces an over-reliance of developers on design documents.\n\n<a name=\"total-unique-colours\"></a>\n#### Total Unique Colours\nMeasures the number of unique colour hashes used in a stylesheet. Fewer colours indicates a simpler colour scheme.\n\n- __id__: total-unique-colours\n- __name__: Total Unique Colors\n- __type__: value\n- __aggregate__: length\n- __format__: number\n\n<a name=\"unique-colours\"></a>\n#### Unique Colours\nLists the unique colour hashes used in a stylesheet. Identifying and reducing unique colours is a good way to simplify colour schemes.\n\n- __id__: unique-colours\n- __name__: Unique Colors\n- __type__: value\n- __aggregate__: list\n- __format__: list\n\n<a name=\"media-queries-heading\"></a>\n### Media Queries\nMedia queries contain rules that change the behaviour of documents according to the sort of device or its state. They're commonly used to create breakpoints in responsive web design behaviour. Each unique media query adds complexity by changing behaviour when a given criteria is met by the device.\n\n<a name=\"media-queries\"></a>\n#### Media Queries\nLists every unique media query used. Reducing unique media queries is a good way to simplify stylesheets.\n\n- __id__: media-queries\n- __name__: Media Queries\n- __type__: mediaquery\n- __aggregate__: list'\n- __format__: list\n\n<a name=\"total-media-queries\"></a>\n#### Total Media Queries\nMeasures the number of unique media queries used. Fewer media queries indicates a simpler stylesheet.\n\n- __id__: total-media-queries\n- __name__: Total Media Queries\n- __type__: mediaquery\n- __aggregate__: length\n- __format__: number\n\n<a name=\"authoring-metrics\"></a>\n## Authoring Metrics\nParker's stylesheets are modular, and there are several attributes and methods a metric can implement to access Parker's metric features.\n\n<a name=\"attributes\"></a>\n### Attributes\n<a name=\"id\"></a>\n#### id\nThe unique identifier of the metric and is used when selecting metrics to be run.\n\n<a name=\"name\"></a>\n#### name\nThe natural language name of the metric and is used when reporting results.\n\n<a name=\"type\"></a>\n#### type\nThe type of stylesheet elements the metric is run against.\n\nAvailable types:\n\n- stylesheet\n- rule\n- selector\n- identifier\n- declaration\n- property\n- value\n- mediaquery\n\n<a name=\"aggregate\"></a>\n#### aggregate\nThe operation applied to data collected by metrics on elements before results are reported.\n\nAvailable aggregates:\n\n- __sum__: will sum number values\n- __mean__: will average number values by mean\n- __max__: will select the maximum of number values after iterator function is applied\n- __list__: will list all collected values after filter function is applied\n- __length__: will display the number of collected values after filter function is applied\n\n<a name=\"format\"></a>\n#### format\nThe output format of the end result. Used for selecting metrics for use in scripts.\n\nAvailable formats:\n\n- number\n- list\n- string\n\n<a name=\"methods\"></a>\n### Methods\n<a name=\"measure\"></a>\n#### measure\n\tmetric.measure(element)\nMeasures an element of css \"element\" and returns a measurement to be reported. This is the main method that measures elements that all metrics must implement.\n\nExample:\nThe Stylesheet Size measure method returns a simple number measurement, which is summed on aggregate.\n\n\tmodule.exports = {\n    \tid: 'total-stylesheet-size',\n\t    name: 'Total Stylesheet Size',\n    \ttype: 'stylesheet',\n\t    aggregate: 'sum',\n    \tformat: 'number',\n\t    measure: function (stylesheet) {\n    \t    return byteCount(stylesheet);\n\t    }\n\t};\n\t\n\tfunction byteCount(s) {\n    \treturn encodeURI(s).split(/%..|./).length - 1;\n\t}\n\n<a name=\"filter\"></a>\n#### filter\n\tmetric.filter(predicate)\nFilters list-aggregated results based on the truth-test \"predicate\" function.\n\nPredicate parameters:\n\n- __value__: the value of the measurement\n- __index__: the index of the item in all measurements the metric has collected\n- __list__: the current list of all measurements to compare the current item to\n\nExample:\nThe Total Media Queries returns the query to be collected into a list. Before reporting, the filter method is run on the list, removing duplicate queries by returning a true or false value according to whether it is the only such item in the list. The length aggregate returns the number of queries collected after filtering.\n\n\tmodule.exports = {\n    \tid: 'total-media-queries',\n\t    name: 'Total Media Queries',\n    \ttype: 'mediaquery',\n\t    aggregate: 'length',\n    \tformat: 'number',\n\t    measure: function (query) {\n    \t    return query;\n\t    },\n    \tfilter: function (value, index, list) {\n\t        return self.indexOf(value) === index;\n    \t}\n\t};\n\n<a name=\"iterator\"></a>\n#### iterator\n\tmetric.iterator(element)\nA helper method of \"max\" aggregated metrics that returns a number value for the given element. Used to determine which item should be selected as the maximum value when the measurement returned by the measurement method is not a number value. When the method is not defined, the measurement returned by \"measure\" is used instead.\n\nExample:\nThe Top Selector Specificity Selector metric returns the most specific selector, but does not report a number value. An iterator method is used to determine the selector's specificity when results are aggregated.\n\n\tmodule.exports = {\n    \tid: 'top-selector-specificity-selector',\n\t    name: 'Top Selector Specificity Selector',\n    \ttype: 'selector',\n\t    aggregate: 'max',\n    \tformat: 'string',\n\t    measure: function (selector) {\n    \t    return selector;\n\t    },\n    \titerator: function (selector) {\n\t        var identifiers = getIdentifiers(selector),\n    \t        specificity = 0;\n\t\n\t\t\t/*\n\t\t\t\tImplementation calculating specificity cut for brevity\n\t\t\t\t...\t\t\t\n\t\t\t*/\n\t\n    \t    return specificity;\n\t    }\n\t};\n\n\n"
  },
  {
    "path": "docs/readme.md",
    "content": "# Parker\nParker is a stylesheet analysis tool. It runs metrics on your stylesheets and will report on their complexity.\n\n## Table of Contents\n\n1. [Installation](installation/readme.md)\n    1. [Installing Node.JS](installation/readme.md#install-node-js)\n    2. [Installing Parker](installation/readme.md#install-parker)\n2. [Usage](usage/readme.md)\n\t1. [Options](usage/readme.md#options)\n3. [Using Parker as a Package](usage-package/readme.md)\n3. [Metrics](metrics/readme.md)\n\t1. [Bundled Metrics](metrics/readme.md#bundled-metrics)\n\t2. [Authoring Metrics](metrics/readme.md#authoring-metrics)\n4. [Contributing](contributing/readme.md)\n\t1. [GitHub](contributing/readme.md#github)\n\t2. [Testing](contributing/readme.md#testing)"
  },
  {
    "path": "docs/usage/readme.md",
    "content": "# Usage\nParker is a command-line tool. Switches and options are used to control how it works. By default Parker runs with recommended settings for beginners to aid discoverability. To make the most of Parker, it is recommended users read about the available options and choose which metrics are most useful to them.\n\n\tparker [arguments] [file...]\n\nMeasuring local stylesheets:\n\n\tparker a.css b.css c.css\n\nMeasuring all local stylesheets in a directory:\n\n\tparker css/\n\nMeasuring a remote stylesheet using curl:\n\n\tcurl http://www.katiefenn.co.uk/css/shuttle.css | parker -s\n\n<a name=\"options\"></a>\n## Options\n### -f --format\nSet output format.\n\nFormats:\n\n- __human__: Default. Human-readable format.\n- __json__: JSON format for integration with scripts.\n- __csv__: Comma-separated-value format for output to spreadsheets.\n\n### -h --help\nShows help.\n\n### -n --numeric\nRun numeric-format metrics only. Useful for making benchmarks.\n\n### -s --stdin\nInput CSS using stdin.\n\n### -v --version\nShow version number of Parker.\n"
  },
  {
    "path": "docs/usage-package/readme.md",
    "content": "# Using Parker as a Package\n\nParker can be used as a package in scripts. It can be installed using npm like so:\n\n\tnpm install --save parker\n\t\nParker can then be used to run metrics on CSS on strings of stylesheet content:\n\n    var Parker = require('parker'),\n        metrics = require('./node_modules/parker/metrics/all'),\n        parker = new Parker(metrics);\n\n    console.log(parker.run('body {background: #fff;}'));\n    \n    /*\n    { 'total-stylesheets': 1,\n\t  'total-stylesheet-size': 24,\n\t  'total-rules': 1,\n\t  'selectors-per-rule': 1,\n\t  'total-selectors': 1,\n\t  'identifiers-per-selector': 1,\n\t  'specificity-per-selector': 1,\n\t  'top-selector-specificity': 1,\n\t  'top-selector-specificity-selector': 'body',\n\t  'total-id-selectors': 0,\n\t  'total-identifiers': 1,\n\t  'total-declarations': 1,\n\t  'total-unique-colours': 1,\n\t  'unique-colours': [ '#FFFFFF' ],\n\t  'total-important-keywords': 0,\n\t  'total-media-queries': 0,\n\t  'media-queries': [] }\n    */\n\t\nMetrics have a bunch of properties that can help you select which ones you want to use:\n\n    var metrics = require('./node_modules/parker/metrics/all'),\n        numericMetrics = metrics.filter(metricIsNumeric),\n        topSelectorSpecificityMetric = metrics.filter(metricIsTopSelectorSpecificity),\n        selectorMetrics = metrics.filter(metricIsSelectorType);\n\n\tfunction metricIsNumeric(metric) {\n\t\treturn metric.format == 'number';\n\t}\n\n\tfunction metricIsTopSelectorSpecificity(metric) {\n\t\treturn metric.id == 'top-selector-specificity';\n\t}\n\n\tfunction metricIsSelectorType(metric) {\n\t\treturn metric.type == 'selector';\n\t}"
  },
  {
    "path": "lib/ArraySelectorSpecificity.js",
    "content": "/*! Parker v0.0.0 - MIT license */\n\n'use strict';\n\nvar CssSelector = require('../lib/CssSelector');\nvar _ = require('lodash');\n\nmodule.exports = function (rawSelector) {\n    var idIdentifiers = 0,\n        classIdentifiers = 0,\n        attributeIdentifiers = 0,\n        pseudoClassIdentifiers = 0,\n        typeIdentifiers = 0,\n        pseudoElementIdentifiers = 0,\n        selector = new CssSelector(rawSelector);\n\n    _.each(selector.getIdentifiers(), function (identifier) {\n        idIdentifiers += countIdIdentifiers(identifier);\n        classIdentifiers += countClassIdentifiers(identifier);\n        attributeIdentifiers += countAttributeIdentifiers(identifier);\n        pseudoClassIdentifiers += countPseudoClassIdentifiers(identifier);\n        typeIdentifiers += countTypeIdentifiers(identifier);\n        pseudoElementIdentifiers = countPseudoElementIdentifiers(identifier);\n    });\n\n    return [\n      idIdentifiers,\n      classIdentifiers + attributeIdentifiers + pseudoClassIdentifiers,\n      typeIdentifiers + pseudoElementIdentifiers\n    ];\n}\n\nvar countIdIdentifiers = function (identifier) {\n    var regex = /#/,\n        matches = regex.exec(identifier);\n\n    if (matches && !countAttributeIdentifiers(identifier)) {\n        return matches.length;\n    }\n\n    return 0;\n};\n\nvar countClassIdentifiers = function (identifier) {\n    var regex = /\\./,\n        matches = regex.exec(identifier);\n\n    if (matches) {\n        return matches.length;\n    }\n\n    return 0;\n};\n\nvar countAttributeIdentifiers = function (identifier) {\n    var regex = /\\[/,\n        matches = regex.exec(identifier);\n\n    if (matches) {\n        return matches.length;\n    }\n\n    return 0;\n};\n\nvar countPseudoClassIdentifiers = function  (identifier) {\n    var regex = /^:[^:]/,\n        matches = regex.exec(identifier);\n\n    // :not pseudo-class identifier itself is ignored\n    // only selectors inside it are counted\n    if (identifier.match(/:not/)) {\n        return 0;\n    }\n\n    if (matches) {\n        return matches.length;\n    }\n\n    return 0;\n};\n\nvar countTypeIdentifiers = function (identifier) {\n    var regex = /^[a-zA-Z_]/;\n\n    if (regex.exec(identifier)) {\n        return 1;\n    }\n\n    return 0;\n};\n\nvar countPseudoElementIdentifiers = function (identifier) {\n    var regex = /::/,\n        matches = regex.exec(identifier);\n\n    if (matches) {\n        return matches.length;\n    }\n\n    return 0;\n};\n\nvar stripNotIdentifier = function (identifier) {\n    if (identifier.match(/:not/)) {\n        return identifier.replace(/:not\\(|\\)/g, '');\n    }\n\n    return identifier;\n};\n"
  },
  {
    "path": "lib/ClassicalSelectorSpecificity.js",
    "content": "/*! Parker v0.0.0 - MIT license */\n\n'use strict';\n\nvar CssSelector = require('../lib/CssSelector');\nvar _ = require('lodash');\n\nmodule.exports = function (rawSelector) {\n    var totalSpecificity = 0,\n        selector = new CssSelector(rawSelector);\n\n    _.each(selector.getIdentifiers(), function (identifier) {\n        var idIdentifiers = countIdIdentifiers(identifier),\n            classIdentifiers = countClassIdentifiers(identifier),\n            attributeIdentifiers = countAttributeIdentifiers(identifier),\n            pseudoClassIdentifiers = countPseudoClassIdentifiers(identifier),\n            typeIdentifiers = countTypeIdentifiers(identifier),\n            pseudoElementIdentifiers = countPseudoElementIdentifiers(identifier);\n\n        totalSpecificity += Number(\n            String(idIdentifiers) +\n            String(classIdentifiers + attributeIdentifiers + pseudoClassIdentifiers) +\n            String(typeIdentifiers + pseudoElementIdentifiers));\n    });\n\n    return totalSpecificity;\n}\n\nvar countIdIdentifiers = function (identifier) {\n    var regex = /#/,\n        matches = regex.exec(identifier);\n\n    if (matches && !countAttributeIdentifiers(identifier)) {\n        return matches.length;\n    }\n\n    return 0;\n};\n\nvar countClassIdentifiers = function (identifier) {\n    var regex = /\\./,\n        matches = regex.exec(identifier);\n\n    if (matches) {\n        return matches.length;\n    }\n\n    return 0;\n};\n\nvar countAttributeIdentifiers = function (identifier) {\n    var regex = /\\[/,\n        matches = regex.exec(identifier);\n\n    if (matches) {\n        return matches.length;\n    }\n\n    return 0;\n};\n\nvar countPseudoClassIdentifiers = function  (identifier) {\n    var regex = /^:[^:]/,\n        matches = regex.exec(identifier);\n\n    // :not pseudo-class identifier itself is ignored\n    // only selectors inside it are counted\n    if (identifier.match(/:not/)) {\n        return 0;\n    }\n\n    if (matches) {\n        return matches.length;\n    }\n\n    return 0;\n};\n\nvar countTypeIdentifiers = function (identifier) {\n    var regex = /^[a-zA-Z_]/;\n\n    if (regex.exec(identifier)) {\n        return 1;\n    }\n\n    return 0;\n};\n\nvar countPseudoElementIdentifiers = function (identifier) {\n    var regex = /::/,\n        matches = regex.exec(identifier);\n\n    if (matches) {\n        return matches.length;\n    }\n\n    return 0;\n};\n\nvar stripNotIdentifier = function (identifier) {\n    if (identifier.match(/:not/)) {\n        return identifier.replace(/:not\\(|\\)/g, '');\n    }\n\n    return identifier;\n};\n"
  },
  {
    "path": "lib/CliController.js",
    "content": "/*! Parker v0.0.0 - MIT license */\n\n'use strict';\n\nvar util = require('util'),\n    events = require('events');\n\nfunction CliController() {\n    events.EventEmitter.call(this);\n}\n\nutil.inherits(CliController, events.EventEmitter);\n\nCliController.prototype.dispatch = function (argv) {\n    if (argv.v || argv.version) {\n        this.emit('showVersion');\n    }\n    if (argv.h || argv.help) {\n        this.emit('showHelp');\n    }\n    if (argv.f || argv.format) {\n        var format = argv.f || argv.format;\n        this.emit('setFormat', format);\n    }\n    if (argv.n || argv.numeric) {\n        this.emit('showNumericOnly');\n    }\n    if (argv._ && argv._.length) {\n        this.emit('runPaths', argv._);\n    }\n    else if (argv.s || argv.stdin) {\n        this.emit('runStdin');\n    }\n    else {\n        // No data supplied - show help\n        this.emit('showHelp');\n    }\n};\n\nmodule.exports = CliController;"
  },
  {
    "path": "lib/CliFormatter.js",
    "content": "/*! Parker v0.0.0 - MIT license */\n\n'use strict';\n\nvar _ = require('lodash');\n\nfunction CliFormatter() {\n\n}\n\nCliFormatter.prototype.format = function (data, metrics) {\n\tvar output = '';\n    _.each(metrics, function(metric) {\n        output += metric.name + \": \" + data[metric.id];\n        output += \"\\n\";\n    });\n\n\treturn output;\n};\n\nmodule.exports = CliFormatter;\n"
  },
  {
    "path": "lib/CssDeclaration.js",
    "content": "/*! Parker v0.0.0 - MIT license */\n\n'use strict';\n\nfunction CssDeclaration(raw) {\n\n    this.raw = raw;\n}\n\nCssDeclaration.prototype.getProperty = function () {\n    if (this.raw.indexOf(':') === -1) {\n        return '';\n    }\n\n    return this.raw.split(':')[0].trim();\n};\n\nCssDeclaration.prototype.getValue = function () {\n    if (this.raw.indexOf(':') === -1) {\n        return '';\n    }\n\n    return this.raw.split(':')[1].trim();\n};\n\nmodule.exports = CssDeclaration;"
  },
  {
    "path": "lib/CssMediaQuery.js",
    "content": "/*! Parker v0.0.0 - MIT license */\n\n'use strict';\n\nfunction CssMediaQuery(raw) {\n\tthis.raw = raw;\n}\n\nCssMediaQuery.prototype.getQueries = function () {\n\tvar pattern = /@media\\w*(.+?)\\s?{/,\n\t\tqueries = pattern.exec(this.raw)[1];\n\n\treturn queries.split(/ or |,/g).map(trimQuery);\n};\n\nCssMediaQuery.prototype.getRules = function () {\n    var rules = [],\n        depth = 0,\n        rule = '';\n\n    for (var index = 0; index < this.raw.length; index++) {\n    \tif (depth > 0) {\n\t        rule += this.raw.charAt(index);\n\t    }\n        if (this.raw.charAt(index) === '{') {\n            depth ++;\n        }\n        else if (this.raw.charAt(index) == '}') {\n            depth --;\n        }\n\n        if (depth === 1 && this.raw.charAt(index) == '}') {\n            rules.push(rule.trim());\n            rule = '';\n        }\n    }\n    return rules;\n};\n\nvar trimQuery = function (query) {\n\treturn query.trim();\n};\n\nmodule.exports = CssMediaQuery;"
  },
  {
    "path": "lib/CssRule.js",
    "content": "/*! Parker v0.0.0 - MIT license */\n\n'use strict';\n\nvar _ = require('lodash');\n\nfunction CssRule(raw) {\n    this.raw = raw;\n}\n\nCssRule.prototype.getSelectors = function () {\n    return getSelectors(getSelectorBlock(this.raw));\n};\n\nCssRule.prototype.getDeclarations = function () {\n    return getDeclarations(getDeclarationBlock(this.raw));\n};\n\nvar getSelectorBlock = function (rule) {\n    var pattern = /([^{]+)\\{/g,\n        results = pattern.exec(rule);\n\n    return results[1];\n};\n\nvar getSelectors = function (selectorBlock) {\n    var untrimmedSelectors = selectorBlock.split(','),\n        trimmedSelectors = untrimmedSelectors.map(function (untrimmed) {\n            return untrimmed.trim();\n        });\n\n    return _.compact(trimmedSelectors);\n};\n\nvar getDeclarationBlock = function (rule) {\n    var pattern = /\\{(.+)\\}/g,\n        results = pattern.exec(rule);\n\n    if (_.isNull(results)) {\n        return '';\n    }\n\n    return results[1];\n};\n\nvar getDeclarations = function (declarationBlock) {\n    var untrimmedDeclarations = _.compact(declarationBlock.trim().split(';')),\n        trimmedDeclarations = untrimmedDeclarations.map(function (untrimmed) {\n            return untrimmed.trim();\n        });\n\n    return trimmedDeclarations;\n};\n\nmodule.exports = CssRule;\n"
  },
  {
    "path": "lib/CssSelector.js",
    "content": "/*! Parker v0.1.0 - MIT license */\n\n'use strict';\n\nvar _ = require('lodash'),\n    DELIMITERS = ['.', '#', '>', '[', ' ', ':', '*'];\n\nfunction CssSelector(raw) {\n    this.raw = raw;\n    this.identifiers = [];\n}\n\nCssSelector.prototype.getIdentifiers = function () {\n    var identifier = '',\n        bracketDepth = 0,\n        parenDepth = 0;\n\n    _.each(this.raw, function (character, index) {\n        var insideBrackets = bracketDepth || parenDepth,\n            isSecondColon = character == ':' && this.raw[index - 1] == ':';\n\n        if (!insideBrackets && isDelimiter(character) && !isSecondColon) {\n            this.addIdentifier(identifier);\n            identifier = '';\n        }\n\n        switch(character) {\n            case '(': parenDepth++; break;\n            case ')': parenDepth--; break;\n            case '[': bracketDepth++; break;\n            case ']': bracketDepth--; break;\n        }\n\n        if (!_.contains([' ', '>'], character)) {\n            identifier += character;\n        }\n    }, this);\n\n    this.addIdentifier(identifier);\n    return _.without(this.identifiers, ' ', '', '[]');\n}\n\nCssSelector.prototype.addIdentifier = function (identifier) {\n    this.identifiers.push(identifier);\n};\n\nfunction isDelimiter(character) {\n    return _.contains(DELIMITERS, character)\n}\n\nmodule.exports = CssSelector;\n"
  },
  {
    "path": "lib/CssStylesheet.js",
    "content": "/*! Parker v0.0.0 - MIT license */\n\n'use strict';\n\nvar _ = require('lodash');\n\nfunction CssStylesheet(raw) {\n    this.raw = raw;\n}\n\nCssStylesheet.prototype.getRules = function () {\n    this.children = this.children || getChildren(this.raw);\n\n    return this.children.filter(function (child) {\n        return isRule(child);\n    });\n};\n\nCssStylesheet.prototype.getMalformedStatements = function () {\n    this.children = this.children || getChildren(this.raw);\n\n    return this.children.filter(function (child) {\n        return isMalformedStatement(child);\n    });\n};\n\nCssStylesheet.prototype.getMediaQueries = function () {\n    this.children = this.children || getChildren(this.raw);\n    return this.children.filter(function (child) {\n        return isMediaQuery(child);\n    });\n};\n\nvar getChildren = function (raw) {\n    var children = [],\n        depth = 0,\n        child = '',\n        stylesheet = stripComments(stripFormatting(raw));\n\n    for (var index = 0; index < stylesheet.length; index++) {\n        child += stylesheet.charAt(index);\n        if (stylesheet.charAt(index) === '{') {\n            depth ++;\n        }\n        else if (stylesheet.charAt(index) == '}') {\n            depth --;\n        }\n\n        if (depth === 0 && stylesheet.charAt(index).match(/\\}|;/g)) {\n            children.push(child.trim());\n            child = '';\n        }\n    }\n    return children;\n};\n\nvar stripComments = function (string) {\n    return string.replace(/\\/\\*.+?\\*\\//g, '');\n};\n\nvar stripFormatting = function (string) {\n    return stripNewlines(trimWhitespace(string));\n};\n\nvar trimWhitespace = function (string) {\n    return string.replace(/[ ]+/g, ' ');\n};\n\nvar stripNewlines = function (string) {\n    return string.replace(/\\n|\\r|\\r\\n/g, '');\n};\n\nvar isRule = function (string) {\n    return !isMediaQuery(string) && hasRuleBlock(string) && hasSelectorBlock(string);\n}\n\nvar isMalformedStatement = function (string) {\n    return !isRule(string) && !isMediaQuery(string);\n}\n\nvar hasRuleBlock = function (string) {\n    return string.indexOf('{') !== -1 && string.indexOf('}') !== -1;\n}\n\nvar hasSelectorBlock = function (string) {\n    return string.match(/^[^\\{]+/g)\n}\n\nvar isMediaQuery = function (string) {\n    return string.match(/^@media/g);\n}\n\nmodule.exports = CssStylesheet;\n"
  },
  {
    "path": "lib/Formatters.js",
    "content": "/*! Parker v0.0.0 - MIT license */\n\n'use strict';\n\nvar _ = require('lodash'),\n    clc = require('cli-color');\n\n\n// formats output as human-friendly text\nexports.human = function (metrics, results) {\n    var logo = clc.red('PA') + clc.yellow('RK') + clc.green('ER') + '-JS' + \"\\n\";\n    return logo + _.reduce(metrics, function (str, metric) {\n        return str + metric.name + ': ' + results[metric.id] + '\\n';\n    }, '');\n};\n\n// formats output as JSON\nexports.json = function (metrics, results) {\n    var ids = _.map(metrics, function (metric) {\n        return metric.id;\n    });\n    var obj = _.reduce(ids, function (obj, id) {\n        obj[id] = results[id];\n        return obj;\n    }, {});\n    return JSON.stringify(obj, null, 4);\n};\n\nexports.csv = function (metrics, results) {\n    var lineItems = [];\n    _.each(metrics, function (metric) {\n        lineItems.push('\"' + results[metric.id] + '\"');\n    });\n\n    return lineItems.join(',');\n}\n"
  },
  {
    "path": "lib/Info.js",
    "content": "/*! Parker v0.0.0 - MIT license */\n\n'use strict';\n\nvar pkg = require('../package.json');\n\nmodule.exports = {\n    version: function() {\n        console.log(pkg.name + ' v' + pkg.version);\n    },\n    help: function() {\n        module.exports.version();\n\n        [\n            pkg.description,\n            '',\n            'Usage:',\n            'parker [arguments] [file...] Run Parker on specified files',\n            '',\n            'Example Local Usage:',\n            'parker styles.css',\n            '',\n            'Example Stdin Usage:',\n            'curl http://www.katiefenn.co.uk/css/shuttle.css -s | parker -s',\n            '',\n            'Arguments:',\n            '',\n            '-f                  Set output format (see list of formats)',\n            '-h                  Shows help',\n            '-n                  Show numeric results only',\n            '-s                  Input CSS using stdin',\n            '-v                  Show version number of Parker',\n            '',\n            'Formats Usage:',\n            'parker -f \"human\"',\n            '',\n            'Formats List:',\n            'human               Human-readable, newline separated format (default)',\n            'json                JSON',\n            'csv                 CSV',\n            '',\n            'For more information, see ' + pkg.homepage\n        ].forEach(function(str) { console.log(str); });\n    }\n};\n"
  },
  {
    "path": "lib/Parker.js",
    "content": "/*! Parker v0.0.0 - MIT license */\n\n'use strict';\n\nvar _ = require('lodash'),\n    CssStylesheet = require('./CssStylesheet.js'),\n    CssRule = require('./CssRule.js'),\n    CssSelector = require('./CssSelector.js'),\n    CssDeclaration = require('./CssDeclaration.js'),\n    CssMediaQuery = require('./CssMediaQuery.js');\n\nvar VALID_METRIC_TYPE = /stylesheet|rule|selector|identifier|declaration|property|value|mediaquery/g;\n\nfunction Parker(metrics) {\n    this.metrics = metrics;\n}\n\nParker.prototype.run = function () {\n    var args = arguments;\n\n    if (arguments.length === 1 && _.isArray(arguments[0])) {\n        args = arguments[0];\n    }\n\n    args = _.filter(args, function (argument) {return _.isString(argument); });\n    var metrics = _.filter(this.metrics, function (metric) {return metric.type.match(VALID_METRIC_TYPE); });\n\n    if (args.length > 0) {\n        return runMetrics(metrics, args);\n    }\n\n    throw {'message': 'No valid stylesheet data supplied', 'name': 'DataTypeException'};\n};\n\nvar runMetrics = function (metrics, stylesheets) {\n    var readings = [];\n\n    _.each(stylesheets, function (rawStylesheet) {\n        readings.push(runMetricsOnNode(metrics, rawStylesheet, 'stylesheet'));\n\n        var stylesheet = new CssStylesheet(rawStylesheet),\n            rules = stylesheet.getRules() || [];\n\n        _.each(stylesheet.getMediaQueries(), function (rawMediaQuery) {\n            var mediaQuery = new CssMediaQuery(rawMediaQuery);\n            _.each(mediaQuery.getQueries(), function (query) {\n                readings.push(runMetricsOnNode(metrics, query, 'mediaquery'));\n            });\n\n            rules = rules.concat(mediaQuery.getRules());\n        });\n\n        _.each(rules, function (rawRule) {\n            readings.push(runMetricsOnNode(metrics, rawRule, 'rule'));\n\n            var rule = new CssRule(rawRule);\n            _.each(rule.getSelectors(), function (rawSelector) {\n                var selector = new CssSelector(rawSelector);\n                readings.push(runMetricsOnNode(metrics, rawSelector, 'selector'));\n\n                _.each(selector.getIdentifiers(), function (rawIdentifier) {\n                    readings.push(runMetricsOnNode(metrics, rawIdentifier, 'identifier'));\n                });\n            });\n\n            _.each(rule.getDeclarations(), function (rawDeclaration) {\n                var declaration = new CssDeclaration(rawDeclaration);\n\n                readings.push(runMetricsOnNode(metrics, rawDeclaration, 'declaration'));\n                readings.push(runMetricsOnNode(metrics, declaration.getProperty(), 'property'));\n                readings.push(runMetricsOnNode(metrics, declaration.getValue(), 'value'));\n            });\n        });\n    });\n\n    var data = readings.reduce(mergeArrayAttributes);\n    data = aggregateData(data, metrics);\n\n    return data;\n};\n\nvar runMetricsOnNode = function (metrics, node, type) {\n    var data = {};\n    _.each(filterMetricsByType(metrics, type), function (metric) {\n        var measurement = metric.measure(node);\n        if (!_.isArray(measurement)) {\n            measurement = [measurement];\n        }\n\n        data[metric.id] = measurement;\n    });\n\n    return data;\n};\n\nvar aggregateData = function (data, metrics) {\n    _.each(metrics, function (metric) {\n        if (!data[metric.id]) {\n            data[metric.id] = [];\n        }\n\n        switch (metric.aggregate) {\n            case 'sum':\n                data[metric.id] = aggregateSum(data[metric.id]);\n                break;\n            case 'mean':\n                data[metric.id] = aggregateMean(data[metric.id]);\n                break;\n            case 'max':\n                data[metric.id] = aggregateMax(data[metric.id], metric.iterator);\n                break;\n            case 'list':\n                data[metric.id] = aggregateList(data[metric.id], metric.filter);\n                break;\n            case 'length':\n                data[metric.id] = aggregateLength(data[metric.id], metric.filter);\n                break;\n            case 'reduce':\n                data[metric.id] = aggregateReduce(data[metric.id], metric.reduce, metric.initial);\n                break;\n        }\n    });\n\n    return data;\n};\n\nvar aggregateSum = function (data) {\n    return sum(data);\n};\n\nvar aggregateMean = function (data) {\n    if (data.length === 0) {\n        return 0;\n    }\n    return mean(data);\n};\n\nvar aggregateMax = function (data, iterator) {\n    if (data.length === 0) {\n        return 0;\n    }\n    if (_.isUndefined(iterator)) {\n        return _.max(data);\n    }\n\n    return _.max(data, iterator);\n};\n\nvar aggregateList = function (data, filter) {\n    if (!_.isUndefined(filter)) {\n        return _.compact(data.filter(filter));\n    }\n\n    return _.compact(data);\n};\n\nvar aggregateLength = function (data, filter) {\n    if (!_.isUndefined(filter)) {\n        return data.filter(filter).length;\n    }\n\n    return _.compact(data).length;\n};\n\nvar aggregateReduce = function (data, reduce, initial) {\n    return data.reduce(reduce, initial);\n};\n\nvar mergeArrayAttributes = function (target, source) {\n    _.each(source, function (attribute, attributeName) {\n        if  (!_.has(target, attributeName)) {\n            target[attributeName] = [];\n        }\n\n        if (!_.isUndefined(attribute)) {\n            if (_.isString(attribute)) {\n                attribute = [attribute];\n            }\n\n            target[attributeName] = target[attributeName].concat(attribute);\n        }\n    });\n\n    return target;\n};\n\nvar sum = function (values) {\n    if (values.length === 0) {\n        return 0;\n    }\n    return values.reduce(function (previous, current) {return previous + current; });\n};\n\nvar mean = function (values) {\n    var valuesSum = sum(values);\n\n    return valuesSum / values.length;\n};\n\nvar filterMetricsByType = function (metrics, type) {\n    if (type) {\n        return metrics.filter(function (metric) {return metric.type === type; });\n    }\n\n    return metrics;\n};\n\nmodule.exports = Parker;\n"
  },
  {
    "path": "lib/PreciseSelectorSpecificity.js",
    "content": "/*! Parker v0.0.0 - MIT license */\n\n'use strict';\n\nvar CssSelector = require('../lib/CssSelector');\nvar _ = require('lodash');\n\nvar CLASS_A = 1;\nvar CLASS_B = 256;\nvar CLASS_C = 65536;\n\nmodule.exports = function (rawSelector) {\n    var totalSpecificity = 0,\n        selector = new CssSelector(rawSelector);\n\n    _.each(selector.getIdentifiers(), function (identifier) {\n        var idIdentifiers = countIdIdentifiers(identifier),\n            classIdentifiers = countClassIdentifiers(identifier),\n            attributeIdentifiers = countAttributeIdentifiers(identifier),\n            pseudoClassIdentifiers = countPseudoClassIdentifiers(identifier),\n            typeIdentifiers = countTypeIdentifiers(identifier),\n            pseudoElementIdentifiers = countPseudoElementIdentifiers(identifier);\n\n        totalSpecificity += Number(\n            (idIdentifiers * CLASS_C) +\n            ((classIdentifiers + attributeIdentifiers + pseudoClassIdentifiers) * CLASS_B) +\n            ((typeIdentifiers + pseudoElementIdentifiers) * CLASS_A));\n    });\n\n    return totalSpecificity;\n}\n\nvar countIdIdentifiers = function (identifier) {\n    var regex = /#/,\n        matches = regex.exec(identifier);\n\n    if (matches && !countAttributeIdentifiers(identifier)) {\n        return matches.length;\n    }\n\n    return 0;\n};\n\nvar countClassIdentifiers = function (identifier) {\n    var regex = /\\./,\n        matches = regex.exec(identifier);\n\n    if (matches) {\n        return matches.length;\n    }\n\n    return 0;\n};\n\nvar countAttributeIdentifiers = function (identifier) {\n    var regex = /\\[/,\n        matches = regex.exec(identifier);\n\n    if (matches) {\n        return matches.length;\n    }\n\n    return 0;\n};\n\nvar countPseudoClassIdentifiers = function  (identifier) {\n    var regex = /^:[^:]/,\n        matches = regex.exec(identifier);\n\n    // :not pseudo-class identifier itself is ignored\n    // only selectors inside it are counted\n    if (identifier.match(/:not/)) {\n        return 0;\n    }\n\n    if (matches) {\n        return matches.length;\n    }\n\n    return 0;\n};\n\nvar countTypeIdentifiers = function (identifier) {\n    var regex = /^[a-zA-Z_]/;\n\n    if (regex.exec(identifier)) {\n        return 1;\n    }\n\n    return 0;\n};\n\nvar countPseudoElementIdentifiers = function (identifier) {\n    var regex = /::/,\n        matches = regex.exec(identifier);\n\n    if (matches) {\n        return matches.length;\n    }\n\n    return 0;\n};\n\nvar stripNotIdentifier = function (identifier) {\n    if (identifier.match(/:not/)) {\n        return identifier.replace(/:not\\(|\\)/g, '');\n    }\n\n    return identifier;\n};\n"
  },
  {
    "path": "metrics/All.js",
    "content": "/*! Parker v0.0.0 - MIT license */\n\n'use strict';\n\nmodule.exports = [\n    // Stylesheet Totals\n    require('./TotalStylesheets.js'),\n    require('./TotalStylesheetSize.js'),\n\n    // Stylesheet Element Totals\n    require('./TotalRules.js'),\n    require('./TotalSelectors.js'),\n    require('./TotalIdentifiers.js'),\n    require('./TotalDeclarations.js'),\n\n    // Stylesheet Element Averages\n    require('./SelectorsPerRule.js'),\n    require('./IdentifiersPerSelector.js'),\n    require('./DeclarationsPerRule.js'),\n\n    // Specificity\n    require('./SpecificityPerSelector.js'),\n    require('./PreciseSpecificityPerSelector.js'),\n    require('./TopSelectorSpecificity.js'),\n    require('./PreciseTopSelectorSpecificity.js'),\n    require('./StringTopSelectorSpecificity.js'),\n    require('./TopSelectorSpecificitySelector.js'),\n    require('./TotalIdSelectors.js'),\n\n    // Colour\n    require('./TotalUniqueColours.js'),\n    require('./UniqueColours.js'),\n\n    // Important Keywords\n    require('./TotalImportantKeywords.js'),\n\n    // Media Queries\n    require('./TotalMediaQueries.js'),\n    require('./MediaQueries.js'),\n\n    // Z-Index\n    require('./ZIndexes.js')\n];\n"
  },
  {
    "path": "metrics/DeclarationsPerRule.js",
    "content": "'use strict';\n\nvar CssRule = require('../lib/CssRule');\n\nvar _ = require('lodash');\nmodule.exports = {\n    id: 'declarations-per-rule',\n    name: 'Declarations Per Rule',\n    type: 'rule',\n    aggregate: 'mean',\n    format: 'number',\n    measure: function (raw) {\n        var rule = new CssRule(raw);\n        return rule.getDeclarations().length;\n    }\n};\n"
  },
  {
    "path": "metrics/IdentifiersPerSelector.js",
    "content": "/*! Parker v0.0.0 - MIT license */\n\n'use strict';\n\nvar _ = require('lodash');\n\nmodule.exports = {\n    id: 'identifiers-per-selector',\n    name: 'Identifiers Per Selector',\n    type: 'selector',\n    aggregate: 'mean',\n    format: 'number',\n    measure: function (selector) {\n        var identifiers = getIdentifiers(selector);\n\n        if (identifiers.length === 1 && identifiers[0] === '') {\n            return 0;\n        }\n\n        return identifiers.length;\n    }\n};\n\nvar getIdentifiers = function (selector) {\n    var identifiers = [],\n        segments = selector.split(/\\s+[\\s\\+>]\\s?|~^=/g);\n\n    _.each(segments, function (segment) {\n        identifiers = identifiers.concat(segment.match(/[#\\.:]?[\\w\\-\\*]+|\\[[\\w=\\-~'\"\\|]+\\]|:{2}[\\w-]+/g) || []);\n    });\n\n    return identifiers;\n};"
  },
  {
    "path": "metrics/MediaQueries.js",
    "content": "/*! Parker v0.0.0 - MIT license */\n\n'use strict';\n\nvar _ = require('lodash');\n\nmodule.exports = {\n    id: 'media-queries',\n    name: 'Media Queries',\n    type: 'mediaquery',\n    aggregate: 'list',\n    format: 'list',\n    measure: function (query) {\n        return query;\n    },\n    filter: function (value, index, self) {\n        return self.indexOf(value) === index;\n    }\n};"
  },
  {
    "path": "metrics/PreciseSpecificityPerSelector.js",
    "content": "/*! Parker v0.0.0 - MIT license */\n\n'use strict';\n\nvar _ = require('lodash');\nvar CssSelector = require('../lib/CssSelector');\nvar getSpecificity = require('../lib/PreciseSelectorSpecificity');\n\nmodule.exports = {\n    id: 'precise-specificity-per-selector',\n    name: 'Specificity Per Selector (Precise)',\n    type: 'selector',\n    aggregate: 'mean',\n    format: 'number',\n    measure: getSpecificity\n};\n"
  },
  {
    "path": "metrics/PreciseTopSelectorSpecificity.js",
    "content": "/*! Parker v0.0.0 - MIT license */\n\n'use strict';\n\nvar _ = require('lodash');\nvar CssSelector = require('../lib/CssSelector');\nvar getSpecificity = require('../lib/PreciseSelectorSpecificity');\n\nmodule.exports = {\n    id: 'precise-top-selector-specificity',\n    name: 'Top Selector Specificity (Precise)',\n    type: 'selector',\n    aggregate: 'max',\n    format: 'number',\n    measure: getSpecificity\n};\n"
  },
  {
    "path": "metrics/SelectorsPerRule.js",
    "content": "/*! Parker v0.0.0 - MIT license */\n\n'use strict';\n\nmodule.exports = {\n    id: 'selectors-per-rule',\n    name: 'Selectors Per Rule',\n    type: 'rule',\n    aggregate: 'mean',\n    format: 'number',\n    measure: function (rule) {\n        return getSelectors(getSelectorBlock(rule)).length;\n    }\n};\n\nvar getSelectorBlock = function (rule) {\n    var pattern = /([^{]+)\\{/g,\n        results = pattern.exec(rule);\n\n    return results[1];\n};\n\nvar getSelectors = function (selectorBlock) {\n    var untrimmedSelectors = selectorBlock.split(','),\n        trimmedSelectors = untrimmedSelectors.map(function (untrimmed) {\n            return untrimmed.trim();\n        });\n\n    return trimmedSelectors;\n};"
  },
  {
    "path": "metrics/SpecificityPerSelector.js",
    "content": "/*! Parker v0.0.0 - MIT license */\n\n'use strict';\n\nvar _ = require('lodash');\nvar CssSelector = require('../lib/CssSelector');\nvar getSpecificity = require('../lib/ClassicalSelectorSpecificity');\n\nmodule.exports = {\n    id: 'specificity-per-selector',\n    name: 'Specificity Per Selector (Classical)',\n    type: 'selector',\n    aggregate: 'mean',\n    format: 'number',\n    measure: getSpecificity\n};\n"
  },
  {
    "path": "metrics/StringTopSelectorSpecificity.js",
    "content": "/*! Parker v0.0.0 - MIT license */\n\n'use strict';\n\nvar _ = require('lodash');\nvar CssSelector = require('../lib/CssSelector');\nvar getSpecificity = require('../lib/ArraySelectorSpecificity');\n\nmodule.exports = {\n    id: 'string-top-selector-specificity',\n    name: 'Top Selector Specificity (String)',\n    type: 'selector',\n    aggregate: 'reduce',\n    format: 'string',\n    initial: '0,0,0',\n    measure: function(selector) {\n        return selector;\n    },\n    reduce: function(previous, current) {\n        var previousSpecificity = fromString(previous);\n        var currentSpecificity = getSpecificity(current);\n\n        return toString(mostSpecific(previousSpecificity, currentSpecificity));\n    }\n};\n\nfunction toString(arr) {\n    return arr.map(function(item) {\n        return item.toString();\n    }).join(',');\n}\n\nfunction fromString(str) {\n    return str.split(',').map(function(item) {\n      return parseInt(item);\n    });\n}\n\nfunction mostSpecific(arr1, arr2) {\n    var arr1Specificity = (arr1[0] * 65536) + (arr1[1] * 256) + (arr1[2] * 1);\n    var arr2Specificity = (arr2[0] * 65536) + (arr2[1] * 256) + (arr2[2] * 1);\n\n    if (arr1Specificity > arr2Specificity) {\n      return arr1;\n    }\n\n    return arr2;\n}\n"
  },
  {
    "path": "metrics/TopSelectorSpecificity.js",
    "content": "/*! Parker v0.0.0 - MIT license */\n\n'use strict';\n\nvar _ = require('lodash');\nvar CssSelector = require('../lib/CssSelector');\n\nmodule.exports = {\n    id: 'top-selector-specificity',\n    name: 'Top Selector Specificity (Classical)',\n    type: 'selector',\n    aggregate: 'max',\n    format: 'number',\n    measure: function (rawSelector) {\n        var selector = new CssSelector(rawSelector),\n            identifiers = selector.getIdentifiers(),\n            specificity = 0;\n\n        _.each(identifiers, function (identifier) {\n            identifier = stripNotIdentifier(identifier);\n\n            var idIdentifiers = countIdIdentifiers(identifier),\n                classIdentifiers = countClassIdentifiers(identifier),\n                attributeIdentifiers = countAttributeIdentifiers(identifier),\n                pseudoClassIdentifiers = countPseudoClassIdentifiers(identifier),\n                typeIdentifiers = countTypeIdentifiers(identifier),\n                pseudoElementIdentifiers = countPseudoElementIdentifiers(identifier);\n\n            specificity += getSpecificity(idIdentifiers, classIdentifiers, attributeIdentifiers, pseudoClassIdentifiers, typeIdentifiers, pseudoElementIdentifiers);\n\n        }, this);\n\n        return specificity;\n    }\n};\n\nvar getSpecificity = function (idIdentifiers, classIdentifiers, attributeIdentifiers, pseudoClassIdentifiers, typeIdentifiers, pseudoElementIdentifiers) {\n    return Number(\n        String(idIdentifiers) +\n        String(classIdentifiers + attributeIdentifiers + pseudoClassIdentifiers) +\n        String(typeIdentifiers + pseudoElementIdentifiers)\n    );\n};\n\nvar countIdIdentifiers = function (identifier) {\n    var regex = /#/,\n        matches = regex.exec(identifier);\n\n    if (matches && !countAttributeIdentifiers(identifier)) {\n        return matches.length;\n    }\n\n    return 0;\n};\n\nvar countClassIdentifiers = function (identifier) {\n    var regex = /\\./,\n        matches = regex.exec(identifier);\n\n    if (matches) {\n        return matches.length;\n    }\n\n    return 0;\n};\n\nvar countAttributeIdentifiers = function (identifier) {\n    var regex = /\\[/,\n        matches = regex.exec(identifier);\n\n    if (matches) {\n        return matches.length;\n    }\n\n    return 0;\n};\n\nvar countPseudoClassIdentifiers = function  (identifier) {\n    var regex = /^:[^:]/,\n        matches = regex.exec(identifier);\n\n    // :not pseudo-class identifier itself is ignored\n    // only selectors inside it are counted\n    if (identifier.match(/:not/)) {\n        return 0;\n    }\n\n    if (matches) {\n        return matches.length;\n    }\n\n    return 0;\n};\n\nvar countTypeIdentifiers = function (identifier) {\n    var regex = /^[a-zA-Z_]/;\n\n    if (regex.exec(identifier)) {\n        return 1;\n    }\n\n    return 0;\n};\n\nvar countPseudoElementIdentifiers = function (identifier) {\n    var regex = /::/,\n        matches = regex.exec(identifier);\n\n    if (matches) {\n        return matches.length;\n    }\n\n    return 0;\n};\n\nvar stripNotIdentifier = function (identifier) {\n    if (identifier.match(/:not/)) {\n        return identifier.replace(/:not\\(|\\)/g, '');\n    }\n\n    return identifier;\n};\n"
  },
  {
    "path": "metrics/TopSelectorSpecificitySelector.js",
    "content": "/*! Parker v0.0.0 - MIT license */\n\n'use strict';\n\nvar _ = require('lodash');\nvar CssSelector = require('../lib/CssSelector');\nvar getSpecificity = require('../lib/PreciseSelectorSpecificity');\n\nmodule.exports = {\n    id: 'top-selector-specificity-selector',\n    name: 'Top Selector Specificity Selector',\n    type: 'selector',\n    aggregate: 'max',\n    format: 'string',\n    measure: function(selector) {\n        return selector;\n    },\n    iterator: getSpecificity\n};\n\nvar getSpecificity = function (idIdentifiers, classIdentifiers, attributeIdentifiers, pseudoClassIdentifiers, typeIdentifiers, pseudoElementIdentifiers) {\n    return Number(\n        String(idIdentifiers) +\n        String(classIdentifiers + attributeIdentifiers + pseudoClassIdentifiers) +\n        String(typeIdentifiers + pseudoElementIdentifiers)\n    );\n};\n\nvar countIdIdentifiers = function (identifier) {\n    var regex = /#/,\n        matches = regex.exec(identifier);\n\n    if (matches && !countAttributeIdentifiers(identifier)) {\n        return matches.length;\n    }\n\n    return 0;\n};\n\nvar countClassIdentifiers = function (identifier) {\n    var regex = /\\./,\n        matches = regex.exec(identifier);\n\n    if (matches) {\n        return matches.length;\n    }\n\n    return 0;\n};\n\nvar countAttributeIdentifiers = function (identifier) {\n    var regex = /\\[/,\n        matches = regex.exec(identifier);\n\n    if (matches) {\n        return matches.length;\n    }\n\n    return 0;\n};\n\nvar countPseudoClassIdentifiers = function  (identifier) {\n    var regex = /^:[^:]/,\n        matches = regex.exec(identifier);\n\n    // :not pseudo-class identifier itself is ignored\n    // only selectors inside it are counted\n    if (identifier.match(/:not/)) {\n        return 0;\n    }\n\n    if (matches) {\n        return matches.length;\n    }\n\n    return 0;\n};\n\nvar countTypeIdentifiers = function (identifier) {\n    var regex = /^[a-zA-Z_]/;\n\n    if (regex.exec(identifier)) {\n        return 1;\n    }\n\n    return 0;\n};\n\nvar countPseudoElementIdentifiers = function (identifier) {\n    var regex = /::/,\n        matches = regex.exec(identifier);\n\n    if (matches) {\n        return matches.length;\n    }\n\n    return 0;\n};\n\nvar stripNotIdentifier = function (identifier) {\n    if (identifier.match(/:not/)) {\n        return identifier.replace(/:not\\(|\\)/g, '');\n    }\n\n    return identifier;\n};\n"
  },
  {
    "path": "metrics/TotalDeclarations.js",
    "content": "/*! Parker v0.0.0 - MIT license */\n\n'use strict';\n\nmodule.exports = {\n    id: 'total-declarations',\n    name: 'Total Declarations',\n    type: 'declaration',\n    aggregate: 'sum',\n    format: 'number',\n    measure: function (declaration) {\n        return 1;\n    }\n};"
  },
  {
    "path": "metrics/TotalIdSelectors.js",
    "content": "\n/*! Parker v0.0.0 - MIT license */\n\n'use strict';\n\nvar _ = require('lodash');\n\nmodule.exports = {\n    id: 'total-id-selectors',\n    name: 'Total Id Selectors',\n    type: 'selector',\n    aggregate: 'sum',\n    format: 'number',\n    measure: function (selector) {\n\t\tvar ids = 0;\n\t\tvar inBrackets = false;\n\n\t\t_.forOwn(selector, function (char) {\n\t\t\tif (char === '[') {\n\t\t\t\tinBrackets = true;\n\t\t\t} else if (char === ']') {\n\t\t\t\tinBrackets = false;\n\t\t\t} else if (char === '#' && !inBrackets) {\n\t\t\t\tids++;\n\t\t\t}\n\t\t});\n\n\t\treturn ids;\n    }\n};\n"
  },
  {
    "path": "metrics/TotalIdentifiers.js",
    "content": "/*! Parker v0.0.0 - MIT license */\n\n'use strict';\n\nvar _ = require('lodash');\n\nmodule.exports = {\n    id: 'total-identifiers',\n    name: 'Total Identifiers',\n    type: 'identifier',\n    aggregate: 'sum',\n    format: 'number',\n    measure: function (identifier) {\n        return 1;\n    }\n};"
  },
  {
    "path": "metrics/TotalImportantKeywords.js",
    "content": "/*! Parker v0.0.0 - MIT license */\n\n'use strict';\n\nvar _ = require('lodash');\n\nmodule.exports = {\n    id: 'total-important-keywords',\n    name: 'Total Important Keywords',\n    type: 'value',\n    aggregate: 'sum',\n    format: 'number',\n    measure: function (value) {\n        if (value.match(/!important/g))\n            return 1;\n        return 0;\n    }\n};\n"
  },
  {
    "path": "metrics/TotalMediaQueries.js",
    "content": "/*! Parker v0.0.0 - MIT license */\n\n'use strict';\n\nvar _ = require('lodash');\n\nmodule.exports = {\n    id: 'total-media-queries',\n    name: 'Total Media Queries',\n    type: 'mediaquery',\n    aggregate: 'length',\n    format: 'number',\n    measure: function (query) {\n        return query;\n    },\n    filter: function (value, index, self) {\n        return self.indexOf(value) === index;\n    }\n};"
  },
  {
    "path": "metrics/TotalRules.js",
    "content": "/*! Parker v0.0.0 - MIT license */\n\n'use strict';\n\nmodule.exports = {\n    id: 'total-rules',\n    name: 'Total Rules',\n    type: 'rule',\n    aggregate: 'sum',\n    format: 'number',\n    measure: function (rule) {\n        return 1;\n    }\n};"
  },
  {
    "path": "metrics/TotalSelectors.js",
    "content": "/*! Parker v0.0.0 - MIT license */\n\n'use strict';\n\nvar _ = require('lodash');\n\nmodule.exports = {\n    id: 'total-selectors',\n    name: 'Total Selectors',\n    type: 'selector',\n    aggregate: 'sum',\n    format: 'number',\n    measure: function (selector) {\n        return 1;\n    }\n};"
  },
  {
    "path": "metrics/TotalStylesheetSize.js",
    "content": "/*! Parker v0.0.0 - MIT license */\n\n'use strict';\n\nmodule.exports = {\n    id: 'total-stylesheet-size',\n    name: 'Total Stylesheet Size',\n    type: 'stylesheet',\n    aggregate: 'sum',\n    format: 'number',\n    measure: function (stylesheet) {\n        return byteCount(stylesheet);\n    }\n};\n\nfunction byteCount(s) {\n    return encodeURI(s).split(/%..|./).length - 1;\n}"
  },
  {
    "path": "metrics/TotalStylesheets.js",
    "content": "/*! Parker v0.0.0 - MIT license */\n\n'use strict';\n\nmodule.exports = {\n    id: 'total-stylesheets',\n    name: 'Total Stylesheets',\n    type: 'stylesheet',\n    aggregate: 'sum',\n    format: 'number',\n    measure: function (stylesheet) {\n        return 1;\n    }\n};"
  },
  {
    "path": "metrics/TotalUniqueColours.js",
    "content": "/*! Parker v0.0.0 - MIT license */\n\n'use strict';\n\nvar _ = require('lodash');\n\nmodule.exports = {\n    id: 'total-unique-colours',\n    name: 'Total Unique Colors',\n    type: 'value',\n    aggregate: 'length',\n    format: 'number',\n    measure: function (value) {\n        return getColourHexes(value).map(function (colourHex) {\n            return getLongHashForm(colourHex).toUpperCase();\n        });\n    },\n    filter: function (value, index, self) {\n        return self.indexOf(value) === index;\n    }\n};\n\nvar getColourHexes = function (value) {\n    var colourHexes = value.match(/#[0-9a-fA-F]{3,6}/g);\n\n    if (_.isNull(colourHexes)) {\n        colourHexes = [];\n    }\n\n    return colourHexes;\n};\n\nvar getLongHashForm = function (string) {\n    if (string.length === 4) {\n        var r = string.substring(1, 2),\n            g = string.substring(2, 3),\n            b = string.substring(3);\n        return '#' + r + r + g + g + b + b;\n    }\n\n    return string;\n};"
  },
  {
    "path": "metrics/UniqueColours.js",
    "content": "/*! Parker v0.0.0 - MIT license */\n\n'use strict';\n\nvar _ = require('lodash');\n\nmodule.exports = {\n    id: 'unique-colours',\n    name: 'Unique Colors',\n    type: 'value',\n    aggregate: 'list',\n    format: 'list',\n    measure: function (value) {\n        return getColourHexes(value).map(function (colourHex) {\n            return getLongHashForm(colourHex).toUpperCase();\n        });\n    },\n    filter: function (value, index, self) {\n        return self.indexOf(value) === index;\n    }\n};\n\nvar getColourHexes = function (value) {\n    var colourHexes = value.match(/#[0-9a-fA-F]{3,6}/g);\n\n    if (_.isNull(colourHexes)) {\n        colourHexes = [];\n    }\n\n    return colourHexes;\n};\n\nvar getLongHashForm = function (string) {\n    if (string.length === 4) {\n        var r = string.substring(1, 2),\n            g = string.substring(2, 3),\n            b = string.substring(3);\n        return '#' + r + r + g + g + b + b;\n    }\n\n    return string;\n};"
  },
  {
    "path": "metrics/ZIndexes.js",
    "content": "/*! Parker v0.0.0 - MIT license */\n\n'use strict';\n\nvar CssDeclaration = require('../lib/CssDeclaration');\n\nmodule.exports = {\n    id: 'z-indexes',\n    name: 'Z-Indexes',\n    type: 'declaration',\n    aggregate: 'list',\n    format: 'list',\n    measure: function (raw) {\n        var declaration = new CssDeclaration(raw);\n\n        if (declaration.getProperty() == \"z-index\") {\n          return declaration.getValue();\n        }\n    },\n    filter: function (value, index, self) {\n        return value != undefined && self.indexOf(value) === index;\n    }\n};\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"parker\",\n  \"description\": \"Stylesheet analysis tool for CSS\",\n  \"keywords\": [\n    \"css\",\n    \"stylesheet\",\n    \"analysis\"\n  ],\n  \"version\": \"1.0.0-alpha.0\",\n  \"main\": \"parker.js\",\n  \"dependencies\": {\n    \"async\": \"~0.2.10\",\n    \"cli-color\": \"*\",\n    \"graceful-fs\": \"~3.0.2\",\n    \"lodash\": \"^3.2.0\",\n    \"minimist\": \"0.0.7\"\n  },\n  \"devDependencies\": {\n    \"chai\": \"*\",\n    \"mocha\": \"*\",\n    \"sinon\": \"*\",\n    \"sinon-chai\": \"*\"\n  },\n  \"scripts\": {\n    \"test\": \"mocha --no-colors --reporter spec\"\n  },\n  \"bin\": {\n    \"parker\": \"./parker.js\"\n  },\n  \"homepage\": \"https://github.com/katiefenn/parker\",\n  \"bugs\": \"https://github.com/katiefenn/parker/issues\",\n  \"author\": \"Katie Fenn\",\n  \"repository\": \"https://github.com/katiefenn/parker\",\n  \"preferGlobal\": true,\n  \"license\": \"MIT\"\n}\n"
  },
  {
    "path": "parker.js",
    "content": "#!/usr/bin/env node\n\n/*! csstool v0.0.0 - MIT license */\n\n'use strict';\n\n/**\n * Module dependencies\n */\n\nvar _ = require('lodash'),\n    Parker = require('./lib/Parker'),\n    CliController = require('./lib/CliController'),\n    metrics = require('./metrics/All'),\n    formatters = require('./lib/Formatters'),\n    argv = require('minimist')(process.argv.slice(2)),\n    fs = require('graceful-fs'),\n    async = require('async'),\n    path = require('path'),\n    info = require('./lib/Info');\n\nvar cliController = new CliController();\n\ncliController.on('runPaths', function (filePaths) {\n    var stylesheets = [];\n    async.each(filePaths, function (filePath, onAllLoad) {\n        var onFileLoad = function (err, data) {\n            stylesheets.push(data);\n        };\n        read(filePath, onFileLoad, onAllLoad);\n    }, function (err) {\n        runReport(stylesheets, metrics);\n    });\n});\n\ncliController.on('runStdin', function () {\n    process.stdin.resume();\n    process.stdin.setEncoding('utf8');\n    var stdinData = '';\n\n    process.stdin.on('data', function(chunk) {\n        stdinData += chunk;\n    });\n\n    process.stdin.on('end', function() {\n        runReport(stdinData, metrics);\n    });\n});\n\ncliController.on('showVersion', function () {\n    info.version();\n    process.exit();\n});\n\ncliController.on('showHelp', function () {\n    info.help();\n    process.exit();\n});\n\ncliController.on('setFormat', function (format) {\n    formatter = formatters[format];\n\n    if (!formatter) {\n        console.error('Unknown output format: %s', argv.format);\n        console.error('  available: ' + Object.keys(formatters).join(' '));\n        process.exit(1);\n    }\n});\n\ncliController.on('showNumericOnly', function () {\n    metrics = _.filter(metrics, function (metric) {\n        return metric.format == 'number';\n    });\n});\n\nvar read = function (filePath, onFileLoad, onAllLoad) {\n    if (fs.lstatSync(filePath).isDirectory()) {\n        readDirectory(filePath, onFileLoad, onAllLoad);\n    }\n    else if (fileIsStylesheet(filePath)) {\n        readFile(filePath, function (err, data) {\n            onFileLoad(err, data);\n            onAllLoad();\n        });\n    } else {\n        onAllLoad();\n    }\n}\n\nvar readDirectory = function (directoryPath, onFileLoad, onAllLoad) {\n    fs.readdir(directoryPath, function (err, files) {\n        async.each(files, function (file, fileDone) {\n            read(path.join(directoryPath, file), onFileLoad, fileDone);\n        }, onAllLoad);\n    });\n};\n\nvar readFile = function (filePath, onLoad) {\n    fs.readFile(filePath, {encoding: 'utf8'}, function (err, fileData) {\n        onLoad(err, fileData);\n    });\n};\n\nvar fileIsStylesheet = function (filePath) {\n    return filePath.indexOf('.css') !== -1;\n};\n\nvar runReport = function (stylesheets, metrics) {\n    var results = parker.run(stylesheets);\n    console.log(formatter(metrics, results));\n};\n\nif (module.parent) {\n    module.exports = Parker;\n} else {\n    var parker = new Parker(metrics),\n    formatter = formatters['human'];\n    cliController.dispatch(argv);\n}\n"
  },
  {
    "path": "test/CliController.js",
    "content": "/*! Parker v0.0.0 - MIT license */\n\nvar chai = require('chai'),\n    expect = require('chai').expect,\n    CliController = require('../lib/CliController.js'),\n    sinon = require('sinon'),\n    sinonChai = require('sinon-chai');\n\nchai.use(sinonChai);\n\ndescribe('The CLI Controller', function() {\n    it('responds to a -v switch by dispatching a version event', function () {\n        var callback = sinon.spy(),\n            cliController = new CliController();\n        \n        cliController.on('showVersion', callback);\n        cliController.dispatch({'v': true});\n        expect(callback).to.have.been.called;\n    });\n\n    it('responds to a --version switch by dispatching a version event', function () {\n        var callback = sinon.spy(),\n            cliController = new CliController();\n        \n        cliController.on('showVersion', callback);\n        cliController.dispatch({'version': true});\n        expect(callback).to.have.been.called;\n    });\n\n    it('responds to a -h switch by dispatching a version event', function () {\n        var callback = sinon.spy(),\n            cliController = new CliController();\n        \n        cliController.on('showHelp', callback);\n        cliController.dispatch({'h': true});\n        expect(callback).to.have.been.called;\n    });\n\n    it('responds to a --help switch by dispatching a version event', function () {\n        var callback = sinon.spy(),\n            cliController = new CliController();\n        \n        cliController.on('showHelp', callback);\n        cliController.dispatch({'help': true});\n        expect(callback).to.have.been.called;\n    });\n\n    it('responds to a -h switch by dispatching a help event', function () {\n        var callback = sinon.spy(),\n            cliController = new CliController();\n        \n        cliController.on('showHelp', callback);\n        cliController.dispatch({'h': true});\n        expect(callback).to.have.been.called;\n    });\n\n    it('responds to a --help switch by dispatching a help event', function () {\n        var callback = sinon.spy(),\n            cliController = new CliController();\n        \n        cliController.on('showHelp', callback);\n        cliController.dispatch({'h': true});\n        expect(callback).to.have.been.called;\n    });\n\n    it('responds to a -f switch by dispatching a format event', function () {\n        var callback = sinon.spy(),\n            cliController = new CliController();\n        \n        cliController.on('setFormat', callback);\n        cliController.dispatch({'f': 'json'});\n        expect(callback).to.have.been.calledWith('json');\n    });\n\n    it('responds to a --format switch by dispatching a format event', function () {\n        var callback = sinon.spy(),\n            cliController = new CliController();\n        \n        cliController.on('setFormat', callback);\n        cliController.dispatch({'format': 'json'});\n        expect(callback).to.have.been.calledWith('json');\n    });\n\n    it('responds to no data supplied by dispatching a help event', function () {\n        var callback = sinon.spy(),\n            cliController = new CliController();\n        \n        cliController.on('showHelp', callback);\n        cliController.dispatch({});\n        expect(callback).to.have.been.called;\n    });\n\n    it('responds to unnamed arguments by dispatching file event, then a run event', function () {\n        var pathsCallback = sinon.spy(),\n            cliController = new CliController();\n        \n        cliController.on('runPaths', pathsCallback);\n        cliController.dispatch({'_': ['styles.css', 'ie.css']});\n        expect(pathsCallback).to.have.been.calledWith(['styles.css', 'ie.css']);\n    });\n});"
  },
  {
    "path": "test/CssDeclaration.js",
    "content": "/*! Parker v0.0.0 - MIT license */\n\nvar expect = require('chai').expect,\n    CssDeclaration = require('../lib/CssDeclaration.js');\n\ndescribe('The Declaration Parser', function() {\n    beforeEach(function() {\n        cssDeclaration = new CssDeclaration('color: #fff');\n    });\n\n    it('should return a property and a value for a declaration', function() {\n        expect(cssDeclaration.getProperty()).to.equal('color');\n        expect(cssDeclaration.getValue()).to.equal('#fff');\n    });\n});"
  },
  {
    "path": "test/CssMediaQuery.js",
    "content": "/*! Parker v0.0.0 - MIT license */\n\nvar expect = require('chai').expect,\n    CssMediaQuery = require('../lib/CssMediaQuery.js');\n\ndescribe('The Css Media Query object', function () {\n    it('should return (n) queries for a media query of (n) queries', function () {\n        var cssMediaQuery = new CssMediaQuery('@media print {a {color: #000;}}');\n        expect(cssMediaQuery.getQueries()[0]).to.equal('print');\n\n        cssMediaQuery = new CssMediaQuery('@media (min-width: 700px) and (orientation: landscape) {.blogroll {display: none;}}');\n        expect(cssMediaQuery.getQueries()[0]).to.equal('(min-width: 700px) and (orientation: landscape)');\n\n        cssMediaQuery = new CssMediaQuery('@media handheld, (min-width: 700px) {.blogroll {display: none;}}');\n        expect(cssMediaQuery.getQueries()[0]).to.equal('handheld');\n        expect(cssMediaQuery.getQueries()[1]).to.equal('(min-width: 700px)');\n\n        cssMediaQuery = new CssMediaQuery('@media handheld or (min-width: 700px) {.blogroll {display: none;}}');\n        expect(cssMediaQuery.getQueries()[0]).to.equal('handheld');\n        expect(cssMediaQuery.getQueries()[1]).to.equal('(min-width: 700px)');\n    });\n\n    it('should return (n) queries for a media query of (n) rules', function () {\n        var cssMediaQuery = new CssMediaQuery('@media print {a {color: #000;} header {display: none;}}');\n        expect(cssMediaQuery.getRules()[0]).to.equal('a {color: #000;}');\n        expect(cssMediaQuery.getRules()[1]).to.equal('header {display: none;}');\n    });\n});"
  },
  {
    "path": "test/CssRule.js",
    "content": "/*! Parker v0.0.0 - MIT license */\n\nvar expect = require('chai').expect,\n    CssRule = require('../lib/CssRule.js');\n\ndescribe('The Rule Parser', function () {\n    it('should return a collection of (n) items of selectors for a rule of (n) selectors', function () {\n        var cssRule = new CssRule('body {border: 0;}');\n        expect(cssRule.getSelectors()).to.have.length(1);\n\n        var complexRule = 'body, html, .container .wrapper, #container, .container a[rel=\"blah\"]'\n            + '{background: url(img.png); background-color: #ffffff;}';\n        cssRule = new CssRule(complexRule);\n\n        expect(cssRule.getSelectors()).to.have.length(5);\n    });\n\n    it('should return a collection of (n) items of declarations for a rule of (n) declarations', function () {\n        var cssRule = new CssRule('body {border: 0;}');\n        expect(cssRule.getDeclarations()).to.have.length(1);\n\n        var complexRule = 'body, html, .container .wrapper, #container, .container a[rel=\"blah\"]'\n            + '{background: url(img.png); background-color: linear-gradient(45deg, #00f, #f00)}';\n        cssRule = new CssRule(complexRule);\n        \n        expect(cssRule.getDeclarations()).to.have.length(2);\n    });\n});"
  },
  {
    "path": "test/CssSelector.js",
    "content": "/*! Parker v0.0.0 - MIT license */\n\nvar expect = require('chai').expect,\n    CssSelector = require('../lib/CssSelector.js');\n\ndescribe('The Selector Parser', function() {\n    it('returns a collection of (n) items for a selector of (n) identifiers', function() {\n        var cssSelector = new CssSelector('#my-form');\n        expect(cssSelector.getIdentifiers()).to.have.length(1);\n        cssSelector = new CssSelector('#my-form #username.error');\n        expect(cssSelector.getIdentifiers()).to.have.length(3);\n        cssSelector = new CssSelector('#my-form input[name=username]');\n        expect(cssSelector.getIdentifiers()).to.have.length(3);\n    });\n\n    it('correctly parses universal identifiers in a selector', function() {\n        var cssSelector = new CssSelector('body .list *:first-child');\n        expect(cssSelector.getIdentifiers()).to.have.length(4);\n    });\n\n    it('correctly parses type identifiers in a selector', function() {\n        var cssSelector = new CssSelector('body form input');\n        expect(cssSelector.getIdentifiers()).to.have.length(3);\n    });\n\n    it('correctly parses class identifiers in a selector', function() {\n        var cssSelector = new CssSelector('.login-form .checkbox.error');\n        expect(cssSelector.getIdentifiers()).to.have.length(3);\n    });\n\n    it('correctly parses id identifiers in a selector', function() {\n        var cssSelector = new CssSelector('#login-page #form#login-form input#password.error');\n        expect(cssSelector.getIdentifiers()).to.have.length(6);\n    });\n\n    it('correctly parses attribute identifiers in a selector', function() {\n        var cssSelector = new CssSelector('form[name=login-form]');\n        expect(cssSelector.getIdentifiers()).to.have.length(2);\n        cssSelector = new CssSelector('a[rel][]');\n        expect(cssSelector.getIdentifiers()).to.have.length(2);\n        cssSelector = new CssSelector('a[rel~=\"copyright\"]');\n        expect(cssSelector.getIdentifiers()).to.have.length(2);\n        cssSelector = new CssSelector('a[hreflang|=\"en\"]');\n        expect(cssSelector.getIdentifiers()).to.have.length(2);\n        cssSelector = new CssSelector('a[hreflang=fr]');\n        expect(cssSelector.getIdentifiers()).to.have.length(2);\n    });\n\n    it('correctly parses pseudo-class identifiers in a selector', function() {\n        var cssSelector = new CssSelector('a:first-child');\n        expect(cssSelector.getIdentifiers()).to.have.length(2);\n    });\n\n    it('correctly parses pseudo-element identifiers in a selector', function() {\n        var cssSelector = new CssSelector('p::first-line');\n        expect(cssSelector.getIdentifiers()).to.have.length(2);\n    });\n});"
  },
  {
    "path": "test/CssStylesheet.js",
    "content": "/*! Parker v0.0.0 - MIT license */\n\nvar expect = require('chai').expect,\n    CssStylesheet = require('../lib/CssStylesheet.js');\n\ndescribe('The Stylesheet Parser', function() {\n    it('should return an empty array of child rules for an empty string', function () {\n        var cssStylesheet = new CssStylesheet('');\n        expect(cssStylesheet.getRules()).to.be.an('array');\n        expect(cssStylesheet.getRules()).to.be.empty;\n    });\n\n    it('should return (n) items of child rules for a stylesheet of (n) rules', function() {\n        var cssStylesheet = new CssStylesheet(\"body {border: 0} h1 {font-weight: bold;}\");\n        expect(cssStylesheet.getRules()).to.have.length(2);\n\n        var multipleRules = \"body {border: 0;} h1 {font-weight: bold;}\"\n            + \" p {color: #333333; font-size: 1.2em; width: 100%} input {border: 1px solid #333333;\"\n            + \" background-color: 1px solid #CCCCCC; padding: 0.1em; linear-gradient(45deg, #00f, #f00)}\";\n        cssStylesheet = new CssStylesheet(multipleRules);\n        expect(cssStylesheet.getRules()).to.have.length(4);\n\n        var multipleSelectors = \"body section :first-child {background: #FFF;}\"\n            + \"form#registration-form > input.username {font-weight: bold;}\";\n        cssStylesheet = new CssStylesheet(multipleSelectors);\n        expect(cssStylesheet.getRules()).to.have.length(2);\n    });\n\n    it('should distinguish between media-queries and at-rules', function () {\n        var cssStylesheet = new CssStylesheet(\"@media screen { body {border: 0;} } @include (styles.css); body { margin: 0; }\");\n        expect(cssStylesheet.getMediaQueries()[0]).to.equal('@media screen { body {border: 0;} }');\n        expect(cssStylesheet.getMediaQueries()).to.have.length(1);\n        expect(cssStylesheet.getRules()[0]).to.equal('body { margin: 0; }');\n    });\n\n    it('should return (n) items of child media-queries for a stylesheet of (n) media-queries', function () {\n        var cssStylesheet = new CssStylesheet(\"@media screen { body {border: 0;} } @media print { a {color: #000;} } @include (styles.css);\");\n        expect(cssStylesheet.getMediaQueries()).to.have.length(2);\n        expect(cssStylesheet.getMediaQueries()[0]).to.equal('@media screen { body {border: 0;} }');\n        expect(cssStylesheet.getMediaQueries()[1]).to.equal('@media print { a {color: #000;} }');\n    });\n\n    it('should ignore comments', function () {\n        var cssStylesheet = new CssStylesheet(\"body {border: 0;} /* ./* */ a {color: #fff; /* comment */} * {margin: 0;}\");\n        expect(cssStylesheet.getRules()).to.have.length(3);\n    });\n\n    it('should ignore newline characters', function () {\n        var cssStylesheet = new CssStylesheet(\"body {\\nborder: 0;\\n}\\na{\\ncolor: #fff;\\n}\");\n        expect(cssStylesheet.getRules()[0]).to.equal(\"body {border: 0;}\");\n        expect(cssStylesheet.getRules()[1]).to.equal(\"a{color: #fff;}\");\n        var cssStylesheet = new CssStylesheet(\"body {\\r\\nborder: 0;\\r\\n}\\r\\na{\\r\\ncolor: #fff;\\r\\n}\");\n        expect(cssStylesheet.getRules()[0]).to.equal(\"body {border: 0;}\");\n        expect(cssStylesheet.getRules()[1]).to.equal(\"a{color: #fff;}\");\n    });\n\n    it('should return an array of malformed statements for a string containing malformed statements', function () {\n        var cssStylesheet = new CssStylesheet('body {border: 0;} h1; h2 {font-weight: bold;}');\n        expect(cssStylesheet.getRules()).to.be.an('array');\n        expect(cssStylesheet.getMalformedStatements()[0]).to.equal('h1;');\n    });\n\n    it('should identify a rule with an unexpected colon as a malformed statement', function () {\n        var cssStylesheet = new CssStylesheet('body {border: 0;} h1;{font-weight: bold;}');\n        expect(cssStylesheet.getRules()).to.be.an('array');\n        expect(cssStylesheet.getMalformedStatements()[0]).to.equal('h1;');\n        expect(cssStylesheet.getMalformedStatements()[1]).to.equal('{font-weight: bold;}');\n    });\n});"
  },
  {
    "path": "test/DeclarationsPerRule.js",
    "content": "\n/*! Parker v0.0.0 - MIT license */\n\nvar expect = require('chai').expect,\n    metric = require('../metrics/DeclarationsPerRule.js');\n\n\ndescribe('The declarations-per-rule metric', function () {\n    it('should provide a string identifier for the metric', function() {\n        expect(metric.id).to.be.a('string');\n    });\n\n    it('should provide a metric type', function() {\n        expect(metric.aggregate).to.match(/sum|mean/g);\n    });\n\n    it('should return 0 for an empty string', function () {\n        expect(metric.measure('')).to.equal(0);\n    });\n\n    it('should return 1 for the selector \"body { color: #222 }\"', function() {\n        expect(metric.measure('body { color: 1 }')).to.equal(1);\n    });\n\n    it('should return 2 for the selector \"body { color: #222; backgrund: #333; }\"', function() {\n        expect(metric.measure('body { color: #222; backgrund: #333; }')).to.equal(2);\n    });\n\n    it('should return 3 for the selector \"body { color: #222; backgrund: #333; margin: 0; }\"', function() {\n        expect(metric.measure('body { color: #222; backgrund: #333; margin: 0; }')).to.equal(3);\n    });\n\n    it('should return 4 for the selector \"body { color: #222; backgrund: #333; margin: 0; padding: 0; }\"', function() {\n        expect(metric.measure('body { color: #222; backgrund: #333; margin: 0; padding: 0; }')).to.equal(4);\n    });\n});\n"
  },
  {
    "path": "test/IdentifiersPerSelector.js",
    "content": "/*! Parker v0.0.0 - MIT license */\n\nvar expect = require('chai').expect,\n    metric = require('../metrics/IdentifiersPerSelector.js');\n\n\ndescribe('The identifiers-per-selector metric', function () {\n    it('should provide a string identifier for the metric', function() {\n        expect(metric.id).to.be.a('string');\n    });\n\n    it('should provide a metric type', function() {\n        expect(metric.aggregate).to.match(/sum|mean/g);\n    });\n\n    it('should return 0 for an empty string', function () {\n        expect(metric.measure('')).to.equal(0);\n    });\n\n    it('should return 1 for the selector \"body\"', function() {\n        expect(metric.measure('body')).to.equal(1);\n    });\n\n    it('should return 2 for the selector \"body section\"', function() {\n        expect(metric.measure('body section')).to.equal(2);\n    });\n\n    it('should return 3 for the selector \"body section.articles\"', function() {\n        expect(metric.measure('body section.acticles')).to.equal(3);\n    });\n\n    it('should return 4 for the selector \"body section.articles>article\"', function() {\n        expect(metric.measure('body section.articles>article')).to.equal(4);\n    });\n\n    it('should return 5 for the selector \"body section.articles>article:first-child\"', function() {\n        expect(metric.measure('body section.articles>article:first-child')).to.equal(5);\n    })\n\n    it('should return 7 for the selector \"body section.articles>article:first-child p::first-line', function() {\n        expect(metric.measure('body section.articles>article:first-child p::first-line')).to.equal(7);\n    });\n\n    it('should return 3 for the selector \"form[name=login] input\"', function() {\n        expect(metric.measure('form[name=login] input')).to.equal(3);\n        expect(metric.measure('form[name=\"login\"] input')).to.equal(3);\n        expect(metric.measure(\"form[name='login'] input\")).to.equal(3);\n    });\n\n    it('should return 2 for the selector \"input[checked]\"', function() {\n        expect(metric.measure('input[checked]')).to.equal(2);\n    });\n\n    it('should return 2 for the selector \"input[value~=Mrs]\"', function() {\n        expect(metric.measure('input[value~=Mrs]')).to.equal(2);\n        expect(metric.measure('input[value~=\"Mrs\"]')).to.equal(2);\n        expect(metric.measure(\"input[value~='Mrs']\")).to.equal(2);\n    });\n});\n"
  },
  {
    "path": "test/Parker.js",
    "content": "/*! Parker v0.0.0 - MIT license */\n\nvar expect = require('chai').expect,\n    Parker = require('../lib/Parker.js');\n\ndescribe('The Parker tool', function() {\n    it('should throw an exception if stylesheet data not supplied as string, array or multi-param strings', function() {\n        parker = new Parker([]);\n        expect(function() {parker.run({})}).to.throw();\n        expect(function() {parker.run(0)}).to.throw();\n        expect(function() {parker.run(1, [], {})}).to.throw();\n    });\n\n    it('should not throw an exception if stylesheet data is supplied as string, array or multi-param strings', function() {\n        parker = new Parker([]);\n        expect(function() {parker.run('body {background: #FFF;}')});\n        expect(function() {parker.run(array('body {background: #FFF;}'))});\n        expect(function() {parker.run('body {background: #FFF;}', 'body {background: #FFF;}')});\n    });\n\n    it('should run metrics on stylesheets', function() {\n        var mockMetric = {id: 'mock-stylesheet-metric', type: 'stylesheet', aggregate: 'sum', measure: function() {return 1}};\n        parker = new Parker([mockMetric]);\n        expect(parker.run('body {background: #FFF;}')).to.have.property('mock-stylesheet-metric');\n    });\n\n    it('should return sum values for sum metrics', function() {\n        var mockMetric = {id: 'mock-stylesheet-metric', type: 'stylesheet', aggregate: 'sum', measure: function() {return 1}},\n            stylesheet = 'body {background: #FFF;}';\n\n        parker = new Parker([mockMetric]);\n        var report = parker.run([stylesheet, stylesheet, stylesheet]);\n\n        \n        expect(report).to.have.property('mock-stylesheet-metric');\n        expect(report['mock-stylesheet-metric']).to.equal(3);\n    });\n\n    it('should return 0 for sum metrics with no data to report on', function() {\n        var mockMetric = {id: 'mock-stylesheet-metric', type: 'rule', aggregate: 'sum', measure: function() {return 1}},\n            stylesheet = '/* comment */';\n\n        parker = new Parker([mockMetric]);\n        var report = parker.run([stylesheet, stylesheet, stylesheet]);\n\n        \n        expect(report).to.have.property('mock-stylesheet-metric');\n        expect(report['mock-stylesheet-metric']).to.equal(0);\n    });\n\n    it('should return mean values for mean metrics', function() {\n        var mockMetric = {id: 'mock-stylesheet-metric', type: 'stylesheet', aggregate: 'mean', measure: function() {return 1}},\n            stylesheet = 'body {background: #FFF;}';\n\n        parker = new Parker([mockMetric]);\n        var report = parker.run([stylesheet, stylesheet, stylesheet]);\n\n        \n        expect(report).to.have.property('mock-stylesheet-metric');\n        expect(report['mock-stylesheet-metric']).to.equal(1);\n    });\n\n    it('should return 0 for mean metrics with no data to report on', function () {\n        var mockMetric = {id: 'mock-stylesheet-metric', type: 'rule', aggregate: 'mean', measure: function() {return 1}},\n            stylesheet = '/* comment */';\n\n        parker = new Parker([mockMetric]);\n        var report = parker.run([stylesheet]);\n\n        \n        expect(report).to.have.property('mock-stylesheet-metric');\n        expect(report['mock-stylesheet-metric']).to.equal(0);\n    });\n\n    it('should return max values for max metrics', function () {\n        var mockIntMetric = {id: 'mock-int-metric', type: 'stylesheet', aggregate: 'max', measure: function(stylesheet) {return stylesheet.length;}},\n            parker = new Parker([mockIntMetric]),\n            report = parker.run(['body {background: #FFF;}', 'body {background: #FFFFFF;}']);\n        \n        expect(report).to.have.property('mock-int-metric');\n        expect(report['mock-int-metric']).to.equal(27);\n    });\n\n    it('should return 0 for max metrics with no data to report on', function () {\n        var mockIntMetric = {id: 'mock-int-metric', type: 'rule', aggregate: 'max', measure: function(stylesheet) {return stylesheet.length;}},\n            parker = new Parker([mockIntMetric]),\n            report = parker.run(['/* comment */']);\n        \n        expect(report).to.have.property('mock-int-metric');\n        expect(report['mock-int-metric']).to.equal(0);\n    });\n\n    it('should return max values determined by an iterator function if one is present', function() {\n        var mockStringMetric = {id: 'mock-string-metric', type: 'stylesheet', aggregate: 'max', measure: function(stylesheet) {return stylesheet;}, iterator: function(string) {return string.length}},\n            parker = new Parker([mockStringMetric]),\n            report = parker.run(['body {background: #FFF;}', 'body {background: #FFFFFF;}']);\n        \n        expect(report).to.have.property('mock-string-metric');\n        expect(report['mock-string-metric']).to.equal('body {background: #FFFFFF;}');\n    });\n\n    it('should return list values for list metrics', function () {\n        var mockSingleMetric = {id: 'mock-single-list-item-metric', type: 'stylesheet', aggregate: 'list', measure: function(stylesheet) {return stylesheet}},\n            mockMultipleMetric = {id: 'mock-multiple-list-item-metric', type: 'stylesheet', aggregate: 'list', measure: function(stylesheet) {return ['a', 'b']}},\n            parker = new Parker([mockSingleMetric, mockMultipleMetric]),\n            report = parker.run(['body {background: #FFF;}', 'body {background: #FFF;}']);\n\n        expect(report).to.have.property('mock-single-list-item-metric');\n        expect(report['mock-single-list-item-metric']).to.be.an('array');\n        expect(report['mock-single-list-item-metric']).to.have.length(2);\n        expect(report['mock-single-list-item-metric'][0]).to.equal('body {background: #FFF;}');\n        expect(report['mock-single-list-item-metric'][1]).to.equal('body {background: #FFF;}');\n        expect(report['mock-multiple-list-item-metric']).to.be.an('array');\n        expect(report['mock-multiple-list-item-metric']).to.have.length(4);\n        expect(report['mock-multiple-list-item-metric'][0]).to.equal('a');\n        expect(report['mock-multiple-list-item-metric'][1]).to.equal('b');\n        expect(report['mock-multiple-list-item-metric'][0]).to.equal('a');\n        expect(report['mock-multiple-list-item-metric'][1]).to.equal('b');\n    });\n\n    it('should return list values filtered by a filter function if one is present', function() {\n        var mockMetric = {id: 'mock-list-metric', type: 'stylesheet', aggregate: 'list', measure: function(stylesheet) {return stylesheet}, filter: function(value, index, self) {return self.indexOf(value) === index;}},\n            parker = new Parker([mockMetric]),\n            report = parker.run(['body {background: #FFF;}', 'body {background: #FFF;}']);\n\n        expect(report).to.have.property('mock-list-metric');\n        expect(report['mock-list-metric']).to.be.an('array');\n        expect(report['mock-list-metric']).to.have.length(1);\n        expect(report['mock-list-metric'][0]).to.equal('body {background: #FFF;}');\n    });\n\n    it('should return length values for length metrics', function () {\n        var mockMetric = {id: 'mock-length-metric', type: 'stylesheet', aggregate: 'length', measure: function(stylesheet) {return stylesheet}},\n        parker = new Parker([mockMetric]);\n        report = parker.run(['body {background: #FFF;}', 'body {background: #FFF;}', '']);\n\n        expect(report).to.have.property('mock-length-metric');\n        expect(report['mock-length-metric']).to.equal(2);\n    });\n\n    it('should run metrics on rules', function() {\n        var mockMetric = {id: 'mock-rule-metric', type: 'rule', aggregate: 'sum', measure: function() {return 1}};\n        parker = new Parker([mockMetric]),\n        report = parker.run('body {background: #FFF;} h1 {font-weight: bold;}');\n\n        expect(report).to.have.property('mock-rule-metric');\n        expect(report['mock-rule-metric']).to.equal(2);\n    });\n\n    it('should run metrics on media queries', function () {\n        var mockMetric = {id: 'mock-media-query-metric', type: 'mediaquery', aggregate: 'list', measure: function(query) {return query;}};\n            parker = new Parker([mockMetric]),\n            report = parker.run('@media handheld, (max-width: 700px) { body { margin: 100px; }} @import url(css/styles.css); body { margin: 0; }');\n        expect(report).to.have.property('mock-media-query-metric');\n        expect(report['mock-media-query-metric'][0]).to.equal('handheld');\n        expect(report['mock-media-query-metric'][1]).to.equal('(max-width: 700px)');\n    });\n\n    it('should run metrics on rules inside media query blocks', function () {\n        var mockMetric = {id: 'mock-media-query-metric', type: 'rule', aggregate: 'list', measure: function(rule) {return rule;}},\n        parker = new Parker([mockMetric]),\n        report = parker.run('@media print {a {color: #000;} header {display: none;}}');\n        expect(report).to.have.property('mock-media-query-metric');\n        expect(report['mock-media-query-metric'][0]).to.equal('a {color: #000;}');\n        expect(report['mock-media-query-metric'][1]).to.equal('header {display: none;}');\n    });\n\n    it('should run metrics on selectors', function() {\n        var mockMetric = {id: 'mock-selector-metric', type: 'selector', aggregate: 'sum', measure: function() {return 1}};\n        parker = new Parker([mockMetric]);\n        report = parker.run('body section {background: #FFF;} h1 {font-weight: bold;}');\n\n        expect(report).to.have.property('mock-selector-metric');\n        expect(report['mock-selector-metric']).to.equal(2);\n    });\n\n    it('should run metrics on identifiers', function() {\n        var mockMetric = {id: 'mock-identifier-metric', type: 'identifier', aggregate: 'sum', measure: function() {return 1}};\n        parker = new Parker([mockMetric]);\n\n        report = parker.run(\"body section :first-child {background: #FFF;} form#registration-form > input.username {font-weight: bold;}\");\n        expect(report).to.have.property('mock-identifier-metric');\n        expect(report['mock-identifier-metric']).to.equal(7);\n    });\n\n    it('should run metrics on declarations', function() {\n        var mockMetric = {id: 'mock-declaration-metric', type: 'declaration', aggregate: 'sum', measure: function() {return 1}};\n        parker = new Parker([mockMetric]);\n\n        report = parker.run(\"body {margin: 0; padding: 0} a {color: #00f} h1 {font-weight: bold; color: #000;}\");\n        expect(report).to.have.property('mock-declaration-metric');\n        expect(report['mock-declaration-metric']).to.equal(5);\n    });\n\n    it('should run metrics on properties', function() {\n        var mockMetric = {id: 'mock-property-metric', type: 'property', aggregate: 'sum', measure: function() {return 1}};\n        parker = new Parker([mockMetric]);\n\n        report = parker.run(\"body {margin: 0; padding: 0} a {color: #00f} h1 {font-weight: bold; color: #000;}\");\n        expect(report).to.have.property('mock-property-metric');\n        expect(report['mock-property-metric']).to.equal(5);\n    });\n\n    it('should run metrics on values', function() {\n        var mockMetric = {id: 'mock-value-metric', type: 'value', aggregate: 'sum', measure: function() {return 1}};\n        parker = new Parker([mockMetric]);\n\n        report = parker.run(\"body {margin: 0; padding: 0} a {color: #00f} h1 {font-weight: bold; color: #000;}\");\n        expect(report).to.have.property('mock-value-metric');\n        expect(report['mock-value-metric']).to.equal(5);\n    });\n\n    it('should return results for metrics measuring optional elements when those elements are not found', function () {\n        var mockMetric = {id: 'mock-media-query-metric', type: 'mediaquery', aggregate: 'length', measure: function(query) {return query;}};\n            parker = new Parker([mockMetric]),\n            report = parker.run('body { margin: 0; }');\n\n        expect(report).to.have.property('mock-media-query-metric');\n        expect(report['mock-media-query-metric']).to.equal(0);\n    });\n});"
  },
  {
    "path": "test/TopSelectorSpecificity.js",
    "content": "var expect = require('chai').expect,\n    metric = require('../metrics/TopSelectorSpecificity.js');\n\ndescribe('The top-selector-specificity metric', function () {\n    it('should return a specificity of \"1\" for the selector \"table\"', function () {\n        expect(metric.measure(\"table\")).to.equal(1);\n    });\n\n    it('should return a specificity of \"1\" for the selector \"::first-line\"', function () {\n        expect(metric.measure('::before')).to.equal(1);\n    });\n\n    it('should return a specificity of \"10\" for the selector \".class\"', function () {\n        expect(metric.measure('.class')).to.equal(10);\n    });\n\n    it('should return a specificity of \"10\" for the selector \"[href=\"/\"]\"', function () {\n        expect(metric.measure('[href=\"/\"]')).to.equal(10);\n    });\n\n    it('should return a specificity of \"10\" for the selector \":first\"', function () {\n        expect(metric.measure(':first')).to.equal(10);\n    });\n\n    it('should return a specificity of \"100\" for the selector \"#main\"', function () {\n        expect(metric.measure('#main')).to.equal(100);\n    });\n\n    it('should return a specificity of \"0\" for the selector \"*\"', function () {\n        expect(metric.measure('*')).to.equal(0);\n    });\n\n    it('should count only the specificity of the child selector of a :not identifier', function () {\n        expect(metric.measure(':not(body)')).to.equal(1);\n        expect(metric.measure(':not(.sidebar)')).to.equal(10);\n        expect(metric.measure(':not(h1#main)')).to.equal(101);\n    });\n\n    it('should ignore identifier tokens inside attribute selectors', function () {\n        expect(metric.measure('[href=\"#main\"]')).to.equal(10);\n    });\n});\n"
  },
  {
    "path": "test/TotalIdSelectors.js",
    "content": "/*! Parker v0.0.0 - MIT license */\n\nvar expect = require('chai').expect,\n\tmetric = require('../metrics/TotalIdSelectors.js');\n\ndescribe('The total-id-selectors metric', function () {\n\tit('should provide a string identifier for the metric', function() {\n\t\texpect(metric.id).to.be.a('string');\n\t});\n\n\tit('should provide a metric type', function() {\n\t\texpect(metric.aggregate).to.match(/sum|mean/g);\n\t});\n\n\tit('should return 0 for an empty string', function () {\n\t\texpect(metric.measure('')).to.equal(0);\n\t});\n\n\tit('should return 1 for the selector \"#test\"', function() {\n\t\texpect(metric.measure('#test')).to.equal(1);\n\t});\n\n\tit('should return 1 for the selector \"foo#test\"', function() {\n\t\texpect(metric.measure('foo#test')).to.equal(1);\n\t});\n\n\tit('should return 1 for the selector \"foo #test\"', function() {\n\t\texpect(metric.measure('foo #test')).to.equal(1);\n\t});\n\n\tit('should return 0 for the selector \"[href=\"#foo\"]\"', function () {\n\t\texpect(metric.measure('[href=\"#foo\"]')).to.equal(0);\n\t});\n\n\tit('should return 1 for the selector \"[href=\"#foo\"] #foo\"', function () {\n\t\texpect(metric.measure('[href=\"#foo\"] #foo')).to.equal(1);\n\t});\n\n\tit('should return 2 for the selector \"#foo #bar\"', function () {\n\t\texpect(metric.measure('#foo #bar')).to.equal(2);\n\t});\n});\n"
  },
  {
    "path": "test/ZIndexes.js",
    "content": "var expect = require('chai').expect,\n    metric = require('../metrics/ZIndexes.js');\n\ndescribe(\"The Z-Indexes metric\", function() {\n    it('should return 1 for \"z-index: 1\"', function () {\n        expect(metric.measure('z-index: 1')).to.equal('1');\n    });\n});\n"
  }
]