Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

- refactored out Locator.URL, InternalURL&ExternalURL resources

  • Loading branch information...
commit 5d3a50a2674be539a553d040bb8c15f53fa52bef 1 parent 2d88e72
Nickolay Platonov authored
View
5 Components.JS
@@ -22,11 +22,6 @@ COMPONENTS = {
"JooseX.Namespace.Depended.Transport.XHRSync",
"JooseX.Namespace.Depended.Transport.ScriptTag",
-
- "JooseX.Namespace.Depended.Locator.URL",
- "JooseX.Namespace.Depended.Resource.ExternalURL",
- "JooseX.Namespace.Depended.Resource.InternalURL",
-
"JooseX.Namespace.Depended",
"JooseX.Namespace.Depended.Bootstrap.Web"
View
88 lib/JooseX/Namespace/Depended/Locator/URL.js
@@ -1,88 +0,0 @@
-//describes the behavior of resource, who's token is an URL
-
-Role('JooseX.Namespace.Depended.Locator.URL', {
-
- methods : {
-
- getUrls : function () {
- var url = this.token
-
- if (/^http/.test(url) || /^\//.test(url)) return [ url ]
-
- var urls = []
-
- Joose.A.each(JooseX.Namespace.Depended.Manager.my.INC, function (libroot) {
- urls.push(libroot.replace(/\/?$/, '/') + url)
- })
-
- return urls
- }
- }
-})
-
-
-/**
-
-Name
-====
-
-
-JooseX.Namespace.Depended.Locator.URL - locator, which treat the `token` property of the resource as URL
-
-
-SYNOPSIS
-========
-
- //generally for consuming only
-
- Class("JooseX.Namespace.Depended.Resource.Custom", {
-
- isa : JooseX.Namespace.Depended.Resource,
-
- does : [ JooseX.Namespace.Depended.Locator.URL, ...]
-
- ...
- })
-
-
-DESCRIPTION
-===========
-
-`JooseX.Namespace.Depended.Locator.URL` is a locator role. It provide the implementation of `getUrls` method.
-
-
-SEE ALSO
-========
-
-Authoring [JooseX.Namespace.Depended](../Authoring.html)
-
-Abstract base resource class: [JooseX.Namespace.Depended.Resource](../Resource.html)
-
-
-General documentation for Joose: <http://openjsan.org/go/?l=Joose>
-
-
-AUTHORS
-=======
-
-Nickolay Platonov <nplatonov@cpan.org>
-
-
-
-COPYRIGHT AND LICENSE
-=====================
-
-Copyright (c) 2009-2010, Nickolay Platonov
-
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
-* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
-* Neither the name of Nickolay Platonov nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-*/
View
2  lib/JooseX/Namespace/Depended/Manager.js
@@ -59,7 +59,7 @@ Class('JooseX.Namespace.Depended.Manager', {
// no type specified
token = descriptor
- type = /\//.test(token) ? 'nonjoose' : 'joose'
+ type = /\//.test(token) ? 'javascript' : 'joose'
}
}
View
21 lib/JooseX/Namespace/Depended/Resource/ExternalURL.js
@@ -1,21 +0,0 @@
-Class('JooseX.Namespace.Depended.Resource.ExternalURL', {
-
- isa : JooseX.Namespace.Depended.Resource,
-
- does : [ JooseX.Namespace.Depended.Locator.URL, JooseX.Namespace.Depended.Transport.ScriptTag ],
-
-
- after : {
-
- initialize : function () {
-
- var url = this.token
-
- if (!/^http/.test(url) && !/^\//.test(url)) throw "Can't use relative URL for resource [" + this + "]"
- }
- }
-
-
-})
-
-JooseX.Namespace.Depended.Manager.my.registerResourceClass('exturl', JooseX.Namespace.Depended.Resource.ExternalURL)
View
19 lib/JooseX/Namespace/Depended/Resource/InternalURL.js
@@ -1,19 +0,0 @@
-Class('JooseX.Namespace.Depended.Resource.InternalURL', {
-
- isa : JooseX.Namespace.Depended.Resource,
-
- does : [ JooseX.Namespace.Depended.Locator.URL, JooseX.Namespace.Depended.Transport.XHRAsync, JooseX.Namespace.Depended.Materialize.Eval ],
-
- after : {
-
- initialize : function () {
-
- var url = this.token
-
- if (/^http/.test(url) || /^\//.test(url)) throw "Can't use absolute URL for resource [" + this + "]"
- }
- }
-
-})
-
-JooseX.Namespace.Depended.Manager.my.registerResourceClass('inturl', JooseX.Namespace.Depended.Resource.InternalURL)
View
6 lib/JooseX/Namespace/Depended/Resource/JavaScript.js
@@ -52,10 +52,12 @@ Class('JooseX.Namespace.Depended.Resource.JavaScript', {
if (this.hasDirectUrl) return [ url ]
- return Joose.A.map(JooseX.Namespace.Depended.Manager.my.INC, function (libroot) {
+ var manager = JooseX.Namespace.Depended.Manager.my
+
+ return Joose.A.map(manager.INC, function (libroot) {
libroot = libroot.replace(/\/$/, '')
- return [ libroot ].concat(url).join('/') + (JooseX.Namespace.Depended.Manager.my.disableCaching ? '?disableCaching=' + new Date().getTime() : '')
+ return [ libroot ].concat(url).join('/') + (manager.disableCaching ? '?disableCaching=' + new Date().getTime() : '')
})
}
}
View
9 lib/JooseX/Namespace/Depended/Resource/JooseClass.js
@@ -46,12 +46,13 @@ Class('JooseX.Namespace.Depended.Resource.JooseClass', {
var urls = []
var className = this.token.split('.')
- Joose.A.each(JooseX.Namespace.Depended.Manager.my.INC, function (libroot) {
+ var manager = JooseX.Namespace.Depended.Manager.my
+
+ return Joose.A.map(manager.INC, function (libroot) {
libroot = libroot.replace(/\/$/, '')
- urls.push( [ libroot ].concat(className).join('/') + '.js' + (JooseX.Namespace.Depended.Manager.my.disableCaching ? '?disableCaching=' + new Date().getTime() : '') )
+
+ return [ libroot ].concat(className).join('/') + '.js' + (manager.disableCaching ? '?disableCaching=' + new Date().getTime() : '')
})
-
- return urls
}
}
View
14 static/dep/BasicTest1.js
@@ -1,14 +0,0 @@
-if (typeof BasicTest1 == 'function' && BasicTest1.meta.constructor == Joose.Meta.Class) throw "Double declaration of BasicTest1";
-
-Class('BasicTest1', {
- VERSION : 0.1,
-
- use : [
- 'BasicTest2'
- ],
-
- methods : {
- result : function () { return 1 }
- }
-
-})
View
3  static/dep/some_raw_dep.js
@@ -0,0 +1,3 @@
+if (typeof some_raw_dep != 'undefined') throw "Double declaration of `some_raw_dep`";
+
+some_raw_dep = true
View
10 t/005_resources_manager.t.js
@@ -1,7 +1,5 @@
StartTest(function(t) {
- t.plan(21)
-
//==================================================================================================================================================================================
t.diag("Sanity")
@@ -12,14 +10,10 @@ StartTest(function(t) {
t.ok(JooseX.Namespace.Depended.Resource.JavaScript, 'JooseX.Namespace.Depended.Resource.JavaScript is here')
t.skipIf(Joose.is_NodeJS, "Not included in NodeJS bundle", function (){
-
- t.ok(JooseX.Namespace.Depended.Locator.URL, 'JooseX.Namespace.Depended.Locator.URL is here')
- t.ok(JooseX.Namespace.Depended.Resource.ExternalURL, 'JooseX.Namespace.Depended.Resource.ExternalURL is here')
- t.ok(JooseX.Namespace.Depended.Resource.InternalURL, 'JooseX.Namespace.Depended.Resource.InternalURL is here')
t.ok(JooseX.Namespace.Depended.Transport.XHRAsync, 'JooseX.Namespace.Depended.Transport.XHRAsync is here')
t.ok(JooseX.Namespace.Depended.Transport.ScriptTag, 'JooseX.Namespace.Depended.Transport.ScriptTag is here')
- }, 5)
+ }, 1)
t.ok(JooseX.Namespace.Depended.Materialize.Eval, 'JooseX.Namespace.Depended.Materialize.Eval is here')
@@ -58,6 +52,8 @@ StartTest(function(t) {
t.ok(testRes2.id == 'joose://Test2', '.. and it has correct id')
t.ok(testRes2.type == 'joose', '.. and it has correct type')
+ t.done()
+
// var res2 = JooseX.Namespace.Depended.Manager.my.getResource({ 'TestClass' : 0.01 })
// var res1 = JooseX.Namespace.Depended.Manager.my.getResource('joose://TestClass#0.01')
//
View
2  t/010_basic.t.js
@@ -95,7 +95,7 @@ StartTest(function(t) {
Module("ExtCoreLoader", {
- use : 'exturl://http://ajax.googleapis.com/ajax/libs/ext-core/3.0.0/ext-core.js',
+ use : 'javascript://http://ajax.googleapis.com/ajax/libs/ext-core/3.0.0/ext-core.js',
BEGIN : function (ready) {
beginCount++
View
2  t/015_basic_for_roles.t.js
@@ -88,7 +88,7 @@ StartTest(function(t) {
Module("ExtCoreLoader", {
- use : 'exturl://http://ajax.googleapis.com/ajax/libs/ext-core/3.0.0/ext-core.js',
+ use : 'javascript://http://ajax.googleapis.com/ajax/libs/ext-core/3.0.0/ext-core.js',
BEGIN : function (ready) {
t.diag("Controllbale ready-ness of Module")
View
54 t/120_script_tag_transport.t.js
@@ -1,54 +0,0 @@
-StartTest(function(t) {
-
- JooseX.Namespace.Depended.Manager.my.INC.unshift('localLib/root4')
-
- if (!Joose.is_NodeJS) t.harness.absolutizeINC(JooseX.Namespace.Depended.Manager.my.INC)
-
- t.plan(8)
-
- t.skip(/*Joose.is_NodeJS, */"Won't test lazy classes for now", function () {
-
- JooseX.Namespace.Depended.Resource.JooseClass.meta.extend({
- doesnt : JooseX.Namespace.Depended.Transport.XHRAsync,
- does : JooseX.Namespace.Depended.Transport.ScriptTag
- })
-
-
- //==================================================================================================================================================================================
- //t.diag("Testing of loading several classes in a single file")
-
- var async1 = t.beginAsync()
-
- use([ 'BasicTest1' ], function() {
-
- //==================================================================================================================================================================================
- t.diag("Testing of loading several classes in a single file")
-
- t.ok(BasicTest1.meta.constructor == Joose.Meta.Class, 'Basic dependencies loading passed #1-1')
- t.ok(new BasicTest1().result() == 1, "And it work as expected #1-2")
-
- t.ok(BasicTest2.meta.constructor == Joose.Meta.Class, 'Basic dependencies loading passed #2-1')
- t.ok(new BasicTest2().result() == 2, "And it work as expected #2-2")
-
- t.endAsync(async1)
- })
-
-
- var async2 = t.beginAsync()
-
- use([ 'BasicTest3' ], function() {
-
- //==================================================================================================================================================================================
- t.diag("Testing of loading several classes in a single file")
-
- t.ok(BasicTest3.meta.constructor == Joose.Meta.Class, 'Basic dependencies loading passed #1-1')
- t.ok(new BasicTest3().result() == 3, "And it work as expected #1-2")
-
- t.ok(BasicTest4.meta.constructor == Joose.Meta.Class, 'Basic dependencies loading passed #2-1')
- t.ok(new BasicTest4().result() == 4, "And it work as expected #2-2")
-
- t.endAsync(async2)
- })
-
- }, 8)
-})
View
3  t/index.js
@@ -55,6 +55,5 @@ Harness.start(
'090_future_class.t.js',
'100_additional_resources.t.js',
'110_several_classes_in_file.t.js',
- '111_delayed_deps.t.js',
- '120_script_tag_transport.t.js'
+ '111_delayed_deps.t.js'
)
Please sign in to comment.
Something went wrong with that request. Please try again.