styxie 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile +1 -1
- data/lib/styxie/initializer.rb +21 -4
- data/lib/styxie/version.rb +1 -1
- data/spec/controllers/tests_controller_spec.rb +5 -1
- data/spec/lib/styxie_helpers_spec.rb +3 -3
- data/spec/lib/styxie_initializer_spec.rb +6 -4
- data/spec/spec_helper.rb +1 -1
- data/styxie.gemspec +0 -1
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4b616eaeefe26c945f00184013497b9509b8d5a44fa005c96a864082e539f4e8
|
4
|
+
data.tar.gz: 5411d96339732638382fc3a85069095639e79a49cfcf96a3b7530cb9475ffb22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7dbf5f07878174f40a531bc5a01452e14bcda6d80c264a29f273b5b54c6eec5ff92e59e260dd816c2fe76bd743a99552af1ab65adadd8b74569401f9b7b7c48a
|
7
|
+
data.tar.gz: d91b0ac3c2df2f6824dcd144d2b12240cbcfd7a43e0ebeab34dc0096e02dfc4a8605135870b3aa7f15de6cddd97ef6442557675e08a38ad129452c73e37c3650
|
data/Gemfile
CHANGED
data/lib/styxie/initializer.rb
CHANGED
@@ -1,8 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module Styxie
|
3
3
|
module Initializer
|
4
|
-
def styxie_initialize_with(data
|
5
|
-
|
4
|
+
def styxie_initialize_with(data)
|
5
|
+
raise 'must be a hash' unless data.is_a?(Hash)
|
6
|
+
|
7
|
+
data = data.with_indifferent_access
|
8
|
+
|
9
|
+
# This code looks a bit weird but it is for backward compatibility with old approach when we
|
10
|
+
# pass cfg: as a keyword argument. I removed the keyword argument because of it does not work
|
11
|
+
# good with ruby 3.
|
12
|
+
if data[:cfg].is_a?(Hash)
|
13
|
+
cfg = data.delete(:cfg)
|
14
|
+
styxie_configuration.merge!(cfg)
|
15
|
+
end
|
16
|
+
|
17
|
+
styxie_configuration.merge! data
|
6
18
|
end
|
7
19
|
|
8
20
|
def styxie_initialize(klass: styxie_class, method: action_name, data: styxie_configuration, camel_case: false)
|
@@ -14,13 +26,18 @@ module Styxie
|
|
14
26
|
if (typeof Styxie === 'undefined' || Styxie === null) {
|
15
27
|
Styxie = {}
|
16
28
|
}
|
29
|
+
|
30
|
+
const klass = '#{klass}'
|
31
|
+
const method = '#{method}'
|
32
|
+
const json = #{json}
|
33
|
+
|
17
34
|
if (Styxie.applyInitializer) {
|
18
|
-
Styxie.applyInitializer(
|
35
|
+
Styxie.applyInitializer(klass, method, json);
|
19
36
|
} else {
|
20
37
|
if (Styxie.initQueue == null) {
|
21
38
|
Styxie.initQueue = []
|
22
39
|
}
|
23
|
-
Styxie.initQueue.push([
|
40
|
+
Styxie.initQueue.push([klass, method, json]);
|
24
41
|
}
|
25
42
|
}
|
26
43
|
//]]>
|
data/lib/styxie/version.rb
CHANGED
@@ -6,6 +6,10 @@ describe TestsController, type: :controller do
|
|
6
6
|
|
7
7
|
it 'index' do
|
8
8
|
get :index
|
9
|
-
|
9
|
+
|
10
|
+
expect(response.body).to have_content("const klass = 'Tests'")
|
11
|
+
expect(response.body).to have_content("const method = 'index'")
|
12
|
+
expect(response.body).to have_content('const json = {"data":"test"}')
|
13
|
+
expect(response.body).to have_content('Styxie.applyInitializer(klass, method, json)')
|
10
14
|
end
|
11
15
|
end
|
@@ -12,8 +12,8 @@ describe Styxie::Helpers do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
it '#this_page?' do
|
15
|
-
controller.
|
16
|
-
controller.
|
15
|
+
allow(controller).to receive(:controller_name).and_return('tests')
|
16
|
+
allow(controller).to receive(:action_name).and_return('index')
|
17
17
|
|
18
18
|
cases = [
|
19
19
|
[
|
@@ -39,7 +39,7 @@ describe Styxie::Helpers do
|
|
39
39
|
end
|
40
40
|
|
41
41
|
it '#this_namespace?' do
|
42
|
-
controller.
|
42
|
+
allow(controller).to receive(:controller_path).and_return('module/tests')
|
43
43
|
|
44
44
|
cases = [
|
45
45
|
[
|
@@ -14,14 +14,16 @@ describe Styxie::Initializer do
|
|
14
14
|
it '#styxie_initialize_with' do
|
15
15
|
expect(controller.styxie_configuration).to eq({})
|
16
16
|
controller.styxie_initialize_with(test: 'data')
|
17
|
-
expect(controller.styxie_configuration).to eq({ test
|
17
|
+
expect(controller.styxie_configuration).to eq({ 'test' => 'data' })
|
18
18
|
end
|
19
19
|
|
20
20
|
it '#styxie_initialize' do
|
21
|
-
controller.
|
22
|
-
controller.
|
21
|
+
allow(controller).to receive(:controller_path).and_return('module/tests')
|
22
|
+
allow(controller).to receive(:action_name).and_return('index')
|
23
23
|
result = controller.styxie_initialize
|
24
|
-
expect(result).to include "
|
24
|
+
expect(result).to include "const klass = 'ModuleTests'"
|
25
|
+
expect(result).to include "const method = 'index'"
|
26
|
+
expect(result).to include "const json = {}"
|
25
27
|
expect(result.html_safe?).to be_truthy
|
26
28
|
end
|
27
29
|
|
data/spec/spec_helper.rb
CHANGED
@@ -3,7 +3,7 @@ require 'rubygems'
|
|
3
3
|
require 'bundler'
|
4
4
|
Bundler.require :development
|
5
5
|
require 'capybara/rspec'
|
6
|
-
Combustion.initialize! :action_controller, :action_view
|
6
|
+
Combustion.initialize! :action_controller, :action_view
|
7
7
|
Bundler.require :default
|
8
8
|
require 'rspec/rails'
|
9
9
|
require 'capybara/rails'
|
data/styxie.gemspec
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
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.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yury Kotov
|
8
8
|
- Httplab
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2024-03-11 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
|
@@ -47,7 +47,7 @@ files:
|
|
47
47
|
homepage: http://github.com/httplab/styxie
|
48
48
|
licenses: []
|
49
49
|
metadata: {}
|
50
|
-
post_install_message:
|
50
|
+
post_install_message:
|
51
51
|
rdoc_options: []
|
52
52
|
require_paths:
|
53
53
|
- lib
|
@@ -62,9 +62,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
62
62
|
- !ruby/object:Gem::Version
|
63
63
|
version: '0'
|
64
64
|
requirements: []
|
65
|
-
|
66
|
-
|
67
|
-
signing_key:
|
65
|
+
rubygems_version: 3.4.10
|
66
|
+
signing_key:
|
68
67
|
specification_version: 4
|
69
68
|
summary: Set of helpers to maintain bridge between Server side and Client (JS) side
|
70
69
|
test_files: []
|