joosy 1.2.0.alpha.51 → 1.2.0.alpha.52
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bower.json +1 -1
- data/build/joosy/extensions/resources.js +34 -34
- data/package.json +3 -3
- data/source/joosy/extensions/resources/base.coffee +0 -30
- data/source/joosy/extensions/resources/rest.coffee +38 -0
- data/spec/joosy/extensions/resources/base_spec.coffee +0 -28
- data/spec/joosy/extensions/resources/rest_spec.coffee +28 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d5c51a78e39be79cd68e82ecf4df0e284ca1fe6
|
4
|
+
data.tar.gz: e45f97697a02edbe7874f88e53c30f1a7b8a3825
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e76c7307e635d877812fb8bdbc652127d70219e367766e885fe9965dfe7d608f2472b142371bbbfa0903618711535035c005bb17b4187aa1f54b7f5bc84fa5e6
|
7
|
+
data.tar.gz: 41f0bf6bddd0dca9840babbe7f2b21c729d6042f04049c15f3364be7a7f74f9c481ae3d57e1ecfde2005221b49c7e8f160852aa8842fea3cfc65a40d930b6468
|
data/bower.json
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
(function() {
|
2
2
|
var __hasProp = {}.hasOwnProperty,
|
3
|
-
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }
|
4
|
-
__slice = [].slice;
|
3
|
+
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
5
4
|
|
6
5
|
Joosy.Resources.Base = (function(_super) {
|
7
6
|
__extends(Base, _super);
|
@@ -29,37 +28,6 @@
|
|
29
28
|
return this.prototype.__primaryKey = primaryKey;
|
30
29
|
};
|
31
30
|
|
32
|
-
Base.source = function(location) {
|
33
|
-
return this.__source = location;
|
34
|
-
};
|
35
|
-
|
36
|
-
Base.at = function() {
|
37
|
-
var Clone, args, _ref;
|
38
|
-
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
39
|
-
Clone = (function(_super1) {
|
40
|
-
__extends(Clone, _super1);
|
41
|
-
|
42
|
-
function Clone() {
|
43
|
-
_ref = Clone.__super__.constructor.apply(this, arguments);
|
44
|
-
return _ref;
|
45
|
-
}
|
46
|
-
|
47
|
-
return Clone;
|
48
|
-
|
49
|
-
})(this);
|
50
|
-
if (args.length === 1 && Object.isArray(args[0])) {
|
51
|
-
return this.at.apply(this, args[0]);
|
52
|
-
} else {
|
53
|
-
Clone.__source = args.reduce(function(path, arg) {
|
54
|
-
return path += arg instanceof Joosy.Resources.Base ? arg.memberPath() : arg.replace(/^\/?/, '/');
|
55
|
-
}, '');
|
56
|
-
if (this.prototype.__entityName && args[args.length - 1] instanceof Joosy.Resources.Base) {
|
57
|
-
Clone.__source += '/' + this.prototype.__entityName.pluralize();
|
58
|
-
}
|
59
|
-
return Clone;
|
60
|
-
}
|
61
|
-
};
|
62
|
-
|
63
31
|
Base.entity = function(name) {
|
64
32
|
return this.prototype.__entityName = name;
|
65
33
|
};
|
@@ -402,7 +370,8 @@
|
|
402
370
|
(function() {
|
403
371
|
var _ref,
|
404
372
|
__hasProp = {}.hasOwnProperty,
|
405
|
-
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }
|
373
|
+
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
374
|
+
__slice = [].slice;
|
406
375
|
|
407
376
|
Joosy.Resources.REST = (function(_super) {
|
408
377
|
__extends(REST, _super);
|
@@ -412,6 +381,37 @@
|
|
412
381
|
return _ref;
|
413
382
|
}
|
414
383
|
|
384
|
+
REST.source = function(location) {
|
385
|
+
return this.__source = location;
|
386
|
+
};
|
387
|
+
|
388
|
+
REST.at = function() {
|
389
|
+
var Clone, args, _ref1;
|
390
|
+
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
391
|
+
Clone = (function(_super1) {
|
392
|
+
__extends(Clone, _super1);
|
393
|
+
|
394
|
+
function Clone() {
|
395
|
+
_ref1 = Clone.__super__.constructor.apply(this, arguments);
|
396
|
+
return _ref1;
|
397
|
+
}
|
398
|
+
|
399
|
+
return Clone;
|
400
|
+
|
401
|
+
})(this);
|
402
|
+
if (args.length === 1 && Object.isArray(args[0])) {
|
403
|
+
return this.at.apply(this, args[0]);
|
404
|
+
} else {
|
405
|
+
Clone.__source = args.reduce(function(path, arg) {
|
406
|
+
return path += arg instanceof Joosy.Resources.Base ? arg.memberPath() : arg.replace(/^\/?/, '/');
|
407
|
+
}, '');
|
408
|
+
if (this.prototype.__entityName && args[args.length - 1] instanceof Joosy.Resources.Base) {
|
409
|
+
Clone.__source += '/' + this.prototype.__entityName.pluralize();
|
410
|
+
}
|
411
|
+
return Clone;
|
412
|
+
}
|
413
|
+
};
|
414
|
+
|
415
415
|
REST.prototype.__collection = function() {
|
416
416
|
var named;
|
417
417
|
named = this.__entityName.camelize().pluralize() + 'Collection';
|
data/package.json
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
"keywords": [
|
5
5
|
"joosy"
|
6
6
|
],
|
7
|
-
"version": "1.2.0-alpha.
|
7
|
+
"version": "1.2.0-alpha.52",
|
8
8
|
"author": "Boris Staal <boris@staal.io>",
|
9
9
|
"homepage": "http://joosy.ws/",
|
10
10
|
"repository": {
|
@@ -18,7 +18,7 @@
|
|
18
18
|
"node": ">=0.4.0"
|
19
19
|
},
|
20
20
|
"dependencies": {
|
21
|
-
"bower": "~1.
|
21
|
+
"bower": "~1.1.0",
|
22
22
|
"sugar": "~1.3.8",
|
23
23
|
"coffee-script": "~1.6.3",
|
24
24
|
"command-router": "0.0.5",
|
@@ -28,7 +28,7 @@
|
|
28
28
|
"commander": "~1.2.0",
|
29
29
|
"colors": "~0.6.0-1",
|
30
30
|
"grunt": "~0.4.1",
|
31
|
-
"mincer": "
|
31
|
+
"mincer": "0.5.2",
|
32
32
|
"connect": "~2.7.11",
|
33
33
|
"haml-coffee": "~1.11.1",
|
34
34
|
"proxy-middleware": "~0.4.0",
|
@@ -57,36 +57,6 @@ class Joosy.Resources.Base extends Joosy.Module
|
|
57
57
|
#
|
58
58
|
@primaryKey: (primaryKey) -> @::__primaryKey = primaryKey
|
59
59
|
|
60
|
-
@source: (location) ->
|
61
|
-
@__source = location
|
62
|
-
|
63
|
-
#
|
64
|
-
# Creates the proxy of current resource binded as a child of given entity
|
65
|
-
#
|
66
|
-
@at: (args...) ->
|
67
|
-
#
|
68
|
-
# Class inheritance used to create proxy
|
69
|
-
#
|
70
|
-
# @private
|
71
|
-
#
|
72
|
-
class Clone extends this
|
73
|
-
|
74
|
-
if args.length == 1 && Object.isArray(args[0])
|
75
|
-
@at(args[0]...)
|
76
|
-
else
|
77
|
-
Clone.__source = args.reduce (path, arg) ->
|
78
|
-
path += if arg instanceof Joosy.Resources.Base
|
79
|
-
arg.memberPath()
|
80
|
-
else
|
81
|
-
arg.replace(/^\/?/, '/')
|
82
|
-
|
83
|
-
, ''
|
84
|
-
|
85
|
-
if @::__entityName && args[args.length - 1] instanceof Joosy.Resources.Base
|
86
|
-
Clone.__source += '/' + @::__entityName.pluralize()
|
87
|
-
|
88
|
-
Clone
|
89
|
-
|
90
60
|
#
|
91
61
|
# Sets the entity text name:
|
92
62
|
# required to do some magic like skipping the root node.
|
@@ -6,6 +6,44 @@
|
|
6
6
|
#
|
7
7
|
class Joosy.Resources.REST extends Joosy.Resources.Base
|
8
8
|
|
9
|
+
#
|
10
|
+
# Sets default base url for fetching and modifiing resources
|
11
|
+
#
|
12
|
+
# @note can be omitted if url equals pluralized @entity
|
13
|
+
# i.e. 'comment' entity name => '/comments' url
|
14
|
+
#
|
15
|
+
# @param [String] primary Name of the field
|
16
|
+
#
|
17
|
+
@source: (location) ->
|
18
|
+
@__source = location
|
19
|
+
|
20
|
+
#
|
21
|
+
# Creates the proxy of current resource binded as a child of given entity
|
22
|
+
#
|
23
|
+
@at: (args...) ->
|
24
|
+
#
|
25
|
+
# Class inheritance used to create proxy
|
26
|
+
#
|
27
|
+
# @private
|
28
|
+
#
|
29
|
+
class Clone extends this
|
30
|
+
|
31
|
+
if args.length == 1 && Object.isArray(args[0])
|
32
|
+
@at(args[0]...)
|
33
|
+
else
|
34
|
+
Clone.__source = args.reduce (path, arg) ->
|
35
|
+
path += if arg instanceof Joosy.Resources.Base
|
36
|
+
arg.memberPath()
|
37
|
+
else
|
38
|
+
arg.replace(/^\/?/, '/')
|
39
|
+
|
40
|
+
, ''
|
41
|
+
|
42
|
+
if @::__entityName && args[args.length - 1] instanceof Joosy.Resources.Base
|
43
|
+
Clone.__source += '/' + @::__entityName.pluralize()
|
44
|
+
|
45
|
+
Clone
|
46
|
+
|
9
47
|
#
|
10
48
|
# Implements `@collection` default behavior.
|
11
49
|
# Changes the default fallback to Joosy.Resources.RESTCollection.
|
@@ -51,34 +51,6 @@ describe "Joosy.Resources.Base", ->
|
|
51
51
|
@resource 'another.deep.value', 'banana strikes back'
|
52
52
|
expect(@resource 'another.deep').toEqual value: 'banana strikes back'
|
53
53
|
|
54
|
-
describe '@at', ->
|
55
|
-
# clone won't be instanceof Fluffy in IE
|
56
|
-
#expect(clone.build({}) instanceof Fluffy).toBeTruthy()
|
57
|
-
|
58
|
-
beforeEach ->
|
59
|
-
class @Fluffy extends Joosy.Resources.Base
|
60
|
-
@entity 'fluffy'
|
61
|
-
|
62
|
-
it 'returns base class child', ->
|
63
|
-
clone = @Fluffy.at 'rumbas'
|
64
|
-
expect(Joosy.Module.hasAncestor clone, @Fluffy).toBeTruthy()
|
65
|
-
|
66
|
-
it 'accepts string', ->
|
67
|
-
clone = @Fluffy.at 'rumbas'
|
68
|
-
expect(clone.__source).toEqual '/rumbas'
|
69
|
-
|
70
|
-
it 'accepts another resource instance', ->
|
71
|
-
clone = @Fluffy.at Test.build(1)
|
72
|
-
expect(clone.__source).toEqual '/tests/1/fluffies'
|
73
|
-
|
74
|
-
it 'accepts array', ->
|
75
|
-
clone = @Fluffy.at ['rumbas', Test.build(1), 'salsas']
|
76
|
-
expect(clone.__source).toEqual '/rumbas/tests/1/salsas'
|
77
|
-
|
78
|
-
it 'accepts sequential attributes', ->
|
79
|
-
clone = @Fluffy.at 'rumbas', 'salsas', Test.build(1)
|
80
|
-
expect(clone.__source).toEqual '/rumbas/salsas/tests/1/fluffies'
|
81
|
-
|
82
54
|
it "triggers 'changed' right", ->
|
83
55
|
callback = sinon.spy()
|
84
56
|
@resource.bind 'changed', callback
|
@@ -28,6 +28,34 @@ describe "Joosy.Resources.REST", ->
|
|
28
28
|
expect(target.url).toMatch url
|
29
29
|
target.respond 200, 'Content-Type': 'application/json', data
|
30
30
|
|
31
|
+
describe '@at', ->
|
32
|
+
# clone won't be instanceof Fluffy in IE
|
33
|
+
#expect(clone.build({}) instanceof Fluffy).toBeTruthy()
|
34
|
+
|
35
|
+
beforeEach ->
|
36
|
+
class @Test extends Joosy.Resources.REST
|
37
|
+
@entity 'test'
|
38
|
+
|
39
|
+
it 'returns base class child', ->
|
40
|
+
clone = @Test.at 'rumbas'
|
41
|
+
expect(Joosy.Module.hasAncestor clone, @Test).toBeTruthy()
|
42
|
+
|
43
|
+
it 'accepts string', ->
|
44
|
+
clone = @Test.at 'rumbas'
|
45
|
+
expect(clone.__source).toEqual '/rumbas'
|
46
|
+
|
47
|
+
it 'accepts another resource instance', ->
|
48
|
+
clone = @Test.at Fluffy.build(1)
|
49
|
+
expect(clone.__source).toEqual '/fluffies/1/tests'
|
50
|
+
|
51
|
+
it 'accepts array', ->
|
52
|
+
clone = @Test.at ['rumbas', Fluffy.build(1), 'salsas']
|
53
|
+
expect(clone.__source).toEqual '/rumbas/fluffies/1/salsas'
|
54
|
+
|
55
|
+
it 'accepts sequential attributes', ->
|
56
|
+
clone = @Test.at 'rumbas', 'salsas', Fluffy.build(1)
|
57
|
+
expect(clone.__source).toEqual '/rumbas/salsas/fluffies/1/tests'
|
58
|
+
|
31
59
|
it "build base path", ->
|
32
60
|
parent = FluffyParent.build 1
|
33
61
|
grandParent = FluffyParent.build 666
|