Skip to content
Browse files

Updated build files. Repackaged as v1.5.3.

  • Loading branch information...
1 parent b8f8e7f commit 6ebd1866ecd261b566147fad02736a01f6db62cf @balupton balupton committed Oct 27, 2013
Showing with 427 additions and 401 deletions.
  1. +4 −2 .travis.yml
  2. +0 −5 Backers.md
  3. +38 −0 CONTRIBUTING.md
  4. +140 −113 Cakefile
  5. +3 −0 History.md
  6. +11 −3 LICENSE.md
  7. +97 −39 README.md
  8. +17 −0 bower.json
  9. +25 −0 component.json
  10. +0 −21 docpad.coffee
  11. +0 −2 out/demo/code.js
  12. +0 −4 out/demo/search.js
  13. +0 −4 out/demo/visual-search.js
  14. +20 −82 out/lib/query-engine.js
  15. +0 −38 out/test/live-test.js
  16. +0 −1 out/test/misc-test.js
  17. +0 −11 out/test/queries-test.js
  18. +0 −18 out/test/sort-test.js
  19. +72 −58 package.json
View
6 .travis.yml
@@ -1,7 +1,9 @@
+# v1.3.2 October 26, 2013
+# https://github.com/bevry/base
language: node_js
install: "npm install"
-before_script: "./node_modules/.bin/cake test-prepare"
-script: "./node_modules/.bin/cake test"
+before_script: "./node_modules/.bin/cake compile"
+script: "npm test"
node_js:
- "0.8"
- "0.10"
View
5 Backers.md
@@ -1,5 +0,0 @@
-# Backers
-
-Thanks go out to the following entities for contributing financially to support the growth of this project:
-
-- [BugHerd](http://bugherd.com/)
View
38 CONTRIBUTING.md
@@ -0,0 +1,38 @@
+# Contribute
+
+## Development
+
+1. Fork the project and clone your fork
+2. Install global dependencies
+
+ ``` bash
+ npm install -g coffee-script
+ ```
+
+3. Compile the project
+
+ ``` bash
+ # Only once
+ cake compile
+
+ # On every change
+ cake watch
+ ```
+
+4. Run your tests
+
+ ``` bash
+ cake test
+ ```
+
+5. Prepare the project for publishing
+
+ ``` bash
+ cake prepublish
+ ```
+
+6. Publish the project
+
+ ``` bash
+ cake publish
+ ```
View
253 Cakefile
@@ -1,133 +1,160 @@
-# This file was originally created by Benjamin Lupton <b@lupton.cc> (http://balupton.com)
-# and is currently licensed under the Creative Commons Zero (http://creativecommons.org/publicdomain/zero/1.0/)
-# making it public domain so you can do whatever you wish with it without worry (you can even remove this notice!)
-#
-# If you change something here, be sure to reflect the changes in:
-# - the scripts section of the package.json file
-# - the .travis.yml file
+# v1.3.1 October 26, 2013
+# https://github.com/bevry/base
-# -----------------
-# Variables
+# =====================================
+# Imports
+
+fsUtil = require('fs')
+pathUtil = require('path')
-WINDOWS = process.platform.indexOf('win') is 0
-NODE = process.execPath
-NPM = if WINDOWS then process.execPath.replace('node.exe','npm.cmd') else 'npm'
-EXT = (if WINDOWS then '.cmd' else '')
-APP = process.cwd()
-BIN = "#{APP}/node_modules/.bin"
-CAKE = "#{BIN}/cake#{EXT}"
-COFFEE = "#{BIN}/coffee#{EXT}"
-DOCPAD = "#{BIN}/docpad#{EXT}"
-OUT = "#{APP}/out"
-SRC = "#{APP}/src"
+# =====================================
+# Variables
-# -----------------
-# Requires
+WINDOWS = process.platform.indexOf('win') is 0
+NODE = process.execPath
+NPM = (if WINDOWS then process.execPath.replace('node.exe', 'npm.cmd') else 'npm')
+EXT = (if WINDOWS then '.cmd' else '')
+APP_DIR = process.cwd()
+PACKAGE_PATH = pathUtil.join(APP_DIR, "package.json")
+PACKAGE_DATA = require(PACKAGE_PATH)
+DOCS_DIR = pathUtil.join(APP_DIR, "docs")
+DOCS_INPUT = pathUtil.join(APP_DIR, "src", "lib", "*")
+SRC_DIR = pathUtil.join(APP_DIR, "src")
+OUT_DIR = pathUtil.join(APP_DIR, "out")
+TEST_DIR = pathUtil.join(APP_DIR, "test")
+MODULES_DIR = pathUtil.join(APP_DIR, "node_modules")
+BIN_DIR = pathUtil.join(MODULES_DIR, ".bin")
+GIT = "git"
+CAKE = pathUtil.join(BIN_DIR, "cake#{EXT}")
+COFFEE = pathUtil.join(BIN_DIR, "coffee#{EXT}")
+PROJECTZ = pathUtil.join(BIN_DIR, "projectz#{EXT}")
+DOCCO = pathUtil.join(BIN_DIR, "docco#{EXT}")
+DOCPAD = pathUtil.join(BIN_DIR, "docpad#{EXT}")
+
+
+# =====================================
+# Generic
-pathUtil = require('path')
{exec,spawn} = require('child_process')
safe = (next,fn) ->
+ fn ?= next # support only one argument
return (err) ->
- return next(err) if err
- return fn()
+ # success status code
+ if err is 0
+ err = null
+ # error status code
+ else if err is 1
+ err = new Error('Process exited with error status code')
-# -----------------
-# Actions
+ # Error
+ return next(err) if err
-bench = (opts,next) ->
- (next = opts; opts = {}) unless next?
- spawn(NODE, ["#{OUT}/test/benchmark.js"], {stdio:'inherit',cwd:APP}).on('exit',next)
-
-clean = (opts,next) ->
- (next = opts; opts = {}) unless next?
- args = [
- '-Rf'
- OUT
- pathUtil.join(APP,'node_modules')
- pathUtil.join(APP,'*out')
- pathUtil.join(APP,'*log')
- ]
- spawn('rm', args, {stdio:'inherit',cwd:APP}).on('exit',next)
-
-compile = (opts,next) ->
- (next = opts; opts = {}) unless next?
- spawn(DOCPAD, ['generate'], {stdio:'inherit',cwd:APP}).on('exit',next)
-
-watch = (opts,next) ->
- (next = opts; opts = {}) unless next?
- spawn(DOCPAD, ['watch'], {stdio:'inherit',cwd:APP}).on('exit',next)
-
-install = (opts,next) ->
- (next = opts; opts = {}) unless next?
- spawn(NPM, ['install'], {stdio:'inherit',cwd:APP}).on('exit',next)
-
-reset = (opts,next) ->
- (next = opts; opts = {}) unless next?
- clean opts, safe next, -> install opts, safe next, -> compile opts, next
-
-setup = (opts,next) ->
- (next = opts; opts = {}) unless next?
- install opts, safe next, ->
- compile opts, next
-
-test = (opts,next) ->
- (next = opts; opts = {}) unless next?
- args = []
- args.push("--debug-brk") if opts.debug
- args.push("--joe-reporter=list")
- args.push("#{OUT}/test/everything-test.js")
- spawn(NODE, args, {stdio:'inherit',cwd:APP}, next)
+ # Continue
+ return fn()
finish = (err) ->
throw err if err
console.log('OK')
-# -----------------
-# Commands
-
-# bench
-task 'bench', 'benchmark our project', ->
- bench finish
-
-# clean
-task 'clean', 'clean up instance', ->
- clean finish
-
-# compile
-task 'compile', 'compile our files', ->
- compile finish
-
-# dev/watch
-task 'dev', 'watch and recompile our files', ->
- watch finish
-task 'watch', 'watch and recompile our files', ->
- watch finish
-
-# install
-task 'install', 'install dependencies', ->
- install finish
-
-# reset
-task 'reset', 'reset instance', ->
- reset finish
-
-# setup
-task 'setup', 'setup for development', ->
- setup finish
-
-# test
-task 'test', 'run our tests', ->
- test finish
-
-# test-debug
-task 'test-debug', 'run our tests in debug mode', ->
- test {debug:true}, finish
+# =====================================
+# Actions
-# test-prepare
-task 'test-prepare', 'prepare out tests', ->
- setup finish
+actions =
+ clean: (opts,next) ->
+ (next = opts; opts = {}) unless next?
+ args = ['-Rf', OUT_DIR]
+ for path in [APP_DIR, TEST_DIR]
+ args.push(
+ pathUtil.join(path, 'build')
+ pathUtil.join(path, 'components')
+ pathUtil.join(path, 'bower_components')
+ pathUtil.join(path, 'node_modules')
+ pathUtil.join(path, '*out')
+ pathUtil.join(path, '*log')
+ )
+ # rm
+ spawn('rm', args, {stdio:'inherit', cwd:APP_DIR}).on('close', safe next)
+
+ install: (opts,next) ->
+ (next = opts; opts = {}) unless next?
+ step1 = ->
+ # npm install (for app)
+ spawn(NPM, ['install'], {stdio:'inherit', cwd:APP_DIR}).on('close', safe next, step2)
+ step2 = ->
+ fsUtil.exists TEST_DIR, (exists) ->
+ return next() unless exists
+ # npm install (for test)
+ spawn(NPM, ['install'], {stdio:'inherit', cwd:TEST_DIR}).on('close', safe next)
+ step1()
+
+ compile: (opts,next) ->
+ (next = opts; opts = {}) unless next?
+ # cake install
+ actions.install opts, safe next, ->
+ # coffee compile
+ spawn(DOCPAD, ['generate'], {stdio:'inherit', cwd:APP_DIR}).on('close', safe next)
+
+ watch: (opts,next) ->
+ (next = opts; opts = {}) unless next?
+ # cake install
+ actions.install opts, safe next, ->
+ # coffee watch
+ spawn(DOCPAD, ['watch'], {stdio:'inherit', cwd:APP_DIR}).on('close', safe next)
+
+ test: (opts,next) ->
+ (next = opts; opts = {}) unless next?
+ # cake compile
+ actions.compile opts, safe next, ->
+ # npm test
+ spawn(NPM, ['test'], {stdio:'inherit', cwd:APP_DIR}).on('close', safe next)
+
+ prepublish: (opts,next) ->
+ (next = opts; opts = {}) unless next?
+ step1 = ->
+ # cake compile
+ actions.compile(opts, safe next, step2)
+ step2 = ->
+ # project compile
+ fsUtil.exists PROJECTZ, (exists) ->
+ return step3() unless exists
+ spawn(PROJECTZ, ['compile'], {stdio:'inherit', cwd:APP_DIR}).on('close', safe next, step3)
+ step3 = ->
+ # docco compile
+ fsUtil.exists DOCCO, (exists) ->
+ return step4() unless exists
+ exec("#{DOCCO} -o #{DOCS_DIR} #{DOCS_INPUT}", {stdio:'inherit', cwd:APP_DIR}, safe next, step4)
+ step4 = ->
+ # npm test
+ actions.test(opts, safe next)
+ step1()
+
+ publish: (opts,next) ->
+ (next = opts; opts = {}) unless next?
+ # cake prepublish
+ actions.prepublish opts, safe next, ->
+ # npm publish
+ spawn(NPM, ['publish'], {stdio:'inherit', cwd:APP_DIR}).on 'close', safe next, ->
+ # git tag
+ spawn(GIT, ['tag', 'v'+PACKAGE_DATA.version, '-a'], {stdio:'inherit', cwd:APP_DIR}).on('close', safe next)
+
+
+# =====================================
+# Commands
+commands =
+ clean: 'clean up instance'
+ install: 'install dependencies'
+ compile: 'compile our files (runs install)'
+ watch: 'compile our files initially, and again for each change (runs install)'
+ test: 'run our tests (runs compile)'
+ prepublish: 'prepare our package for publishing'
+ publish: 'publish our package (runs prepublish)'
+
+Object.keys(commands).forEach (key) ->
+ description = commands[key]
+ fn = actions[key]
+ task key, description, (opts) -> fn(opts, finish)
View
3 History.md
@@ -1,5 +1,8 @@
## History
+- v1.5.3 October 27, 2013
+ - Re-packaged
+
- v1.5.2 March 21, 2013
- Backbone peerDependency now supports any version
- Tested again Backbone.js v1.0.0
View
14 LICENSE.md
@@ -1,10 +1,18 @@
-(The MIT License)
-Copyright (c) 2012+ Bevry Pty Ltd <us@bevry.me>
-Copyright (c) 2011 Benjamin Lupton <b@lupton.cc>
+<!-- LICENSEFILE/ -->
+# License
+
+Copyright &copy; 2012+ Bevry Pty Ltd <us@bevry.me> (http://bevry.me)
+<br/>Copyright &copy; 2011 Benjamin Lupton <b@lupton.cc> (http://balupton.com)
+
+## The MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+<!-- /LICENSEFILE -->
+
+
View
136 README.md
@@ -1,8 +1,51 @@
+
+<!-- TITLE/ -->
+
# QueryEngine
-[![Build Status](https://secure.travis-ci.org/bevry/query-engine.png?branch=master)](http://travis-ci.org/bevry/query-engine)
-[![NPM version](https://badge.fury.io/js/query-engine.png)](https://npmjs.org/package/query-engine)
-[![Flattr this project](https://raw.github.com/balupton/flattr-buttons/master/badge-89x18.gif)](http://flattr.com/thing/344188/balupton-on-Flattr)
+<!-- /TITLE -->
+
+
+<!-- BADGES/ -->
+
+[![Build Status](http://img.shields.io/travis-ci/bevry/query-engine.png?branch=master)](http://travis-ci.org/bevry/query-engine "Check this project's build status on TravisCI")
+[![NPM version](https://badge.fury.io/js/query-engine.png)](https://npmjs.org/package/query-engine "View this project on NPM")
+[![Gittip donate button](http://img.shields.io/gittip/bevry.png)](https://www.gittip.com/bevry/ "Donate weekly to this project using Gittip")
+[![Flattr donate button](https://raw.github.com/balupton/flattr-buttons/master/badge-89x18.gif)](http://flattr.com/thing/344188/balupton-on-Flattr "Donate monthly to this project using Flattr")
+[![PayPayl donate button](https://www.paypalobjects.com/en_AU/i/btn/btn_donate_SM.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QB8GQPZAH84N6 "Donate once-off to this project using Paypal")
+
+<!-- /BADGES -->
+
+
+<!-- DESCRIPTION/ -->
+
+Query-Engine is a NoSQL and MongoDb compliant query engine. It can run on the server-side with Node.js, or on the client-side within web browsers
+
+<!-- /DESCRIPTION -->
+
+
+<!-- INSTALL/ -->
+
+## Install
+
+### [Node](http://nodejs.org/), [Browserify](http://browserify.org/)
+- Use: `require('query-engine')`
+- Install: `npm install --save query-engine`
+
+### [Ender](http://ender.jit.su/)
+- Use: `require('query-engine')`
+- Install: `ender add query-engine`
+
+### [Component](http://github.com/component/component)
+- Use: `require('query-engine')`
+- Install: `component install bevry/query-engine`
+
+### [Bower](http://bower.io/)
+- Use: `require('query-engine')`
+- Install: `bower install query-engine`
+
+<!-- /INSTALL -->
+
QueryEngine provides extensive Querying, Filtering, and Searching abilities for [Backbone.js Collections](http://documentcloud.github.com/backbone/#Collection) as well as JavaScript arrays and objects. The Backbone.js and Underscore dependencies are optional.
@@ -20,69 +63,84 @@ QueryEngine provides extensive Querying, Filtering, and Searching abilities for
* actively maintained, supported, and implemented by several companies
-## Installation
+## Compatability
-### Server-Side with Node.js
+Tested and working against Backbone versions:
-1. [Install Node.js](https://github.com/balupton/node/wiki/Installing-Node.js)
+- 0.9.2
+- 0.9.9
+- 1.0.0
+- 1.1.0
-1. Install Backbone (optional, but required for `QueryCollection`)
- ``` bash
- npm install backbone
- ```
+## Using
-1. Install QueryEngine
+[You can find all the information you desire about using QueryEngine on its Using QueryEngine Wiki Page](https://github.com/bevry/query-engine/wiki/Using)
- ``` bash
- npm install query-engine
- ```
-1. Require QueryEngine
+<!-- HISTORY/ -->
- ``` javascript
- var queryEngine = require('query-engine');
- ```
+## History
+[Discover the change history by heading on over to the `History.md` file.](https://github.com/bevry/query-engine/blob/master/History.md#files)
+<!-- /HISTORY -->
-### Client-Side with Web Browsers
-1. Include the necessary scripts
+<!-- CONTRIBUTE/ -->
- ``` html
- <!-- Optional: But required for QueryCollection -->
- <script src="http://documentcloud.github.com/underscore/underscore-min.js"></script>
- <script src="http://documentcloud.github.com/backbone/backbone-min.js"></script>
+## Contribute
- <!-- Required -->
- <script src="http://raw.github.com/bevry/query-engine/master/out/lib/query-engine.js"></script>
- ```
+[Discover how you can contribute by heading on over to the `Contributing.md` file.](https://github.com/bevry/query-engine/blob/master/Contributing.md#files)
-2. Access QueryEngine via the `window.queryEngine` variable
+<!-- /CONTRIBUTE -->
-## Using
+<!-- BACKERS/ -->
-[You can find all the information you desire about using QueryEngine on its Using QueryEngine Wiki Page](https://github.com/bevry/query-engine/wiki/Using)
+## Backers
+### Maintainers
-## History
+These amazing people are maintaining this project:
-[You can discover the history inside the `History.md` file](https://github.com/bevry/query-engine/blob/master/History.md#files)
+- Benjamin Lupton <b@lupton.cc> (https://github.com/balupton)
+### Sponsors
-## Compatability
+These amazing people have contributed finances to this project:
-Tested and working against Backbone versions 0.9.2, 0.9.9, and 1.0.0
+- BugHerd <support@bugherd.com> (http://bugherd.com/)
+Become a sponsor!
-## Backers
+[![Gittip donate button](http://img.shields.io/gittip/bevry.png)](https://www.gittip.com/bevry/ "Donate weekly to this project using Gittip")
+[![Flattr donate button](https://raw.github.com/balupton/flattr-buttons/master/badge-89x18.gif)](http://flattr.com/thing/344188/balupton-on-Flattr "Donate monthly to this project using Flattr")
+[![PayPayl donate button](https://www.paypalobjects.com/en_AU/i/btn/btn_donate_SM.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QB8GQPZAH84N6 "Donate once-off to this project using Paypal")
-Check out the [Backers.md](https://github.com/bevry/query-engine/blob/master/Backers.md#files) file to discover all the amazing people who financially supported the development of this project.
+### Contributors
+These amazing people have contributed code to this project:
+
+- Andrew Shults <andrewjshults@gmail.com> (https://github.com/andrewjshults) - [view contributions](https://github.com/bevry/query-engine/commits?author=andrewjshults)
+- Benjamin Lupton <b@lupton.cc> (https://github.com/balupton) - [view contributions](https://github.com/bevry/query-engine/commits?author=balupton)
+- Farid Neshat <FaridN_SOAD@yahoo.com> (https://github.com/alFReD-NSH) - [view contributions](https://github.com/bevry/query-engine/commits?author=alFReD-NSH)
+- Khalid Jebbari <https://github.com/DjebbZ> (https://github.com/DjebbZ) - [view contributions](https://github.com/bevry/query-engine/commits?author=DjebbZ)
+- Nicholas Firth-McCoy (https://github.com/nfm) - [view contributions](https://github.com/bevry/query-engine/commits?author=nfm)
+
+[Become a contributor!](https://github.com/bevry/query-engine/blob/master/Contributing.md#files)
+
+<!-- /BACKERS -->
+
+
+<!-- LICENSE/ -->
## License
-Licensed under the incredibly [permissive](http://en.wikipedia.org/wiki/Permissive_free_software_licence) [MIT License](http://creativecommons.org/licenses/MIT/)
-<br/>Copyright &copy; 2012+ [Bevry Pty Ltd](http://bevry.me)
-<br/>Copyright &copy; 2011 [Benjamin Lupton](http://balupton.com)
+Licensed under the incredibly [permissive](http://en.wikipedia.org/wiki/Permissive_free_software_licence) [MIT license](http://creativecommons.org/licenses/MIT/)
+
+Copyright &copy; 2012+ Bevry Pty Ltd <us@bevry.me> (http://bevry.me)
+<br/>Copyright &copy; 2011 Benjamin Lupton <b@lupton.cc> (http://balupton.com)
+
+<!-- /LICENSE -->
+
+
View
17 bower.json
@@ -0,0 +1,17 @@
+{
+ "name": "query-engine",
+ "version": "1.5.3",
+ "dependencies": {},
+ "devDependencies": {
+ "backbone": "~1.1.0",
+ "underscore": "~1.5.2",
+ "coffee-script": "~1.6.2",
+ "docpad": ">=6.21.5 <7",
+ "docpad-plugin-coffeescript": "2",
+ "joe": "~1.3.0",
+ "joe-reporter-console": "~1.2.1",
+ "benchmark": "~1.0.0",
+ "projectz": "~0.2.3"
+ },
+ "main": "./out/lib/query-engine.js"
+}
View
25 component.json
@@ -0,0 +1,25 @@
+{
+ "name": "query-engine",
+ "version": "1.5.3",
+ "license": "MIT",
+ "description": "Query-Engine is a NoSQL and MongoDb compliant query engine. It can run on the server-side with Node.js, or on the client-side within web browsers",
+ "keywords": [
+ "coffeescript",
+ "query-engine",
+ "nosql",
+ "query",
+ "sql",
+ "pills",
+ "search",
+ "searching",
+ "lucene",
+ "filter",
+ "filtering",
+ "collections"
+ ],
+ "demo": "https://github.com/bevry/query-engine",
+ "main": "./out/lib/query-engine.js",
+ "scripts": [
+ "./out/lib/query-engine.js"
+ ]
+}
View
21 docpad.coffee
@@ -1,21 +0,0 @@
-# Prepare
-delay = (next) -> setTimeout(next,500)
-
-# Export
-module.exports =
- prompts: false
- events:
- generateAfter: (opts,next) ->
- # Prepare
- docpad = @docpad
-
- # Test
- require('bal-util').spawn 'cake test', {output:true}, (err) ->
- if err
- message = 'TESTS FAILED'
- docpad.log('warn', message)
- else
- message = 'Tests passed'
- docpad.log('info', message)
- delay -> docpad.notify(message)
- return next()
View
2 out/demo/code.js
@@ -15,7 +15,6 @@
$(window).resize(function() {
var padHeight, padWidth;
-
padWidth = $(window).width() / 2 - 20;
padHeight = $(window).height() - $('.header:first').height() - 80;
return $('.pad,.editor').width(padWidth).height(padHeight);
@@ -36,7 +35,6 @@
performQuery = function() {
var code, err, errMessage, inCollection, resultCoffee, resultCollection;
-
try {
code = CoffeeScript.compile(editors.code.getSession().getValue());
inCollection = eval(code);
View
4 out/demo/search.js
@@ -15,15 +15,13 @@
$(window).resize(function() {
var padHeight, padWidth;
-
padWidth = $(window).width() / 2 - 20;
padHeight = $(window).height() - $('.header:first').height() - 80;
return $('.pad,.editor').width(padWidth).height(padHeight);
}).trigger('resize');
$(document).keydown(function(e) {
var isInput;
-
isInput = $(document.activeElement).is(':input');
if (e.keyCode === 8 && !isInput) {
return e.preventDefault();
@@ -45,7 +43,6 @@
codeChanged = function() {
var codeCoffeeScript, codeJavaScript, collection, err, errMessage;
-
try {
codeCoffeeScript = editors.code.getSession().getValue();
codeJavaScript = CoffeeScript.compile(codeCoffeeScript);
@@ -61,7 +58,6 @@
window.updateResults = function(collection) {
var resultArray, resultCoffee, resultJavaScript;
-
resultArray = collection != null ? collection.toJSON() : void 0;
resultJavaScript = JSON.stringify(resultArray);
resultCoffee = Js2coffee.build("var result = " + resultJavaScript);
View
4 out/demo/visual-search.js
@@ -15,15 +15,13 @@
$(window).resize(function() {
var padHeight, padWidth;
-
padWidth = $(window).width() / 2 - 20;
padHeight = $(window).height() - $('.header:first').height() - 80;
return $('.pad,.editor').width(padWidth).height(padHeight);
}).trigger('resize');
$(document).keydown(function(e) {
var isInput;
-
isInput = $(document.activeElement).is(':input');
if (e.keyCode === 8 && !isInput) {
return e.preventDefault();
@@ -45,7 +43,6 @@
codeChanged = function() {
var codeCoffeeScript, codeJavaScript, collection, err, errMessage;
-
try {
codeCoffeeScript = editors.code.getSession().getValue();
codeJavaScript = CoffeeScript.compile(codeCoffeeScript);
@@ -61,7 +58,6 @@
window.updateResults = function(collection) {
var resultArray, resultCoffee, resultJavaScript;
-
resultArray = collection != null ? collection.toJSON() : void 0;
resultJavaScript = JSON.stringify(resultArray);
resultCoffee = Js2coffee.build("var result = " + resultJavaScript);
View
102 out/lib/query-engine.js
@@ -68,7 +68,6 @@
},
isObjectEmpty: function(object) {
var empty, key, value;
-
empty = true;
for (key in object) {
if (!__hasProp.call(object, key)) continue;
@@ -86,19 +85,16 @@
},
clone: function() {
var args;
-
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
return util.shallowExtendPlainObjects.apply(util, [{}].concat(__slice.call(args)));
},
extend: function() {
var args;
-
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
return util.shallowExtendPlainObjects.apply(util, args);
},
shallowExtendPlainObjects: function() {
var key, obj, objs, target, value, _i, _len;
-
target = arguments[0], objs = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
for (_i = 0, _len = objs.length; _i < _len; _i++) {
obj = objs[_i];
@@ -113,7 +109,6 @@
},
get: function(obj, key) {
var result;
-
if (obj.get != null) {
result = obj.get(key);
} else {
@@ -140,7 +135,6 @@
},
toArray: function(value) {
var item, key, result, valueExists;
-
result = [];
valueExists = typeof value !== 'undefined';
if (valueExists) {
@@ -160,7 +154,6 @@
},
toArrayGroup: function(value) {
var item, key, obj, result, valueExists;
-
result = [];
valueExists = typeof value !== 'undefined';
if (valueExists) {
@@ -182,7 +175,6 @@
},
generateComparator: function(input) {
var generateFunction;
-
generateFunction = function(comparator) {
if (!comparator) {
return null;
@@ -191,7 +183,6 @@
} else if (util.isArray(comparator)) {
return function(a, b) {
var comparison, key, value, _i, _len;
-
comparison = 0;
for (key = _i = 0, _len = comparator.length; _i < _len; key = ++_i) {
value = comparator[key];
@@ -205,7 +196,6 @@
} else if (util.isObject(comparator)) {
return function(a, b) {
var aValue, bValue, comparison, key, value;
-
comparison = 0;
for (key in comparator) {
if (!__hasProp.call(comparator, key)) continue;
@@ -241,7 +231,6 @@
function Hash(value) {
var item, key, _i, _len;
-
value = util.toArray(value);
for (key = _i = 0, _len = value.length; _i < _len; key = ++_i) {
item = value[key];
@@ -251,7 +240,6 @@
Hash.prototype.hasIn = function(options) {
var value, _i, _len;
-
options = util.toArray(options);
for (_i = 0, _len = this.length; _i < _len; _i++) {
value = this[_i];
@@ -264,7 +252,6 @@
Hash.prototype.hasAll = function(options) {
var empty, pass, value, _i, _len;
-
options = util.toArray(options);
empty = true;
pass = true;
@@ -283,7 +270,6 @@
Hash.prototype.isSame = function(options) {
var pass;
-
options = util.toArray(options);
pass = this.sort().join() === options.sort().join();
return pass;
@@ -304,24 +290,24 @@
this.onParentAdd = __bind(this.onParentAdd, this);
this.onParentRemove = __bind(this.onParentRemove, this);
this.onParentChange = __bind(this.onParentChange, this);
- this.onChange = __bind(this.onChange, this); _ref1 = QueryCollection.__super__.constructor.apply(this, arguments);
+ this.onChange = __bind(this.onChange, this);
+ _ref1 = QueryCollection.__super__.constructor.apply(this, arguments);
return _ref1;
}
QueryCollection.prototype.model = Backbone.Model;
QueryCollection.prototype.initialize = function(models, options) {
- var key, me, value, _ref2, _ref3, _ref4;
-
+ var key, me, value, _ref2;
me = this;
- if ((_ref2 = this.options) == null) {
+ if (this.options == null) {
this.options = {};
}
- _ref3 = Criteria.prototype;
- for (key in _ref3) {
- if (!__hasProp.call(_ref3, key)) continue;
- value = _ref3[key];
- if ((_ref4 = this[key]) == null) {
+ _ref2 = Criteria.prototype;
+ for (key in _ref2) {
+ if (!__hasProp.call(_ref2, key)) continue;
+ value = _ref2[key];
+ if (this[key] == null) {
this[key] = value;
}
}
@@ -352,14 +338,13 @@
};
QueryCollection.prototype.createChildCollection = function(models, options) {
- var collection, _ref2, _ref3;
-
+ var collection;
options || (options = {});
options.parentCollection = this;
- if ((_ref2 = options.collection) == null) {
+ if (options.collection == null) {
options.collection = this.collection || QueryCollection;
}
- if ((_ref3 = options.comparator) == null) {
+ if (options.comparator == null) {
options.comparator = options.collection.prototype.comparator || this.comparator;
}
collection = new options.collection(models, options);
@@ -368,7 +353,6 @@
QueryCollection.prototype.createLiveChildCollection = function(models, options) {
var collection;
-
options || (options = {});
options.live = true;
collection = this.createChildCollection(models, options);
@@ -394,7 +378,6 @@
QueryCollection.prototype.hasModel = function(model) {
var exists, _ref2, _ref3;
-
model || (model = {});
if ((model.id != null) && this.get(model.id)) {
exists = true;
@@ -408,7 +391,6 @@
QueryCollection.prototype.safeRemove = function(model) {
var exists;
-
exists = this.hasModel(model);
if (exists) {
this.remove(model);
@@ -418,7 +400,6 @@
QueryCollection.prototype.safeAdd = function(model) {
var exists;
-
exists = this.hasModel(model);
if (!exists) {
this.add(model);
@@ -443,7 +424,6 @@
QueryCollection.prototype.sortArray = function(comparator) {
var arr;
-
arr = this.toJSON();
if (comparator) {
comparator = util.generateComparator(comparator);
@@ -461,7 +441,6 @@
QueryCollection.prototype.findAll = function() {
var args, collection, comparator, criteriaOptions, paging, query;
-
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
if (args.length) {
if (args.length === 1 && args[0] instanceof Criteria) {
@@ -485,7 +464,6 @@
QueryCollection.prototype.findAllLive = function() {
var args, collection, comparator, criteriaOptions, paging, query;
-
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
if (args.length) {
if (args.length === 1 && args[0] instanceof Criteria) {
@@ -509,7 +487,6 @@
QueryCollection.prototype.findOne = function() {
var args, comparator, criteriaOptions, paging, passed, query;
-
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
if (args.length) {
if (args.length === 1 && args[0] instanceof Criteria) {
@@ -537,7 +514,6 @@
QueryCollection.prototype.query = function() {
var args, criteria, passed;
-
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
if (args.length === 1) {
if (args[0] instanceof Criteria) {
@@ -555,7 +531,6 @@
QueryCollection.prototype.queryModels = function() {
var args, collection, criteriaOptions, models, passed;
-
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
criteriaOptions = this.extractCriteriaOptions.apply(this, args);
collection = this.getParentCollection() || this;
@@ -566,7 +541,6 @@
QueryCollection.prototype.queryArray = function() {
var args, model, passed, result, _i, _len;
-
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
result = [];
passed = this.queryModels.apply(this, args);
@@ -579,7 +553,6 @@
QueryCollection.prototype.live = function(enabled) {
var parentCollection;
-
if (enabled == null) {
enabled = this.options.live;
}
@@ -608,7 +581,6 @@
QueryCollection.prototype.add = function(models, options) {
var model, passedModels, _i, _len;
-
options = options ? util.clone(options) : {};
models = util.isArray(models) ? models.slice() : [models];
passedModels = [];
@@ -634,7 +606,6 @@
QueryCollection.prototype.onChange = function(model) {
var pass;
-
if (this.getPaging()) {
return this.query();
}
@@ -651,7 +622,6 @@
QueryCollection.prototype.onParentChange = function(model) {
var pass;
-
if (this.getPaging()) {
return this.query();
}
@@ -693,7 +663,6 @@
Criteria = (function() {
function Criteria() {
var args;
-
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
this.applyCriteriaOptions = __bind(this.applyCriteriaOptions, this);
this.applyCriteriaOptions.apply(this, args);
@@ -702,7 +671,6 @@
Criteria.prototype.extractCriteriaOptions = function() {
var args, comparator, criteriaOptions, paging, query;
-
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
if (args.length === 1) {
if (args[0] instanceof Criteria) {
@@ -728,28 +696,27 @@
};
Criteria.prototype.applyCriteriaOptions = function() {
- var args, criteriaOptions, _base, _base1, _base2, _base3, _base4, _base5, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8;
-
+ var args, criteriaOptions, _base, _base1, _base2, _base3, _base4, _base5;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
- if ((_ref2 = this.options) == null) {
+ if (this.options == null) {
this.options = {};
}
- if ((_ref3 = (_base = this.options).filters) == null) {
+ if ((_base = this.options).filters == null) {
_base.filters = {};
}
- if ((_ref4 = (_base1 = this.options).queries) == null) {
+ if ((_base1 = this.options).queries == null) {
_base1.queries = {};
}
- if ((_ref5 = (_base2 = this.options).pills) == null) {
+ if ((_base2 = this.options).pills == null) {
_base2.pills = {};
}
- if ((_ref6 = (_base3 = this.options).paging) == null) {
+ if ((_base3 = this.options).paging == null) {
_base3.paging = null;
}
- if ((_ref7 = (_base4 = this.options).searchString) == null) {
+ if ((_base4 = this.options).searchString == null) {
_base4.searchString = null;
}
- if ((_ref8 = (_base5 = this.options).comparator) == null) {
+ if ((_base5 = this.options).comparator == null) {
_base5.comparator = null;
}
criteriaOptions = this.extractCriteriaOptions.apply(this, args);
@@ -813,7 +780,6 @@
Criteria.prototype.setFilters = function(filters) {
var key, value;
-
filters || (filters = {});
for (key in filters) {
if (!__hasProp.call(filters, key)) continue;
@@ -825,7 +791,6 @@
Criteria.prototype.setFilter = function(name, value) {
var filters;
-
if (typeof value === 'undefined') {
throw new Error('QueryCollection::setFilter was called without both arguments');
}
@@ -848,7 +813,6 @@
Criteria.prototype.setQueries = function(queries) {
var key, value;
-
queries || (queries = {});
for (key in queries) {
if (!__hasProp.call(queries, key)) continue;
@@ -860,7 +824,6 @@
Criteria.prototype.setQuery = function(name, value) {
var queries;
-
if (typeof value === 'undefined') {
throw new Error('QueryCollection::setQuery was called without both arguments');
}
@@ -886,7 +849,6 @@
Criteria.prototype.setPills = function(pills) {
var key, value;
-
pills || (pills = {});
for (key in pills) {
if (!__hasProp.call(pills, key)) continue;
@@ -898,7 +860,6 @@
Criteria.prototype.setPill = function(name, value) {
var pills, searchString;
-
if (typeof value === 'undefined') {
throw new Error('QueryCollection::setPill was called without both arguments');
}
@@ -928,7 +889,6 @@
Criteria.prototype.setSearchString = function(searchString) {
var cleanedSearchString, pill, pillName, pills;
-
pills = this.options.pills;
cleanedSearchString = searchString;
for (pillName in pills) {
@@ -943,14 +903,12 @@
Criteria.prototype.test = function() {
var args;
-
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
return this.testModel.apply(this, args);
};
Criteria.prototype.testModel = function(model, criteriaOptions) {
var passed;
-
if (criteriaOptions == null) {
criteriaOptions = {};
}
@@ -960,7 +918,6 @@
Criteria.prototype.testModels = function(models, criteriaOptions) {
var comparator, finish, me, model, paging, pass, passed, start, _i, _len;
-
if (criteriaOptions == null) {
criteriaOptions = {};
}
@@ -1002,7 +959,6 @@
Criteria.prototype.testQueries = function(model, queries) {
var passed, query, queryName;
-
passed = true;
if (queries == null) {
queries = this.getQueries();
@@ -1026,7 +982,6 @@
Criteria.prototype.testFilters = function(model, filters) {
var cleanedSearchString, filter, filterName, passed;
-
passed = true;
cleanedSearchString = this.getCleanedSearchString();
if (filters == null) {
@@ -1047,7 +1002,6 @@
Criteria.prototype.testPills = function(model, pills) {
var passed, pill, pillName, searchString;
-
passed = true;
searchString = this.getSearchString();
if (pills == null) {
@@ -1090,7 +1044,6 @@
function Pill(pill) {
var prefix, regexString, safePrefixes, safePrefixesStr, _i, _len, _ref2;
-
pill || (pill = {});
this.callback = pill.callback;
this.prefixes = pill.prefixes;
@@ -1111,7 +1064,6 @@
Pill.prototype.setSearchString = function(searchString) {
var cleanedSearchString, match, value, values;
-
cleanedSearchString = searchString;
values = [];
while (match = this.regex.exec(searchString)) {
@@ -1139,7 +1091,6 @@
Pill.prototype.test = function(model) {
var pass, value, _i, _j, _len, _len1, _ref2, _ref3, _ref4;
-
if ((_ref2 = this.values) != null ? _ref2.length : void 0) {
if (this.logicalOperator === 'OR') {
pass = false;
@@ -1183,7 +1134,6 @@
'$or': {
compile: function(opts) {
var queries, query, queryGroup, querySource, _i, _len;
-
queries = [];
queryGroup = util.toArrayGroup(opts.selectorValue);
if (!queryGroup.length) {
@@ -1200,7 +1150,6 @@
},
test: function(opts) {
var query, _i, _len, _ref2;
-
_ref2 = opts.queries;
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
query = _ref2[_i];
@@ -1225,7 +1174,6 @@
},
test: function(opts) {
var query, _i, _len, _ref2;
-
_ref2 = opts.queries;
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
query = _ref2[_i];
@@ -1282,7 +1230,6 @@
'$beginsWith': {
test: function(opts) {
var beginsWithParts, beginsWithValue, _i, _len;
-
if (opts.selectorValue && opts.modelValueExists && util.isString(opts.modelValue)) {
beginsWithParts = util.toArray(opts.selectorValue);
for (_i = 0, _len = beginsWithParts.length; _i < _len; _i++) {
@@ -1304,7 +1251,6 @@
'$endsWith': {
test: function(opts) {
var endsWithParts, endsWithValue, _i, _len;
-
if (opts.selectorValue && opts.modelValueExists && util.isString(opts.modelValue)) {
endsWithParts = util.toArray(opts.selectorValue);
for (_i = 0, _len = endsWithParts.length; _i < _len; _i++) {
@@ -1423,7 +1369,6 @@
'$mod': {
test: function(opts) {
var $mod;
-
if (opts.modelValueExists) {
$mod = opts.selectorValue;
if (!util.isArray($mod)) {
@@ -1520,7 +1465,6 @@
Query.prototype.compileSelector = function(selectorName, selectorOpts) {
var compileOpts, compiledSelector, key, opts, query, selector, selectors, value;
-
if (selectorOpts == null) {
selectorOpts = {};
}
@@ -1561,7 +1505,6 @@
Query.prototype.testCompiledSelector = function(compiledSelector, model) {
var match, opts, test;
-
opts = compiledSelector.opts;
test = compiledSelector.test;
opts.model = model;
@@ -1577,7 +1520,6 @@
Query.prototype.compileQuery = function() {
var advancedSelectorName, advancedSelectorValue, compiledSelector, compiledSelectors, fieldName, query, selectorValue, _ref2;
-
query = this;
compiledSelectors = [];
_ref2 = this.source;
@@ -1650,7 +1592,6 @@
Query.prototype.test = function(model) {
var compiledSelector, match, _i, _len, _ref2;
-
match = true;
_ref2 = this.compiledSelectors;
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
@@ -1690,7 +1631,6 @@
},
testModels: function() {
var args, criteria, models, result;
-
models = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
models = util.toArray(models);
criteria = (function(func, args, ctor) {
@@ -1703,14 +1643,12 @@
},
createCollection: function(models, options) {
var collection;
-
models = util.toArray(models);
collection = new QueryCollection(models, options);
return collection;
},
createLiveCollection: function(models, options) {
var collection;
-
models = util.toArray(models);
collection = new QueryCollection(models, options).live(true);
return collection;
View
38 out/test/live-test.js
@@ -96,7 +96,6 @@
describe('queries', function(describe, it) {
it('should only keep jquery related models', function() {
var actual, expected, liveCollection;
-
liveCollection = queryEngine.createLiveCollection().setQuery('only jquery related', {
tags: {
$has: ['jquery']
@@ -108,10 +107,8 @@
});
it('should support searching', function() {
var actual, expected, liveCollection;
-
liveCollection = queryEngine.createLiveCollection().setFilter('search', function(model, searchString) {
var pass, searchRegex;
-
searchRegex = queryEngine.createSafeRegex(searchString);
pass = searchRegex.test(model.get('title')) || searchRegex.test(model.get('content'));
return pass;
@@ -123,12 +120,10 @@
return describe('pill searches', function(describe, it) {
it('should support pill searches without spacing', function() {
var actual, expected, liveCollection;
-
liveCollection = queryEngine.createLiveCollection().setPill('id', {
prefixes: ['id:', '#'],
callback: function(model, value) {
var pass, pillRegex;
-
pillRegex = queryEngine.createSafeRegex(value);
pass = pillRegex.test(model.get('id'));
return pass;
@@ -140,12 +135,10 @@
});
it('should support pill searches with null', function() {
var actual, expected, liveCollection;
-
liveCollection = queryEngine.createLiveCollection().setPill('positionNullable', {
prefixes: ['positionNullable:'],
callback: function(model, value) {
var pass, pillRegex;
-
pillRegex = queryEngine.createSafeRegex(value);
pass = pillRegex.test(model.get('positionNullable'));
return pass;
@@ -157,12 +150,10 @@
});
it('should support pill searches with spacing', function() {
var actual, expected, liveCollection;
-
liveCollection = queryEngine.createLiveCollection().setPill('id', {
prefixes: ['id:', '#'],
callback: function(model, value) {
var pass, pillRegex;
-
pillRegex = queryEngine.createSafeRegex(value);
pass = pillRegex.test(model.get('id'));
return pass;
@@ -174,12 +165,10 @@
});
it('should support pill searches with quotes', function() {
var actual, expected, liveCollection;
-
liveCollection = queryEngine.createLiveCollection().setPill('title', {
prefixes: ['title:'],
callback: function(model, value) {
var pass;
-
pass = value === model.get('title');
return pass;
}
@@ -190,12 +179,10 @@
});
it('should support pill searches with OR pills', function() {
var actual, expected, liveCollection;
-
liveCollection = queryEngine.createLiveCollection().setPill('tag', {
prefixes: ['tag:'],
callback: function(model, value) {
var pass;
-
pass = __indexOf.call(model.get('tags'), value) >= 0;
return pass;
}
@@ -206,13 +193,11 @@
});
it('should support pill searches with AND pills', function() {
var actual, expected, liveCollection;
-
liveCollection = queryEngine.createLiveCollection().setPill('tag', {
logicalOperator: 'AND',
prefixes: ['tag:'],
callback: function(model, value) {
var pass;
-
pass = __indexOf.call(model.get('tags'), value) >= 0;
return pass;
}
@@ -223,18 +208,15 @@
});
return it('should support pills searches with filters', function() {
var actual, expected, liveCollection;
-
liveCollection = queryEngine.createLiveCollection().setFilter('search', function(model, searchString) {
var pass, searchRegex;
-
searchRegex = queryEngine.createSafeRegex(searchString);
pass = searchRegex.test(model.get('content'));
return pass;
}).setPill('category', {
prefixes: ['category:'],
callback: function(model, value) {
var pass, pillRegex;
-
pillRegex = queryEngine.createSafeRegex(value);
pass = pillRegex.test(model.get('category'));
return pass;
@@ -248,11 +230,9 @@
});
describe('events', function(describe, it) {
var liveCollection;
-
liveCollection = queryEngine.createLiveCollection();
it('when query is called on our liveCollection, it should successfully filter our models', function() {
var actual, expected;
-
liveCollection.add(models).setQuery('only jquery related', {
tags: {
$has: ['jquery']
@@ -264,39 +244,34 @@
});
it('when a model that passes our rules is added to our liveCollection, it should be added', function() {
var actual, expected;
-
liveCollection.add(ajaxyModel);
actual = liveCollection.toJSON();
expected = [modelsObject.jquery, modelsObject.history, ajaxyModel];
return assert.deepEqual(actual, expected);
});
it('when a model that fails our rules is added to our liveCollection, it should NOT be added', function() {
var actual, expected;
-
liveCollection.add(pokemonModel);
actual = liveCollection.toJSON();
expected = [modelsObject.jquery, modelsObject.history, ajaxyModel];
return assert.deepEqual(actual, expected);
});
it('when a model is removed from our liveCollection, it should be removed', function() {
var actual, expected;
-
liveCollection.remove(liveCollection.get('history'));
actual = liveCollection.toJSON();
expected = [modelsObject.jquery, ajaxyModel];
return assert.deepEqual(actual, expected);
});
it('when a model is changed in our liveCollection (and no longer supports our rules), it should be removed', function() {
var actual, expected;
-
liveCollection.get('jquery').set('tags', []);
actual = liveCollection.toJSON();
expected = [ajaxyModel];
return assert.deepEqual(actual, expected);
});
return it('when our liveCollection is reset, it should be empty', function() {
var actual, expected;
-
liveCollection.reset([]);
actual = liveCollection.toJSON();
expected = [];
@@ -305,11 +280,9 @@
});
describe('parent collections', function(describe, it) {
var childCollection, parentCollection;
-
parentCollection = queryEngine.createCollection(models);
it('should work with findAllLive with query', function() {
var actual, childCollection, expected;
-
childCollection = parentCollection.findAllLive({
tags: {
$has: ['jquery']
@@ -321,7 +294,6 @@
});
it('should work with findAllLive with query and comparator', function() {
var actual, childCollection, expected;
-
childCollection = parentCollection.findAllLive({
tags: {
$has: ['jquery']
@@ -336,7 +308,6 @@
childCollection = parentCollection.createLiveChildCollection();
it('when query is called on our childCollection, it should successfully filter our parentCollection', function() {
var actual, expected;
-
childCollection.setQuery('only jquery related', {
tags: {
$has: ['jquery']
@@ -348,47 +319,41 @@
});
it('when a model that passes our rules is added to the parentCollection, it should be added to the childCollection', function() {
var actual, expected;
-
parentCollection.add(ajaxyModel);
actual = childCollection.toJSON();
expected = [modelsObject.jquery, modelsObject.history, ajaxyModel];
return assert.deepEqual(actual, expected);
});
it('when a model that fails our rules is added to the parentCollection, it should NOT be added to the childCollection', function() {
var actual, expected;
-
parentCollection.add(pokemonModel);
actual = childCollection.toJSON();
expected = [modelsObject.jquery, modelsObject.history, ajaxyModel];
return assert.deepEqual(actual, expected);
});
it('when a model is removed from our parentCollection, it should be removed from our childCollection', function() {
var actual, expected;
-
parentCollection.remove(parentCollection.get('history'));
actual = childCollection.toJSON();
expected = [modelsObject.jquery, ajaxyModel];
return assert.deepEqual(actual, expected);
});
it('when a model is changed from our parentCollection (and no longer supports our rules), it should be removed from our childCollection', function() {
var actual, expected;
-
parentCollection.get('jquery').set('tags', []);
actual = childCollection.toJSON();
expected = [ajaxyModel];
return assert.deepEqual(actual, expected);
});
it('when a model is changed from our parentCollection (and now supports our rules), it should be added to our childCollection', function() {
var actual, expected;
-
parentCollection.get('jquery').set('tags', ['jquery']);
actual = childCollection.toJSON();
expected = [ajaxyModel, modelsObject.jquery];
return assert.deepEqual(actual, expected);
});
return it('when our parentCollection is reset, our childCollection should be reset too', function() {
var actual, expected;
-
parentCollection.reset([]);
actual = childCollection.toJSON();
expected = [];
@@ -397,7 +362,6 @@
});
return describe('parent collections: many levels', function(describe, it) {
var childCollectionLevel2, childCollectionLevel3, childCollectionLevel4, parentCollection;
-
parentCollection = queryEngine.createCollection(models);
childCollectionLevel2 = parentCollection.findAllLive({
tags: {
@@ -414,7 +378,6 @@
});
it('removes triggered by changes trickle through children correctly', function() {
var actual, expected;
-
parentCollection.where({
id: 'history'
})[0].set({
@@ -426,7 +389,6 @@
});
return it('additions triggered by changes trickle through children correctly', function() {
var actual, expected;
-
parentCollection.where({
id: 'history'
})[0].set({
View
1 out/test/misc-test.js
@@ -17,7 +17,6 @@
return describe('collection property', function(describe, it) {
return it('when specificied, should create child collections of the property type', function() {
var MyQueryCollection, myChildCollection, myQueryCollection, _ref;
-
MyQueryCollection = (function(_super) {
__extends(MyQueryCollection, _super);
View
11 out/test/queries-test.js
@@ -453,7 +453,6 @@
return _.each(queryTests, function(queryTest, queryTestName) {
return it(queryTestName, function() {
var actual, criteriaOptions, expected, expectedModelId, _i, _len, _ref;
-
if (queryTest.debug) {
debugger;
}
@@ -484,7 +483,6 @@
return _.each(queryTests, function(queryTest, queryTestName) {
return it(queryTestName, function() {
var actual, expected, expectedModelId, expectedModels, _i, _len, _ref;
-
if (queryTest.debug) {
debugger;
}
@@ -509,14 +507,12 @@
describe('special', function(describe, it) {
it('all', function() {
var actual, expected;
-
actual = store;
expected = store;
return assert.deepEqual(actual.toJSON(), expected.toJSON());
});
return it('findOne', function() {
var actual, expected;
-
actual = store.findOne({
tags: {
$has: 'jquery'
@@ -528,7 +524,6 @@
return describe('paging', function(describe, it) {
it('limit', function() {
var actual, expected;
-
actual = store.createChildCollection().query({
limit: 1
});
@@ -539,7 +534,6 @@
});
it('limit+page', function() {
var actual, expected;
-
actual = store.createChildCollection().query({
limit: 1,
page: 2
@@ -551,7 +545,6 @@
});
it('limit+offset', function() {
var actual, expected;
-
actual = store.createChildCollection().query({
limit: 1,
offset: 1
@@ -563,7 +556,6 @@
});
it('limit+offset+page', function() {
var actual, expected;
-
actual = store.createChildCollection().query({
limit: 1,
offset: 1,
@@ -577,7 +569,6 @@
it('limit+offset+page (via findAll)', function() {
debugger;
var actual, expected;
-
actual = store.findAll({
id: {
$exists: true
@@ -594,7 +585,6 @@
});
return it('offset', function() {
var actual, expected;
-
actual = store.createChildCollection().query({
offset: 1
});
@@ -611,7 +601,6 @@
describe('queries', function(describe, it) {
var store, storeName, _results;
-
_results = [];
for (storeName in stores) {
if (!__hasProp.call(stores, storeName)) continue;
View
18 out/test/sort-test.js
@@ -104,7 +104,6 @@
describe('sortArray', function(describe, it) {
it('string-object', function() {
var actual, expected;
-
actual = queryEngine.createCollection(docs.models).sortArray({
title: 1
});
@@ -113,7 +112,6 @@
});
it('numeric-function', function() {
var actual, expected;
-
actual = queryEngine.createCollection(docs.models).sortArray(function(a, b) {
return b.position - a.position;
});
@@ -122,7 +120,6 @@
});
it('numeric-object', function() {
var actual, expected;
-
actual = queryEngine.createCollection(docs.models).sortArray({
position: -1
});
@@ -131,7 +128,6 @@
});
it('date-function', function() {
var actual, expected;
-
actual = queryEngine.createCollection(docs.models).sortArray(function(a, b) {
return b.date - a.date;
});
@@ -140,7 +136,6 @@
});
return it('date-object', function() {
var actual, expected;
-
actual = queryEngine.createCollection(docs.models).sortArray({
date: -1
});
@@ -151,7 +146,6 @@
describe('sortCollection', function(describe, it) {
it('numeric-function', function() {
var actual, expected;
-
actual = queryEngine.createCollection(docs.models).sortCollection(function(a, b) {
return b.get('position') - a.get('position');
});
@@ -160,7 +154,6 @@
});
it('numeric-object', function() {
var actual, expected;
-
actual = queryEngine.createCollection(docs.models).sortCollection({
position: -1
});
@@ -169,7 +162,6 @@
});
it('date-function', function() {
var actual, expected;
-
actual = queryEngine.createCollection(docs.models).sortCollection(function(a, b) {
return b.get('date') - a.get('date');
});
@@ -178,7 +170,6 @@
});
return it('date-object', function() {
var actual, expected;
-
actual = queryEngine.createCollection(docs.models).sortCollection({
date: -1
});
@@ -189,7 +180,6 @@
describe('queryArray', function(describe, it) {
it('queryArray', function() {
var actual, expected;
-
actual = queryEngine.createCollection(docs.models).queryArray({
tags: {
$has: 'jquery'
@@ -202,7 +192,6 @@
});
return it('queryArray-paging', function() {
var actual, expected;
-
actual = queryEngine.createCollection(docs.models).queryArray({
tags: {
$has: 'jquery'
@@ -219,7 +208,6 @@
describe('findAll', function(describe, it) {
it('findAll', function() {
var actual, expected;
-
actual = queryEngine.createCollection(docs.models).findAll({
tags: {
$has: 'jquery'
@@ -232,7 +220,6 @@
});
return it('findAll-paging', function() {
var actual, expected;
-
actual = queryEngine.createCollection(docs.models).findAll({
tags: {
$has: 'jquery'
@@ -249,7 +236,6 @@
describe('findAllLive', function(describe, it) {
it('findAllLive', function() {
var actual, expected, parent;
-
actual = (parent = queryEngine.createCollection()).findAllLive({
tags: {
$has: 'jquery'
@@ -263,7 +249,6 @@
});
return it('findAllLive-paging', function() {
var actual, expected, parent;
-
actual = (parent = queryEngine.createCollection()).findAllLive({
tags: {
$has: 'jquery'
@@ -281,7 +266,6 @@
return describe('comparator', function(describe, it) {
it('live-onadd', function() {
var actual, expected;
-
actual = queryEngine.createLiveCollection().setComparator({
position: -1
}).add(docs.models);
@@ -290,7 +274,6 @@
});
return it('live-onchange', function() {
var actual, expected;
-
actual = queryEngine.createLiveCollection().setComparator({
position: -1
}).add(docs.models);
@@ -306,7 +289,6 @@
describe('sort', function(describe, it) {
var collectionName, docs, _results;
-
_results = [];
for (collectionName in store) {
if (!__hasProp.call(store, collectionName)) continue;
View
130 package.json
@@ -1,60 +1,74 @@
{
- "name": "query-engine",
- "version": "1.5.2",
- "description": "Query-Engine is a NoSQL and MongoDb compliant query engine. It can run on the server-side with Node.js, or on the client-side within web browsers",
- "homepage": "https://github.com/bevry/query-engine",
- "keywords": [
- "coffeescript",
- "query-engine",
- "nosql",
- "query",
- "sql",
- "pills",
- "search",
- "searching",
- "lucene",
- "filter",
- "filtering",
- "collections"
- ],
- "author": "Bevry Pty Ltd <us@bevry.me> (http://bevry.me)",
- "maintainers": [
- "Benjamin Lupton <b@lupton.cc> (https://github.com/balupton)"
- ],
- "contributors": [
- "Benjamin Lupton <b@lupton.cc> (https://github.com/balupton)",
- "Farid Neshat <FaridN_SOAD@yahoo.com> (https://github.com/alFReD-NSH)",
- "Nicholas Firth-McCoy (https://github.com/nfm)",
- "Khalid Jebbari <https://github.com/DjebbZ> (https://github.com/DjebbZ)",
- "Andrew Shults <andrewjshults@gmail.com> (https://github.com/andrewjshults)"
- ],
- "bugs": {
- "url": "https://github.com/bevry/query-engine/issues"
- },
- "repository" : {
- "type": "git",
- "url": "http://github.com/bevry/query-engine.git"
- },
- "dependencies": {},
- "peerDependencies": {
- "backbone": "*"
- },
- "devDependencies": {
- "backbone": "~1.0.0",
- "coffee-script": "~1.6.2",
- "bal-util": "~2.0.5",
- "docpad": ">=6.21.5 <7",
- "docpad-plugin-coffeescript": "2.x",
- "underscore": "~1.4.4",
- "joe": "~1.2.0",
- "joe-reporter-list": "~1.2.1",
- "benchmark": "~1.0.0"
- },
- "directories": {
- "lib": "./out/lib"
- },
- "scripts": {
- "test": "./node_modules/.bin/cake test"
- },
- "main": "./out/lib/query-engine.js"
+ "title": "QueryEngine",
+ "name": "query-engine",
+ "version": "1.5.3",
+ "description": "Query-Engine is a NoSQL and MongoDb compliant query engine. It can run on the server-side with Node.js, or on the client-side within web browsers",
+ "homepage": "https://github.com/bevry/query-engine",
+ "license": {
+ "type": "MIT"
+ },
+ "badges": {