Permalink
Browse files

- removed the undocumented namespaces facility (was not in use anyway)

  • Loading branch information...
1 parent ec4ffc8 commit 87ec868a3f155adb0ce5581f61d2f2cfb2623d47 Nickolay Platonov committed Apr 13, 2011
Showing with 41 additions and 102 deletions.
  1. +13 −0 Changes
  2. +0 −2 Components.JS
  3. +11 −10 lib/Joose.js
  4. +0 −37 lib/Joose/Managed/PropertySet/Namespace.js
  5. +0 −12 lib/Joose/Namespace/Able.js
  6. +14 −26 lib/Joose/Namespace/Manager.js
  7. +2 −5 t/050_helpers.t.js
  8. +0 −9 t/060_modules.t.js
  9. +1 −1 t/index.js
View
@@ -2,6 +2,19 @@ Release history for Joose:
{{ $NEXT }}
+ [ENHANCEMENTS]
+
+ - none
+
+ [API CHANGES]
+
+ - removed the undocumented namespaces facility (was not in use anyway)
+
+ [BUG FIXES]
+
+ - none
+
+
3.018 2011-03-12 12:58
View
@@ -34,8 +34,6 @@ COMPONENTS = {
"Joose.Managed.Attribute",
- "Joose.Managed.PropertySet.Namespace",
-
"Joose.Managed.Attribute.Builder",
"Joose.Managed.My",
"Joose.Namespace.Able",
View
@@ -1,6 +1,15 @@
Joose = {}
-Joose.top = this
+// configuration hash
+
+Joose.C = typeof JOOSE_CFG != 'undefined' ? JOOSE_CFG : {}
+
+Joose.is_IE = '\v' == 'v'
+Joose.is_NodeJS = Boolean(typeof process != 'undefined' && process.pid)
+
+
+Joose.top = Joose.is_NodeJS && global || function () { return this }()
+
Joose.stub = function () {
return function () { throw new Error("Modules can not be instantiated") }
}
@@ -195,12 +204,4 @@ Joose.I = {
Object : function () { return {} },
Function : function () { return arguments.callee },
Now : function () { return new Date() }
-}
-
-
-// configuration hash
-
-Joose.C = typeof JOOSE_CFG != 'undefined' ? JOOSE_CFG : {}
-
-Joose.is_IE = '\v' == 'v'
-Joose.is_NodeJS = Boolean(typeof process != 'undefined' && process.pid)
+}
@@ -1,37 +0,0 @@
-Joose.Managed.PropertySet.Namespace = new Joose.Proto.Class('Joose.Managed.PropertySet.Namespace', {
-
- isa : Joose.Managed.PropertySet,
-
- propertyMetaClass : null,
-
- targetMeta : null,
-
- container : null,
-
-
- initialize : function (props) {
- Joose.Managed.PropertySet.Namespace.superClass.initialize.call(this, props)
-
- this.container = this.targetMeta.c
- },
-
-
-
- addProperty : function (name, value) {
- if (value && value.meta && value.meta.meta.hasAttribute('ns')) value.meta.parentNs = this.targetMeta.ns
-
- return this.container[name] = this.properties[name] = value
- },
-
-
- removeProperty : function (name) {
- try {
- delete this.container[name]
- } catch(e) {
- this.container[name] = undefined
- }
-
- return Joose.Managed.PropertySet.Namespace.superClass.removeProperty.call(this, name)
- }
-
-}).c
@@ -3,10 +3,6 @@ Joose.Namespace = Joose.stub()
Joose.Namespace.Able = new Joose.Managed.Role('Joose.Namespace.Able', {
have : {
- parentNs : null,
-
- ns : null,
-
bodyFunc : null
},
@@ -22,14 +18,6 @@ Joose.Namespace.Able = new Joose.Managed.Role('Joose.Namespace.Able', {
after: {
- //at this point targetMeta will contain 'c' which is a container for Joose.Managed.PropertySet.Namespace
- adaptConstructor: function (extend) {
- var localName = (this.name || '').split('.').pop()
-
- //XXX check that 'ns' is overwritten after planting
- this.ns = new Joose.Managed.PropertySet.Namespace({ name : localName, targetMeta : this })
- },
-
afterMutate : function () {
var bodyFunc = this.bodyFunc
@@ -2,7 +2,6 @@ Joose.Namespace.Manager = new Joose.Managed.Class('Joose.Namespace.Manager', {
have : {
global : null,
- globalNs : null,
current : null
},
@@ -11,15 +10,10 @@ Joose.Namespace.Manager = new Joose.Managed.Class('Joose.Namespace.Manager', {
methods : {
initialize : function () {
- var globalKeeper = this.global = new Joose.Namespace.Keeper('').c
+ // backward compat, is used in JXND, pending for removal
+ this.global = Joose.top
- var globalNs = this.globalNs = globalKeeper.meta.ns
-
-
- globalNs.container = Joose.is_NodeJS && global || Joose.top
- globalKeeper.meta.parentNs = globalKeeper
-
- this.current = [ globalKeeper ]
+ this.current = [ Joose.top ]
},
@@ -31,10 +25,8 @@ Joose.Namespace.Manager = new Joose.Managed.Class('Joose.Namespace.Manager', {
executeIn : function (ns, func) {
var current = this.current
- var scope = ns.meta.ns ? ns.meta.ns.container : ns
-
current.unshift(ns)
- var res = func.call(scope, ns)
+ var res = func.call(ns, ns)
current.shift()
return res
@@ -55,23 +47,23 @@ Joose.Namespace.Manager = new Joose.Managed.Class('Joose.Namespace.Manager', {
var me = this
- if (/^\./.test(nsName)) return this.executeIn(this.global, function () {
+ if (/^\./.test(nsName)) return this.executeIn(Joose.top, function () {
return me.create(nsName.replace(/^\./, ''), metaClass, extend)
})
props = extend || {}
var parts = Joose.S.saneSplit(nsName, '.')
var object = this.getCurrent()
- var soFar = Joose.S.saneSplit(object.meta.name, '.')
+ var soFar = object == Joose.top ? [] : Joose.S.saneSplit(object.meta.name, '.')
for (var i = 0; i < parts.length; i++) {
var part = parts[i]
var isLast = i == parts.length - 1
if (part == "meta" || part == "my" || !part) throw "Module name [" + nsName + "] may not include a part called 'meta' or 'my' or empty part."
- var cur = (object == this.global ? this.global.meta.ns.container : object)[part]//object.meta.ns.getProperty(part)
+ var cur = object[part]
soFar.push(part)
@@ -89,10 +81,7 @@ Joose.Namespace.Manager = new Joose.Managed.Class('Joose.Namespace.Manager', {
} else
nsKeeper = new Joose.Namespace.Keeper(soFarName).c
- if (object.meta)
- object.meta.ns.addProperty(part, nsKeeper)
- else
- object[part] = nsKeeper
+ object[part] = nsKeeper
cur = nsKeeper
@@ -115,7 +104,7 @@ Joose.Namespace.Manager = new Joose.Managed.Class('Joose.Namespace.Manager', {
}
} else
- if (isLast && !(cur && cur.meta && cur.meta.meta && cur.meta.meta.hasAttribute('ns'))) throw "Trying to setup module " + soFarName + " failed. There is already something: " + cur
+ if (isLast && !(cur && cur.meta && cur.meta.meta)) throw "Trying to setup module " + soFarName + " failed. There is already something: " + cur
if (needFinalize) cur.meta.construct(props)
@@ -164,19 +153,18 @@ Joose.Namespace.Manager = new Joose.Managed.Class('Joose.Namespace.Manager', {
var me = this
if (this.meta.hasMethod(helperName)) {
+
var helper = function () {
- return me[helperName].apply(me, arguments)
+ return me[ helperName ].apply(me, arguments)
}
- if (!Joose.top[helperName]) Joose.top[helperName] = helper
- if (!Joose[helperName]) Joose[helperName] = helper
+ if (!Joose.top[ helperName ]) Joose.top[ helperName ] = helper
+ if (!Joose[ helperName ]) Joose[ helperName ] = helper
- // declaring NodeJS global
- if (Joose.is_NodeJS && !global[helperName]) global[helperName] = helper
} else {
var methods = {}
- methods[helperName] = func || this.getDefaultHelperFor(metaClass)
+ methods[ helperName ] = func || this.getDefaultHelperFor(metaClass)
this.meta.extend({
methods : methods
View
@@ -1,16 +1,11 @@
StartTest(function (t) {
- t.plan(68)
-
//==================================================================================================================================================================================
t.diag("Modules")
t.ok(Joose.Namespace.Manager, "Joose.Namespace.Manager is here")
t.ok(Joose.Namespace.Keeper, "Joose.Namespace.Keeper is here")
- t.ok(Joose.Meta.Class.meta.hasAttribute('ns'), "Joose.Meta.Class's meta has 'ns' attribute")
- t.ok(Joose.Meta.Role.meta.hasAttribute('ns'), "Joose.Meta.Role's meta has 'ns' attribute")
-
Module('TestModule', {})
@@ -470,4 +465,6 @@ StartTest(function (t) {
t.ok(new Private_().result() == 10, "'Class' helper was modified correctly")
+ t.done()
+
})
View
@@ -6,13 +6,6 @@ StartTest(function (t) {
t.ok(Joose.Namespace.Manager, "Joose.Namespace.Manager is here")
t.ok(Joose.Namespace.Keeper, "Joose.Namespace.Keeper is here")
- var global = Joose.Namespace.Manager.my.global
- var globalNs = Joose.Namespace.Manager.my.globalNs
-
- t.ok(global, "There is a global namespace")
- t.ok(globalNs instanceof Joose.Managed.PropertySet.Namespace, "And it has an instance of Joose.Managed.PropertySet.Namespace")
- t.ok(globalNs.container == Joose.top, "Container of global namespace is a top scope")
-
Module('TestModule', {
VERSION : 0.01,
@@ -30,8 +23,6 @@ StartTest(function (t) {
t.ok(TestModule, 'Something in the module spot appears')
t.ok(TestModule.meta.constructor == Joose.Namespace.Keeper, '.. and its a Joose.Namespace.Keeper')
-
- t.ok(TestModule.meta.ns.container == TestModule, 'Container of namespace is a module function')
t.is(TestModule.foo, 'bar', 'Body of module was executed in the scope of its container')
t.is(TestModule.bar, 'baz', 'Module namespacekeeper was also passed as 1st argument to body')
View
@@ -13,7 +13,7 @@ Harness.configure({
verbosity : 0,
-// transparentEx : true,
+ transparentEx : true,
// runCore : 'sequential',
preload : [

0 comments on commit 87ec868

Please sign in to comment.