lacey-rails 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/lacey/rails/version.rb +1 -1
- data/vendor/assets/javascripts/lacey.js +128 -38
- metadata +2 -3
- data/vendor/assets/javascripts/lacey.min.js +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 562c88bfad178367751a8002f3370e913305a478
|
4
|
+
data.tar.gz: 35808af3c1fbe1a01e6213b50d10d651f93674f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5214d28c2608a58ca8e7b6971cfb82d662c613b3ba5396c119b2b2c1f1068a20836afd22ab5518673c8ce1135cb5d8043303f366b35f4cdfb98e9d59848bb5a
|
7
|
+
data.tar.gz: 35d160d59fc925e2614e9bb7bce79f3165868dfccda1ba441463c66bbd8ae6eb4d3e5e94fbbc2a7fcc8fef9292081e214f81e7ef0441dcdb5330ab54a204c21e
|
data/lib/lacey/rails/version.rb
CHANGED
@@ -1,41 +1,131 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
return this;
|
1
|
+
Object.prototype.has_parent = Object.prototype.is_child = false;
|
2
|
+
|
3
|
+
Object.prototype.inherits_from = function (klass) {
|
4
|
+
this.prototype = new (Function.bind.apply(klass, arguments))();
|
5
|
+
this.prototype.constructor = this;
|
6
|
+
this.prototype.is_child = this.prototype.has_parent = true;
|
8
7
|
};
|
9
8
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
9
|
+
var LaceyApp,
|
10
|
+
LaceyModule,
|
11
|
+
modules,
|
12
|
+
validate_app_name,
|
13
|
+
validate_duplicated_module,
|
14
|
+
validate_module_name,
|
15
|
+
validate_module_type,
|
16
|
+
validate_parent_module_name;
|
17
|
+
|
18
|
+
LaceyApp = function (app_name) {
|
19
|
+
validate_app_name.call(this, app_name);
|
20
|
+
|
21
|
+
this.modules = [];
|
22
|
+
this.name = app_name;
|
23
|
+
modules = {};
|
24
|
+
|
25
|
+
return this;
|
26
|
+
};
|
27
|
+
|
28
|
+
LaceyApp.prototype.register_module = function (module_name, parent_module, Module) {
|
29
|
+
if (typeof parent_module === 'function') {
|
30
|
+
Module = parent_module;
|
31
|
+
parent_module = null;
|
32
|
+
}
|
33
|
+
|
34
|
+
validate_module_name.call(this, module_name);
|
35
|
+
validate_module_type.call(this, Module);
|
36
|
+
validate_duplicated_module.call(this, module_name);
|
37
|
+
|
38
|
+
this[module_name] = new LaceyModule(module_name, parent_module, Module);
|
39
|
+
this.modules.push(module_name);
|
40
|
+
modules[module_name] = Module;
|
41
|
+
|
42
|
+
return this[module_name];
|
43
|
+
};
|
44
|
+
|
45
|
+
LaceyApp.prototype.unregister_module = function (module_name) {
|
46
|
+
validate_module_name.call(this, module_name);
|
47
|
+
|
48
|
+
this[module_name] = null;
|
49
|
+
modules[module_name] = null;
|
50
|
+
|
51
|
+
delete this[module_name];
|
52
|
+
delete modules[module_name];
|
53
|
+
|
54
|
+
return this;
|
55
|
+
};
|
56
|
+
|
57
|
+
validate_app_name = function (app_name) {
|
58
|
+
if (typeof app_name !== 'string' || app_name === '') {
|
59
|
+
throw 'InvalidNameError - you must give a valid name to your lacey app';
|
60
|
+
}
|
61
|
+
|
62
|
+
return true;
|
63
|
+
};
|
64
|
+
|
65
|
+
validate_module_name = function (module_name) {
|
66
|
+
if (typeof module_name !== 'string' || module_name === '') {
|
67
|
+
throw 'InvalidModuleNameError - you must give a valid name to your module';
|
68
|
+
}
|
69
|
+
|
70
|
+
return true;
|
71
|
+
};
|
72
|
+
|
73
|
+
validate_module_type = function (Module) {
|
74
|
+
if (typeof Module !== 'function') {
|
75
|
+
throw 'InvalidModuleError - your module must be a function';
|
76
|
+
}
|
77
|
+
|
78
|
+
return true;
|
79
|
+
};
|
80
|
+
|
81
|
+
validate_duplicated_module = function (module_name) {
|
82
|
+
if (this.modules[module_name] !== void 0) {
|
83
|
+
throw 'DuplicateModuleError - your module has already been registered';
|
84
|
+
}
|
85
|
+
|
86
|
+
return true;
|
87
|
+
};
|
88
|
+
|
89
|
+
LaceyModule = function (module_name, parent_module, Module) {
|
90
|
+
var instance = null;
|
91
|
+
|
92
|
+
this.initialized = false;
|
93
|
+
this.module_name = module_name;
|
94
|
+
|
95
|
+
this.get_instance = function () {
|
96
|
+
if (instance === null) {
|
97
|
+
if (parent_module !== null && parent_module !== module_name) {
|
98
|
+
validate_parent_module_name.call(this, parent_module);
|
99
|
+
Module.inherits_from(modules[parent_module]);
|
100
|
+
}
|
101
|
+
|
102
|
+
instance = new Module();
|
16
103
|
}
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
};
|
104
|
+
|
105
|
+
return instance;
|
106
|
+
};
|
107
|
+
|
108
|
+
return this;
|
109
|
+
};
|
110
|
+
|
111
|
+
LaceyModule.prototype.initialize = function () {
|
112
|
+
var instance = this.get_instance();
|
113
|
+
|
114
|
+
if (!this.initialized && (instance.initialize !== null) && typeof instance.initialize === 'function') {
|
115
|
+
instance.initialize();
|
116
|
+
this.initialized = true;
|
117
|
+
}
|
118
|
+
|
119
|
+
return instance;
|
120
|
+
};
|
121
|
+
|
122
|
+
validate_parent_module_name = function (parent_module) {
|
123
|
+
if (modules[parent_module] === null) {
|
124
|
+
throw 'InvalidParentModule - the parent module does not exist';
|
125
|
+
}
|
126
|
+
|
127
|
+
return true;
|
128
|
+
};
|
129
|
+
|
130
|
+
|
131
|
+
window.LaceyApp = LaceyApp;
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lacey-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- alexzicat
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -55,7 +55,6 @@ files:
|
|
55
55
|
- lib/lacey/rails.rb
|
56
56
|
- lib/lacey/rails/version.rb
|
57
57
|
- vendor/assets/javascripts/lacey.js
|
58
|
-
- vendor/assets/javascripts/lacey.min.js
|
59
58
|
homepage: https://github.com/alexzicat/lacey-rails
|
60
59
|
licenses:
|
61
60
|
- MIT
|
@@ -1 +0,0 @@
|
|
1
|
-
window.App=function(t){if("string"!=typeof t||""==t)throw"InvalidAppNameError - you must give a valid name to your lacey app";return this.app_name=t,this.modules=[],this},App.prototype.register_module=function(t,n){if("string"!=typeof t||""==t)throw"InvalidModuleNameError - you must give a valid name to your module";if("function"!=typeof n)throw"InvalidModuleError - your module must be a function";return this.modules.push(t),this[t]=function(){var t,i,o;return o=null,i=function(){return null==o&&(o=new n),o},t=function(){if(null==o){var t=i();"function"==typeof t.init&&t.init()}return t},{initialize:t,get_instance:i}}(),this[t]};
|