Commit 83f7f566 authored by David Trudgian's avatar David Trudgian
Browse files

Initial import

parents
{
"directory": "bower_components/",
"analytics": false
}
* text=auto
\ No newline at end of file
{
"node": true,
"browser": true,
"esnext": true,
"bitwise": false,
"curly": false,
"eqeqeq": true,
"eqnull": true,
"immed": true,
"latedef": true,
"newcap": true,
"noarg": true,
"undef": true,
"strict": false,
"trailing": false,
"smarttabs": true,
"globals": {
"BiohpcSbatch": true,
"jQuery": true,
"Ember": true,
"Handlebars": true,
"DS": true
}
}
{
"name": "biohpcsbatch",
"version": "0.0.0",
"dependencies": {
"jquery": "~2.1.0",
"handlebars": "~2.0.0",
"ember": "~1.9.1",
"ember-data": "1.0.0-beta.14.1",
"ember-localstorage-adapter": "latest",
"ember-validations-nocli": "latest"
},
"resolutions": {
"handlebars": ">= 2.0.0 < 3.0.0"
}
}
{
"name": "ember-data",
"version": "1.0.0-beta.14.1",
"main": "ember-data.js",
"dependencies": {
"ember": ">= 1.8.1 < 2.0.0"
},
"ignore": [
"**/*_configuration.js",
"ember-data-setup.js",
"docs",
"**/*.html"
],
"homepage": "https://github.com/components/ember-data",
"_release": "1.0.0-beta.14.1",
"_resolution": {
"type": "version",
"tag": "1.0.0-beta.14.1",
"commit": "7dd377bae744124c248449d306f76030b89a8a16"
},
"_source": "https://github.com/components/ember-data.git",
"_target": ">= 1.0.0-beta.6",
"_originalSource": "ember-data"
}
\ No newline at end of file
components
node_modules
vendor
composer.lock
data
VERSION=v1.0.0-beta.14
default:
@curl -O http://builds.emberjs.com/tags/$(VERSION)/ember-data.js
@curl -O http://builds.emberjs.com/tags/$(VERSION)/ember-data.min.js
@curl -O http://builds.emberjs.com/tags/$(VERSION)/ember-data.prod.js
@curl -O http://builds.emberjs.com/tags/$(VERSION)/ember-data.js.map
.PHONY: default
Ember Data
==========
Shim repository for the [Ember.js Data](http://github.com/emberjs/data) component.
Package Managers
----------------
* [Bower](http://bower.io): `ember-data`
* [Component](http://component.io): `components/ember-data`
* [Composer](http://packagist.org/packages/components/ember): `components/ember-data`
{
"name": "ember-data",
"version": "1.0.0-beta.14.1",
"main": "ember-data.js",
"dependencies": {
"ember": ">= 1.8.1 < 2.0.0"
},
"ignore": [
"**/*_configuration.js",
"ember-data-setup.js",
"docs",
"**/*.html"
]
}
{
"name": "ember-data",
"repo": "components/ember-data",
"description": "A data persistence library for Ember.js.",
"version": "1.0.0-beta.14.1",
"main": "ember-data.js",
"scripts": [
"ember-data.js",
"ember-data.min.js",
"ember-data.prod.js"
],
"dependencies": {
"components/ember": ">= 1.8.1 < 2.0.0"
},
"license": "MIT"
}
{
"name": "components/ember-data",
"description": "A data persistence library for Ember.js.",
"type": "component",
"license": "MIT",
"require": {
"components/ember": "~1.8.1"
},
"extra": {
"component": {
"scripts": [
"ember-data.js"
],
"files": [
"ember-data.min.js",
"ember-data.prod.js"
],
"shim": {
"exports": "Ember",
"deps": [
"ember"
]
}
}
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
{
"name": "components-ember-data",
"version": "1.0.0-beta.14.1",
"description": "A data persistence library for Ember.js.",
"keywords": [
"ember"
],
"main": "./ember-data.js",
"dependencies": {
"ember": ">= 1.8.1 < 2.0.0"
}
}
{
"name": "ember-localstorage-adapter",
"version": "0.5.0",
"homepage": "https://github.com/rpflorence/ember-localstorage-adapter",
"authors": [
"Ryan Florence <rpflorence@gmail.com>"
],
"description": "Store your ember application data in localStorage.",
"main": "localstorage_adapter.js",
"keywords": [
"localstorage",
"ember",
"ember-data"
],
"license": "MIT",
"ignore": [
"script",
"test",
"vendor"
],
"dependencies": {
"ember-data": ">= 1.0.0-beta.6",
"ember": ">= 1.0.0"
},
"_release": "0.5.0",
"_resolution": {
"type": "version",
"tag": "0.5.0",
"commit": "d310938c9b80e1eb8c34b230f483b9a8010cdf77"
},
"_source": "https://github.com/rpflorence/ember-localstorage-adapter.git",
"_target": "*",
"_originalSource": "ember-localstorage-adapter"
}
\ No newline at end of file
tmp-update
bower_components
node_modules
ember-localstorage-adapter
language: node_js
before_script:
- npm install -g bower
- bower install
script: "phantomjs test/runner.js test/index.html"
# ember-localstorage-adapter
## Master
### 0.3.2 (June 27, 2014)
* `#find` rejects its promise if no record is found.
* `#findQuery` rejects its promise if no records are found.
The MIT License (MIT)
Copyright (c) 2012 Ryan Florence
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.
\ No newline at end of file
Ember Data Local Storage Adapter
================================
[![Build
Status](https://travis-ci.org/kurko/ember-localstorage-adapter.svg?branch=master)](https://travis-ci.org/kurko/ember-localstorage-adapter)
Store your ember application data in localStorage.
Compatible with Ember Data 1.0.beta.6.
**NOTE**: New versions of the `localStorage` adapter are no longer compatible
with older versions of Ember Data. For older versions, checkout the `pre-beta`
branch.
Usage
-----
Include `localstorage_adapter.js` in your app and then like all adapters:
```js
App.ApplicationSerializer = DS.LSSerializer.extend();
App.ApplicationAdapter = DS.LSAdapter.extend({
namespace: 'yournamespace'
});
```
If you are using Ember Localstorage Adapter within an Ember CLI project you can install it as an addon with the following command:
```sh
npm install --save-dev ember-localstorage-adapter
```
Then in Brocfile.js import it before module.exports:
```js
app.import('bower_components/ember-localstorage-adapter/localstorage_adapter.js');
module.exports = app.toTree();
```
### Local Storage Namespace
All of your application data lives on a single `localStorage` key, it defaults to `DS.LSAdapter` but if you supply a `namespace` option it will store it there:
```js
DS.LSAdapter.create({
namespace: 'my app'
});
```
### Models
Whenever the adapter returns a record, it'll also return all
relationships, so __do not__ use `{async: true}` in you model definitions.
#### Namespace
If your model definition has a `url` property, the adapter will store the data on that namespace. URL is a weird term in this context, but it makes swapping out adapters simpler by not requiring additional properties on your models.
```js
var List = DS.Model.extend({
// ...
});
List.reopen({
url: '/some/url'
});
```
### Quota Exceeded Handler
Browser's `localStorage` has limited space, if you try to commit application data and the browser is out of space, then the adapter will trigger the `QUOTA_EXCEEDED_ERR` event.
```js
App.store.adapter.on('QUOTA_EXCEEDED_ERR', function(records){
// do stuff
});
App.store.commit();
```
Todo
----
- Make the repo nicer to work with long-term (do something more intelligent with dependencies found in `vendor`, etc.)
Tests
-----
If you don't have bower, install it with
npm install bower -g
Then install the dependencies with
bower install
Open `test/index.html` in a browser. If you have `phantomjs` installed,
run
phantomjs test/runner.js test/index.html
License & Copyright
-------------------
Copyright (c) 2012 Ryan Florence
MIT Style license. http://opensource.org/licenses/MIT
{
"name": "ember-localstorage-adapter",
"version": "0.5.0",
"homepage": "https://github.com/rpflorence/ember-localstorage-adapter",
"authors": [
"Ryan Florence <rpflorence@gmail.com>"
],
"description": "Store your ember application data in localStorage.",
"main": "localstorage_adapter.js",
"keywords": [
"localstorage",
"ember",
"ember-data"
],
"license": "MIT",
"ignore": [
"script",
"test",
"vendor"
],
"dependencies": {
"ember-data": ">= 1.0.0-beta.6",
"ember": ">= 1.0.0"
}
}
'use strict';
var path = require('path');
var fs = require('fs');
module.exports = {
name: 'Ember Localstorage Adapter',
treeFor: function(name) {
if (name !== 'vendor') { return; }
var treePath = path.join(__dirname, '..', 'ember-localstorage-adapter');
var namespacedPath = path.join(treePath, 'ember-localstorage-adapter');
if(!fs.existsSync(namespacedPath)) {
fs.mkdirSync(namespacedPath);
}
fs.writeFileSync(
path.join(namespacedPath, 'localstorage_adapter.js'),
fs.readFileSync(path.join(treePath, 'localstorage_adapter.js'), {encoding: 'utf8'})
);
return unwatchedTree(treePath);
},
included: function(app){
this.app = app;
this.app.import('vendor/ember-localstorage-adapter/localstorage_adapter.js');
}
};
function unwatchedTree(dir) {
return {
read: function() { return dir; },
cleanup: function() { }
};
};
/*global Ember*/
/*global DS*/
(function () {
'use strict';
DS.LSSerializer = DS.JSONSerializer.extend({
serializeHasMany: function(record, json, relationship) {
var key = relationship.key;
var payloadKey = this.keyForRelationship ? this.keyForRelationship(key, "hasMany") : key;
var relationshipType = record.constructor.determineRelationshipType(relationship);
if (relationshipType === 'manyToNone' ||
relationshipType === 'manyToMany' ||
relationshipType === 'manyToOne') {
json[payloadKey] = record.get(key).mapBy('id');
// TODO support for polymorphic manyToNone and manyToMany relationships
}
},
/**
* Extracts whatever was returned from the adapter.
*
* If the adapter returns relationships in an embedded way, such as follows:
*
* ```js
* {
* "id": 1,
* "title": "Rails Rambo",
*
* "_embedded": {
* "comment": [{
* "id": 1,
* "comment_title": "FIRST"
* }, {
* "id": 2,
* "comment_title": "Rails is unagi"
* }]
* }
* }
*
* this method will create separated JSON for each resource and then push
* them individually to the Store.
*
* In the end, only the main resource will remain, containing the ids of its
* relationships. Given the relations are already in the Store, we will
* return a JSON with the main resource alone. The Store will sort out the
* associations by itself.
*
* @method extractSingle
* @private
* @param {DS.Store} store the returned store
* @param {DS.Model} type the type/model
* @param {Object} payload returned JSON
*/
extractSingle: function(store, type, payload) {
if (payload && payload._embedded) {
for (var relation in payload._embedded) {
var relType = type.typeForRelationship(relation);
var typeName = relType.typeKey,
embeddedPayload = payload._embedded[relation];
if (embeddedPayload) {
if (Ember.isArray(embeddedPayload)) {
store.pushMany(typeName, embeddedPayload);
} else {
store.push(typeName, embeddedPayload);
}
}
}
delete payload._embedded;
}
return this.normalize(type, payload);
},
/**
* This is exactly the same as extractSingle, but used in an array.
*
* @method extractSingle
* @private
* @param {DS.Store} store the returned store
* @param {DS.Model} type the type/model
* @param {Array} payload returned JSONs
*/
extractArray: function(store, type, payload) {
return payload.map(function(json) {
return this.extractSingle(store, type, json);
}, this);
}
});
DS.LSAdapter = DS.Adapter.extend(Ember.Evented, {
/**
This is the main entry point into finding records. The first parameter to
this method is the model's name as a string.
@method find
@param {DS.Model} type
@param {Object|String|Integer|null} id
*/
find: function(store, type, id, opts) {
var allowRecursive = true;
var namespace = this._namespaceForType(type);
var record = Ember.A(namespace.records[id]);
/**
* In the case where there are relationships, this method is called again
* for each relation. Given the relations have references to the main
* object, we use allowRecursive to avoid going further into infinite
* recursiveness.
*
* Concept from ember-indexdb-adapter
*/
if (opts && typeof opts.allowRecursive !== 'undefined') {
allowRecursive = opts.allowRecursive;
}
if (!record || !record.hasOwnProperty('id')) {
return Ember.RSVP.reject(new Error("Couldn't find record of"
+ " type '" + type.typeKey
+ "' for the id '" + id + "'."));
}
if (allowRecursive) {
return this.loadRelationships(type, record);
} else {
return Ember.RSVP.resolve(record);
}
},
findMany: function (store, type, ids, opts) {
var namespace = this._namespaceForType(type);
var adapter = this,
allowRecursive = true,
results = [], record;
/**
* In the case where there are relationships, this method is called again