styxie 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90c7ee17c29d4526e2795924b267d7c681ce6dce
|
4
|
+
data.tar.gz: febe54bbe560e25049c0f754d891a81392462bd5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ddb19ea59efb9ea4f3be9e733d9ae2cdfe6a3f0f6ab9d272ecee7630366d2138572aef9f6a171a4d0e9b8ed9c21c90bf5bc02d2e180a8912479ce5e128d753bf
|
7
|
+
data.tar.gz: 4a5e0820045fa111a4d94bf11297ad60214672a72c29bcb97142db57f289a75a00d79ca1874b920fb47d676d537c64f79a10184808bc8e24cb443844a91d6afd
|
@@ -1,3 +1,21 @@
|
|
1
|
-
@Styxie
|
2
|
-
|
3
|
-
}
|
1
|
+
@Styxie ?= {}
|
2
|
+
|
3
|
+
@Styxie.Initializers = {}
|
4
|
+
@Styxie.initQueue ?= []
|
5
|
+
|
6
|
+
@Styxie.applyInitializer = (klass, method, json) ->
|
7
|
+
initializer = @Initializers[klass]
|
8
|
+
return unless initializer
|
9
|
+
|
10
|
+
if initializer.initialize
|
11
|
+
initializer.initialize(json)
|
12
|
+
|
13
|
+
if initializer[method]
|
14
|
+
initializer[method](json)
|
15
|
+
|
16
|
+
@Styxie.deferredInit = ->
|
17
|
+
@applyInitializer.apply(this, args) for args in @initQueue
|
18
|
+
@initQueue = []
|
19
|
+
|
20
|
+
@initStyxie = =>
|
21
|
+
@Styxie.deferredInit()
|
data/lib/styxie/initializer.rb
CHANGED
@@ -5,23 +5,22 @@ module Styxie
|
|
5
5
|
cfg.merge! data
|
6
6
|
end
|
7
7
|
|
8
|
-
def styxie_initialize(klass: styxie_class, method: action_name, data: styxie_configuration
|
8
|
+
def styxie_initialize(klass: styxie_class, method: action_name, data: styxie_configuration)
|
9
9
|
json = data.to_json
|
10
|
-
init_call = autorun ? 'initStyxie();' : ''
|
11
10
|
result = <<-CODE
|
12
11
|
<script type="text/javascript">
|
13
12
|
//<![CDATA[
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
if (typeof Styxie === 'undefined' || Styxie === null) {
|
14
|
+
Styxie = {}
|
15
|
+
}
|
16
|
+
if (Styxie.applyInitializer) {
|
17
|
+
Styxie.applyInitializer('#{klass}', '#{method}', #{json});
|
18
|
+
} else {
|
19
|
+
if (Styxie.initQueue == null) {
|
20
|
+
Styxie.initQueue = []
|
18
21
|
}
|
19
|
-
|
20
|
-
|
21
|
-
Styxie.Initializers.#{klass}['#{method}'](#{json});
|
22
|
-
}
|
23
|
-
};
|
24
|
-
#{init_call}
|
22
|
+
Styxie.initQueue.push(['#{klass}', '#{method}', #{json}]);
|
23
|
+
}
|
25
24
|
//]]>
|
26
25
|
</script>
|
27
26
|
CODE
|
data/lib/styxie/version.rb
CHANGED
@@ -6,7 +6,6 @@ describe TestsController, type: :controller do
|
|
6
6
|
|
7
7
|
it 'index' do
|
8
8
|
get :index
|
9
|
-
response.body.should have_content(
|
10
|
-
response.body.should have_content('Styxie.Initializers.Tests[\'index\']({"data":"test"})')
|
9
|
+
response.body.should have_content("Styxie.applyInitializer('Tests', 'index', {\"data\":\"test\"})")
|
11
10
|
end
|
12
11
|
end
|
@@ -21,8 +21,7 @@ describe Styxie::Initializer do
|
|
21
21
|
controller.stub(controller_path: 'module/tests')
|
22
22
|
controller.stub(action_name: 'index')
|
23
23
|
result = controller.styxie_initialize
|
24
|
-
expect(result).to include "Styxie.
|
25
|
-
expect(result).to include "initStyxie();"
|
24
|
+
expect(result).to include "Styxie.applyInitializer('ModuleTests', 'index', {});"
|
26
25
|
expect(result.html_safe?).to be_truthy
|
27
26
|
end
|
28
27
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: styxie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yury Kotov
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-10-
|
12
|
+
date: 2016-10-24 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Set of helpers to maintain bridge between Server side and Client (JS)
|
15
15
|
side
|