Start of new idea. Doesn't do much of anything yet.
The plan is to allow for a kind of Copy-On-Write or Overlay feature to be made available to Backbone models.
Showing
8 changed files
with
152 additions
and
0 deletions
.gitignore
0 → 100644
Gruntfile.js
0 → 100644
1 | /* global module */ | ||
2 | |||
3 | module.exports = function (grunt) { | ||
4 | /* global require */ | ||
5 | 'use strict'; | ||
6 | |||
7 | var config = {}; | ||
8 | config.base = 'src'; | ||
9 | config.jshint = { | ||
10 | options: { | ||
11 | }, | ||
12 | browserOptions: { | ||
13 | }, | ||
14 | }; | ||
15 | config.jscs = { | ||
16 | options: { | ||
17 | validateIndentation: 4, | ||
18 | reporter: 'console', | ||
19 | maxErrors: -1, | ||
20 | }, | ||
21 | }; | ||
22 | config.bower = { | ||
23 | directory: 'lib/bower', | ||
24 | }; | ||
25 | config.jasmine = { | ||
26 | withCoverage: true, | ||
27 | }; | ||
28 | var montyPython = require('grunt-monty-python')(grunt); | ||
29 | montyPython.createConfig(config); | ||
30 | }; |
bower.json
0 → 100644
1 | { | ||
2 | "name": "backbone-model-overlay", | ||
3 | "version": "0.0.0", | ||
4 | "authors": [ | ||
5 | "Adam Heath <doogie@brainfood.com>" | ||
6 | ], | ||
7 | "main": [ | ||
8 | "src/scripts/backbone-model-overlay.js" | ||
9 | ], | ||
10 | "private": true, | ||
11 | "ignore": [ | ||
12 | "**/.*", | ||
13 | "node_modules", | ||
14 | "src/lib" | ||
15 | ], | ||
16 | "dependencies": { | ||
17 | "backbone": "", | ||
18 | "jquery": "", | ||
19 | "requirejs": "", | ||
20 | "underscore": "" | ||
21 | } | ||
22 | } |
package.json
0 → 100644
1 | { | ||
2 | "name": "backbone-model-overlay", | ||
3 | "version": "0.0.0", | ||
4 | "main": [ | ||
5 | "src/scripts/backbone-model-overlay.js" | ||
6 | ], | ||
7 | "dependencies": { | ||
8 | "rivets": "", | ||
9 | "requirejs": "" | ||
10 | }, | ||
11 | "devDependencies": { | ||
12 | "bower-requirejs": "~0.9.2", | ||
13 | "grunt": "~0", | ||
14 | "grunt-monty-python": "git+ssh://git@gitlab.brainfood.com:brainfood/grunt-monty-python.git" | ||
15 | }, | ||
16 | "engines": { | ||
17 | "node": ">=0.8.0" | ||
18 | } | ||
19 | } | ||
20 |
src/scripts/backbone-model-overlay.js
0 → 100644
1 | define(function(require) { | ||
2 | 'use strict'; | ||
3 | var module = require('module'); | ||
4 | var Backbone = require('backbone'); | ||
5 | |||
6 | var BackboneModelOverlay = Backbone.Model.extend({ | ||
7 | initialize: function(data, options) { | ||
8 | BackboneModelOverlay.__super__.initialize.apply(this, arguments); | ||
9 | }, | ||
10 | }); | ||
11 | return BackboneModelOverlay; | ||
12 | }); |
src/scripts/backbone-model-overlay.spec.js
0 → 100644
1 | define(function(require) { | ||
2 | 'use strict'; | ||
3 | |||
4 | var $ = require('jquery'); | ||
5 | window.jQuery = $; | ||
6 | var _ = require('underscore'); | ||
7 | var Backbone = require('backbone'); | ||
8 | var BackboneModelOverlay = require('backbone-model-overlay'); | ||
9 | |||
10 | describe('BackboneModelOverlay', function() { | ||
11 | it('exists', function() { | ||
12 | expect(BackboneModelOverlay).toBeDefined(); | ||
13 | }); | ||
14 | }); | ||
15 | describe('BackboneModelOverlay', function() { | ||
16 | var model; | ||
17 | beforeEach(function() { | ||
18 | model = new BackboneModelOverlay(); | ||
19 | }); | ||
20 | describe('empty', function() { | ||
21 | it('get', function() { | ||
22 | expect(model.get('missing')).toBeUndefined(); | ||
23 | }); | ||
24 | it('toJSON', function() { | ||
25 | expect(model.toJSON()).toEqual({}); | ||
26 | }); | ||
27 | }); | ||
28 | }); | ||
29 | }); |
src/scripts/config.js
0 → 100644
1 | /* global require:true */ | ||
2 | var require; | ||
3 | require = (function() { | ||
4 | 'use strict'; | ||
5 | |||
6 | var require = { | ||
7 | baseUrl: 'scripts', | ||
8 | config: { | ||
9 | 'backbone-model-overlay': {}, | ||
10 | }, | ||
11 | shim: { | ||
12 | backbone: { | ||
13 | deps: ['underscore'], | ||
14 | exports: 'Backbone', | ||
15 | }, | ||
16 | underscore: { | ||
17 | exports: '_', | ||
18 | }, | ||
19 | }, | ||
20 | paths: { | ||
21 | backbone: '../lib/bower/backbone/backbone', | ||
22 | underscore: '../lib/bower/underscore/underscore', | ||
23 | jquery: '../lib/bower/jquery/dist/jquery', | ||
24 | }, | ||
25 | }; | ||
26 | |||
27 | return require; | ||
28 | })(); |
src/scripts/main.js
0 → 100644
-
Please register or sign in to post a comment