Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Guillaume Royer
jio
Commits
3dcd4338
Commit
3dcd4338
authored
Aug 08, 2013
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jio updated to support recent labraries
parent
9af06b64
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
136 additions
and
139 deletions
+136
-139
jio.js
jio.js
+58
-61
src/jio/intro.js
src/jio/intro.js
+6
-2
src/jio/jioNamespace.js
src/jio/jioNamespace.js
+52
-59
src/jio/outro.js
src/jio/outro.js
+1
-1
test/jio/tests.js
test/jio/tests.js
+19
-16
No files found.
jio.js
View file @
3dcd4338
...
@@ -10,8 +10,12 @@
...
@@ -10,8 +10,12 @@
if
(
typeof
define
===
'
function
'
&&
define
.
amd
)
{
if
(
typeof
define
===
'
function
'
&&
define
.
amd
)
{
return
define
(
dependencies
,
module
);
return
define
(
dependencies
,
module
);
}
}
window
.
jIO
=
module
({
hex_md5
:
hex_md5
});
if
(
typeof
exports
===
'
object
'
)
{
}([
'
md5
'
],
function
(
md5
)
{
return
module
(
exports
,
require
(
'
md5
'
));
}
window
.
jIO
=
{};
module
(
window
.
jIO
,
{
hex_md5
:
hex_md5
});
}([
'
exports
'
,
'
md5
'
],
function
(
exports
,
md5
)
{
"
use strict
"
;
"
use strict
"
;
var
localstorage
,
hex_md5
=
md5
.
hex_md5
;
var
localstorage
,
hex_md5
=
md5
.
hex_md5
;
...
@@ -2782,72 +2786,65 @@ Object.defineProperty(that, "repair", {
...
@@ -2782,72 +2786,65 @@ Object.defineProperty(that, "repair", {
return
that
;
return
that
;
};
// End Class jio
};
// End Class jio
/*jslint indent: 2, maxlen: 80, sloppy: true */
/*jslint indent: 2, maxlen: 80, sloppy: true */
/*global jio: true, invalidStorageType: true */
/*global exports, jio, invalidStorageType */
var
storage_type_object
=
{
// -> 'key':constructorFunction
var
storage_type_object
=
{
// -> 'key':constructorFunction
'
base
'
:
function
()
{}
// overriden by jio
'
base
'
:
function
()
{
// overriden by jio
return
undefined
;
}
};
};
var
jioNamespace
=
(
function
(
spec
)
{
var
that
=
{};
spec
=
spec
||
{};
// Attributes //
// Methods //
/**
* Creates a new jio instance.
/**
* @method newJio
* Creates a new jio instance.
* @param {object} spec The storage description
* @method newJio
* @return {object} The new Jio instance.
* @param {object} spec The storage description
*/
* @return {object} The new Jio instance.
Object
.
defineProperty
(
exports
,
"
newJio
"
,
{
*/
configurable
:
false
,
Object
.
defineProperty
(
that
,
"
newJio
"
,
{
enumerable
:
true
,
configurable
:
false
,
writable
:
false
,
enumerable
:
false
,
value
:
function
(
spec
)
{
writable
:
false
,
var
storage
=
spec
,
instance
=
null
;
value
:
function
(
spec
)
{
if
(
typeof
storage
===
'
string
'
)
{
var
storage
=
spec
,
storage
=
JSON
.
parse
(
storage
);
instance
=
null
;
}
else
{
if
(
typeof
storage
===
'
string
'
)
{
storage
=
JSON
.
stringify
(
storage
);
if
(
storage
!==
undefined
)
{
storage
=
JSON
.
parse
(
storage
);
storage
=
JSON
.
parse
(
storage
);
}
else
{
storage
=
JSON
.
stringify
(
storage
);
if
(
storage
!==
undefined
)
{
storage
=
JSON
.
parse
(
storage
);
}
}
}
storage
=
storage
||
{
type
:
'
base
'
};
instance
=
jio
(
storage
);
instance
.
start
();
return
instance
;
}
}
});
storage
=
storage
||
{
type
:
'
base
'
};
instance
=
jio
(
storage
);
instance
.
start
();
return
instance
;
}
});
/**
/**
* Add a storage type to jio.
* Add a storage type to jio.
* @method addStorageType
* @method addStorageType
* @param {string} type The storage type
* @param {string} type The storage type
* @param {function} constructor The associated constructor
* @param {function} constructor The associated constructor
*/
*/
Object
.
defineProperty
(
that
,
"
addStorageType
"
,
{
Object
.
defineProperty
(
exports
,
"
addStorageType
"
,
{
configurable
:
false
,
configurable
:
false
,
enumerable
:
false
,
enumerable
:
true
,
writable
:
false
,
writable
:
false
,
value
:
function
(
type
,
constructor
)
{
value
:
function
(
type
,
constructor
)
{
constructor
=
constructor
||
function
()
{
constructor
=
constructor
||
function
()
{
return
null
;
return
null
;
};
};
if
(
storage_type_object
[
type
])
{
if
(
storage_type_object
[
type
])
{
throw
invalidStorageType
({
throw
invalidStorageType
({
type
:
type
,
type
:
type
,
message
:
'
Already known.
'
message
:
'
Already known.
'
});
});
}
storage_type_object
[
type
]
=
constructor
;
}
}
});
storage_type_object
[
type
]
=
constructor
;
}
});
return
that
;
}());
return
jioNamespace
;
}));
}));
src/jio/intro.js
View file @
3dcd4338
...
@@ -10,8 +10,12 @@
...
@@ -10,8 +10,12 @@
if
(
typeof
define
===
'
function
'
&&
define
.
amd
)
{
if
(
typeof
define
===
'
function
'
&&
define
.
amd
)
{
return
define
(
dependencies
,
module
);
return
define
(
dependencies
,
module
);
}
}
window
.
jIO
=
module
({
hex_md5
:
hex_md5
});
if
(
typeof
exports
===
'
object
'
)
{
}([
'
md5
'
],
function
(
md5
)
{
return
module
(
exports
,
require
(
'
md5
'
));
}
window
.
jIO
=
{};
module
(
window
.
jIO
,
{
hex_md5
:
hex_md5
});
}([
'
exports
'
,
'
md5
'
],
function
(
exports
,
md5
)
{
"
use strict
"
;
"
use strict
"
;
var
localstorage
,
hex_md5
=
md5
.
hex_md5
;
var
localstorage
,
hex_md5
=
md5
.
hex_md5
;
...
...
src/jio/jioNamespace.js
View file @
3dcd4338
/*jslint indent: 2, maxlen: 80, sloppy: true */
/*jslint indent: 2, maxlen: 80, sloppy: true */
/*global jio: true, invalidStorageType: true */
/*global exports, jio, invalidStorageType */
var
storage_type_object
=
{
// -> 'key':constructorFunction
var
storage_type_object
=
{
// -> 'key':constructorFunction
'
base
'
:
function
()
{}
// overriden by jio
'
base
'
:
function
()
{
// overriden by jio
return
undefined
;
}
};
};
var
jioNamespace
=
(
function
(
spec
)
{
var
that
=
{};
spec
=
spec
||
{};
// Attributes //
// Methods //
/**
/**
* Creates a new jio instance.
* Creates a new jio instance.
* @method newJio
* @method newJio
* @param {object} spec The storage description
* @param {object} spec The storage description
* @return {object} The new Jio instance.
* @return {object} The new Jio instance.
*/
*/
Object
.
defineProperty
(
that
,
"
newJio
"
,
{
Object
.
defineProperty
(
exports
,
"
newJio
"
,
{
configurable
:
false
,
configurable
:
false
,
enumerable
:
false
,
enumerable
:
true
,
writable
:
false
,
writable
:
false
,
value
:
function
(
spec
)
{
value
:
function
(
spec
)
{
var
storage
=
spec
,
var
storage
=
spec
,
instance
=
null
;
instance
=
null
;
if
(
typeof
storage
===
'
string
'
)
{
if
(
typeof
storage
===
'
string
'
)
{
storage
=
JSON
.
parse
(
storage
);
}
else
{
storage
=
JSON
.
stringify
(
storage
);
if
(
storage
!==
undefined
)
{
storage
=
JSON
.
parse
(
storage
);
storage
=
JSON
.
parse
(
storage
);
}
else
{
storage
=
JSON
.
stringify
(
storage
);
if
(
storage
!==
undefined
)
{
storage
=
JSON
.
parse
(
storage
);
}
}
}
storage
=
storage
||
{
type
:
'
base
'
};
instance
=
jio
(
storage
);
instance
.
start
();
return
instance
;
}
}
});
storage
=
storage
||
{
type
:
'
base
'
};
instance
=
jio
(
storage
);
instance
.
start
();
return
instance
;
}
});
/**
/**
* Add a storage type to jio.
* Add a storage type to jio.
* @method addStorageType
* @method addStorageType
* @param {string} type The storage type
* @param {string} type The storage type
* @param {function} constructor The associated constructor
* @param {function} constructor The associated constructor
*/
*/
Object
.
defineProperty
(
that
,
"
addStorageType
"
,
{
Object
.
defineProperty
(
exports
,
"
addStorageType
"
,
{
configurable
:
false
,
configurable
:
false
,
enumerable
:
false
,
enumerable
:
true
,
writable
:
false
,
writable
:
false
,
value
:
function
(
type
,
constructor
)
{
value
:
function
(
type
,
constructor
)
{
constructor
=
constructor
||
function
()
{
constructor
=
constructor
||
function
()
{
return
null
;
return
null
;
};
};
if
(
storage_type_object
[
type
])
{
if
(
storage_type_object
[
type
])
{
throw
invalidStorageType
({
throw
invalidStorageType
({
type
:
type
,
type
:
type
,
message
:
'
Already known.
'
message
:
'
Already known.
'
});
});
}
storage_type_object
[
type
]
=
constructor
;
}
}
});
storage_type_object
[
type
]
=
constructor
;
}
return
that
;
});
}());
src/jio/outro.js
View file @
3dcd4338
return
jioNamespace
;
}));
}));
test/jio/tests.js
View file @
3dcd4338
...
@@ -8,10 +8,14 @@
...
@@ -8,10 +8,14 @@
if
(
typeof
define
===
'
function
'
&&
define
.
amd
)
{
if
(
typeof
define
===
'
function
'
&&
define
.
amd
)
{
return
define
(
dependencies
,
module
);
return
define
(
dependencies
,
module
);
}
}
window
.
jio_tests
=
module
(
jIO
);
if
(
typeof
exports
===
'
object
'
)
{
}([
'
jio
'
],
function
(
jIO
)
{
return
module
(
exports
,
require
(
'
jio
'
));
}
window
.
jio_tests
=
{};
module
(
window
.
jio_tests
,
jIO
);
}([
'
exports
'
,
'
jio
'
,
'
sinon_qunit
'
],
function
(
exports
,
jIO
)
{
"
use strict
"
;
"
use strict
"
;
var
t
o_export
=
{},
t
mp
;
var
tmp
;
// localStorage cleanup
// localStorage cleanup
for
(
tmp
in
localStorage
)
{
for
(
tmp
in
localStorage
)
{
...
@@ -45,7 +49,7 @@
...
@@ -45,7 +49,7 @@
deepEqual
(
val
,
value
,
message
);
deepEqual
(
val
,
value
,
message
);
};
};
}
}
to_export
.
spyJioCallback
=
spyJioCallback
;
exports
.
spyJioCallback
=
spyJioCallback
;
// XXX docstring
// XXX docstring
function
isUuid
(
uuid
)
{
function
isUuid
(
uuid
)
{
...
@@ -58,10 +62,10 @@
...
@@ -58,10 +62,10 @@
x
+
"
{4}-
"
+
x
+
"
{4}-
"
+
x
+
"
{12}$
"
x
+
"
{4}-
"
+
x
+
"
{4}-
"
+
x
+
"
{12}$
"
)
===
null
?
false
:
true
);
)
===
null
?
false
:
true
);
}
}
to_export
.
isUuid
=
isUuid
;
exports
.
isUuid
=
isUuid
;
// XXX docstring
// XXX docstring
to_export
.
jsonlocalstorage
=
{
exports
.
jsonlocalstorage
=
{
clear
:
function
()
{
clear
:
function
()
{
return
localStorage
.
clear
();
return
localStorage
.
clear
();
},
},
...
@@ -87,13 +91,13 @@
...
@@ -87,13 +91,13 @@
function
closeAndcleanUpJio
(
jio
)
{
function
closeAndcleanUpJio
(
jio
)
{
jio
.
close
();
jio
.
close
();
to_export
.
jsonlocalstorage
.
removeItem
(
"
jio/id/
"
+
jio
.
getId
());
exports
.
jsonlocalstorage
.
removeItem
(
"
jio/id/
"
+
jio
.
getId
());
to_export
.
jsonlocalstorage
.
removeItem
(
"
jio/job_array/
"
+
jio
.
getId
());
exports
.
jsonlocalstorage
.
removeItem
(
"
jio/job_array/
"
+
jio
.
getId
());
}
}
to_export
.
closeAndcleanUpJio
=
closeAndcleanUpJio
;
exports
.
closeAndcleanUpJio
=
closeAndcleanUpJio
;
function
getJioLastJob
(
jio
)
{
function
getJioLastJob
(
jio
)
{
return
(
to_export
.
jsonlocalstorage
.
getItem
(
return
(
exports
.
jsonlocalstorage
.
getItem
(
"
jio/job_array/
"
+
jio
.
getId
()
"
jio/job_array/
"
+
jio
.
getId
()
)
||
[
undefined
]).
pop
();
)
||
[
undefined
]).
pop
();
}
}
...
@@ -123,7 +127,7 @@
...
@@ -123,7 +127,7 @@
};
};
sinon
.
spy
(
o
,
function_name
);
sinon
.
spy
(
o
,
function_name
);
}
}
to_export
.
ospy
=
ospy
;
exports
.
ospy
=
ospy
;
function
otick
(
o
,
a
,
b
)
{
function
otick
(
o
,
a
,
b
)
{
var
tick
=
10000
,
function_name
=
'
f
'
;
var
tick
=
10000
,
function_name
=
'
f
'
;
...
@@ -143,7 +147,7 @@
...
@@ -143,7 +147,7 @@
}
}
}
}
}
}
to_export
.
otick
=
otick
;
exports
.
otick
=
otick
;
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// Dummy Storage
// Dummy Storage
...
@@ -228,7 +232,7 @@
...
@@ -228,7 +232,7 @@
}
}
jIO
.
addStorageType
(
'
dummy
'
,
dummyStorage
);
jIO
.
addStorageType
(
'
dummy
'
,
dummyStorage
);
to_export
.
dummyStorage
=
dummyStorage
;
exports
.
dummyStorage
=
dummyStorage
;
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// Tests
// Tests
...
@@ -708,11 +712,10 @@
...
@@ -708,11 +712,10 @@
ok
(
getJioLastJob
(
o
.
jio
)
===
undefined
,
"
Job executed
"
);
ok
(
getJioLastJob
(
o
.
jio
)
===
undefined
,
"
Job executed
"
);
o
.
clock
.
tick
(
1000
);
o
.
clock
.
tick
(
1000
);
to_export
.
jsonlocalstorage
.
removeItem
(
"
jio/id/
"
+
o
.
jio_id
);
exports
.
jsonlocalstorage
.
removeItem
(
"
jio/id/
"
+
o
.
jio_id
);
to_export
.
jsonlocalstorage
.
removeItem
(
"
jio/job_array/
"
+
o
.
jio_id
);
exports
.
jsonlocalstorage
.
removeItem
(
"
jio/job_array/
"
+
o
.
jio_id
);
closeAndcleanUpJio
(
o
.
jio
);
closeAndcleanUpJio
(
o
.
jio
);
});
});
return
to_export
;
}));
}));
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment