appjs 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/appjs/version.rb +1 -1
- data/lib/assets/javascripts/app.js +15 -2
- data/test/javascripts/app_test.js +32 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be0a8f257901bb32bb81b7905ac61698404f6394
|
4
|
+
data.tar.gz: 1a397bee83db324c160e798e46d800d633a26ee5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6c9a425aab15924dc20c5971fe80b77c06033650128609dc7b3001bcf99ed6aa7030de44e845d482c9508d64145d088b4f6628d76697e41bbb852791814fe15
|
7
|
+
data.tar.gz: 340ff2c1849a4a301a40a94bd17bfe1a63ca9bf9f3a367b40acad18ba86b534b8cd1b87849a9e6d5a88d6f4fc8d68470a3031bb9df301bee7a4d9f354edcfcd0
|
data/lib/appjs/version.rb
CHANGED
@@ -2,9 +2,10 @@ var App = function () {
|
|
2
2
|
var app_instance;
|
3
3
|
|
4
4
|
app_instance = function () {
|
5
|
-
var app
|
5
|
+
var app = {},
|
6
6
|
definitions = {},
|
7
|
-
constants
|
7
|
+
constants = {},
|
8
|
+
overwrites = {};
|
8
9
|
|
9
10
|
app.define = function (constant, definition) {
|
10
11
|
if (definitions[constant] !== undefined) {
|
@@ -18,6 +19,10 @@ var App = function () {
|
|
18
19
|
};
|
19
20
|
|
20
21
|
app.require = function (constant) {
|
22
|
+
if (overwrites[constant]) {
|
23
|
+
return overwrites[constant]();
|
24
|
+
}
|
25
|
+
|
21
26
|
if (constants[constant] === undefined) {
|
22
27
|
if (definitions[constant] === undefined) {
|
23
28
|
throw "Constant '" + constant + "' not defined."
|
@@ -28,6 +33,14 @@ var App = function () {
|
|
28
33
|
return constants[constant];
|
29
34
|
};
|
30
35
|
|
36
|
+
app.overwrite = function(constant, definition) {
|
37
|
+
overwrites[constant] = definition;
|
38
|
+
}
|
39
|
+
|
40
|
+
app.reset = function(constant) {
|
41
|
+
delete overwrites[constant];
|
42
|
+
}
|
43
|
+
|
31
44
|
return app;
|
32
45
|
}
|
33
46
|
|
@@ -124,4 +124,36 @@ describe('app', function () {
|
|
124
124
|
|
125
125
|
});
|
126
126
|
|
127
|
+
describe('overwrite', function () {
|
128
|
+
var namespace;
|
129
|
+
|
130
|
+
beforeEach(function () {
|
131
|
+
namespace = {};
|
132
|
+
App.induce(namespace);
|
133
|
+
});
|
134
|
+
|
135
|
+
it('temporarilly overwrites the Result of require', function () {
|
136
|
+
namespace.app.define('test', function () {
|
137
|
+
return 123
|
138
|
+
});
|
139
|
+
|
140
|
+
assert.equal(namespace.app.require('test'), 123)
|
141
|
+
|
142
|
+
var count = 0;
|
143
|
+
namespace.app.overwrite('test', function () {
|
144
|
+
count += 1;
|
145
|
+
return count;
|
146
|
+
});
|
147
|
+
|
148
|
+
|
149
|
+
assert.equal(namespace.app.require('test'), 1)
|
150
|
+
assert.equal(namespace.app.require('test'), 2)
|
151
|
+
assert.equal(namespace.app.require('test'), 3)
|
152
|
+
|
153
|
+
namespace.app.reset('test')
|
154
|
+
|
155
|
+
assert.equal(namespace.app.require('test'), 123)
|
156
|
+
});
|
157
|
+
});
|
158
|
+
|
127
159
|
});
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appjs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jakob Holderbaum
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-05-
|
11
|
+
date: 2013-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|