styxie 0.0.5 → 0.0.7
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/styxie/initializer.rb +7 -2
- data/lib/styxie/version.rb +1 -1
- data/spec/lib/styxie_initializer_spec.rb +14 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87d3197e636185b66b8a020ecf9057933fb8c8e8
|
4
|
+
data.tar.gz: ee5233d0599f814ec10b36c305f475c95ad52f8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '097db64e604c0e666ddfd33d84e0f02465426c0404d6d5e4337efbe5f6c4133bd46dfa9d37f47634cf15b5da320132c8698c454cc56934ee1d8bd7cbb3be9d27'
|
7
|
+
data.tar.gz: 984ee85b2af1fc09652a89984289b29604590dbdfd8d12d1ab24d33dfb9843e959e9ae40e9bc57ffcd9cdc5da23fadbaf685bd824979af9c8c82c20d184d43a1
|
data/lib/styxie/initializer.rb
CHANGED
@@ -5,8 +5,8 @@ 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)
|
9
|
-
json = data.to_json
|
8
|
+
def styxie_initialize(klass: styxie_class, method: action_name, data: styxie_configuration, camel_case: false)
|
9
|
+
json = styxie_formatted_data(data, camel_case).to_json
|
10
10
|
result = <<-CODE
|
11
11
|
<script type="text/javascript">
|
12
12
|
//<![CDATA[
|
@@ -35,5 +35,10 @@ module Styxie
|
|
35
35
|
def styxie_class
|
36
36
|
controller_path.tr('/', '_').camelize
|
37
37
|
end
|
38
|
+
|
39
|
+
def styxie_formatted_data(data, is_camel_case)
|
40
|
+
return data unless is_camel_case
|
41
|
+
data.deep_transform_keys { |key| key.to_s.camelcase(:lower) }
|
42
|
+
end
|
38
43
|
end
|
39
44
|
end
|
data/lib/styxie/version.rb
CHANGED
@@ -24,4 +24,18 @@ describe Styxie::Initializer do
|
|
24
24
|
expect(result).to include "Styxie.applyInitializer('ModuleTests', 'index', {});"
|
25
25
|
expect(result.html_safe?).to be_truthy
|
26
26
|
end
|
27
|
+
|
28
|
+
describe '#styxie_formatted_data' do
|
29
|
+
let(:data) { { hello_world: 'data' } }
|
30
|
+
|
31
|
+
it 'camel cased' do
|
32
|
+
result = controller.styxie_formatted_data(data, true)
|
33
|
+
expect(result).to eq({ 'helloWorld' => 'data' })
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'snake cased' do
|
37
|
+
result = controller.styxie_formatted_data(data, false)
|
38
|
+
expect(result).to eq(data)
|
39
|
+
end
|
40
|
+
end
|
27
41
|
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.7
|
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:
|
12
|
+
date: 2018-03-28 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
|
@@ -63,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
63
63
|
version: '0'
|
64
64
|
requirements: []
|
65
65
|
rubyforge_project:
|
66
|
-
rubygems_version: 2.
|
66
|
+
rubygems_version: 2.6.10
|
67
67
|
signing_key:
|
68
68
|
specification_version: 4
|
69
69
|
summary: Set of helpers to maintain bridge between Server side and Client (JS) side
|