hyper-vis 1.0.0.lap26 → 1.0.0.lap27
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/README.md +4 -3
- data/lib/hyperloop/vis/network/component.rb +1 -1
- data/lib/hyperloop/vis/network/mixin.rb +4 -4
- data/lib/hyperloop/vis/version.rb +1 -1
- data/spec/vis_network_component_spec.rb +29 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ede951b3499ae42da49b376e7de770a63e8157deb0bb0a3dacd67aae88c76ab
|
4
|
+
data.tar.gz: 87900a67da3127c3e15d24efe822d9ca7d7a1950fdb7214fb5323542cd33750d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86542b71a0a62b06929b049634bebb9391ca68fca5caaa224bdb57fd100419450fe07b30548796f08ca1107a50c8579d50c3c7034962a9cdde0a842cd22a657a
|
7
|
+
data.tar.gz: afaa1c901e2497839bfca6ce2f441f105cf39945f9a62f1b898c6e11ae438819f1862910855b3ea3f02de3e1ef1aba2ad070b93f9d72110b138db1f333b894a9
|
data/README.md
CHANGED
@@ -14,14 +14,15 @@ gem 'hyper-vis'
|
|
14
14
|
and `bundle update`
|
15
15
|
hyper-vis depends on `hyper-component` from (ruby-hyperloop)[http://ruby-hyperloop.org]
|
16
16
|
|
17
|
-
### Usage
|
18
|
-
|
19
17
|
vis.js is automatically imported. If you use webpacker, you may need to cancel the import in your config/intializers/hyperloop.rb
|
20
18
|
```
|
21
19
|
config.cancel_import 'vis/source/vis.js'
|
22
20
|
```
|
21
|
+
The wrapper expects a global `vis' (not `Vis`) to be availabe in javascript.
|
23
22
|
stylesheets are includes in 'vis/source/vis.css', images are there too.
|
24
23
|
|
24
|
+
### Usage
|
25
|
+
|
25
26
|
#### The Vis part
|
26
27
|
```
|
27
28
|
dataset = Vis::DataSet.new([{id: 1, name: 'foo'}, {id: 2, name: 'bar'}, {id: 3, name: 'pub'}])
|
@@ -56,7 +57,7 @@ class AOuterComponent < Hyperloop::Component
|
|
56
57
|
|
57
58
|
data = Vis::DataSet.new([{id: 1, name: 'foo'}, {id: 2, name: 'bar'}, {id: 3, name: 'pub'}])
|
58
59
|
|
59
|
-
DIV { MyVisNetworkComponent(
|
60
|
+
DIV { MyVisNetworkComponent(vis_data: data, otions: options)}
|
60
61
|
end
|
61
62
|
end
|
62
63
|
```
|
@@ -7,7 +7,7 @@ module Hyperloop
|
|
7
7
|
def self.included(base)
|
8
8
|
base.include(Hyperloop::Component::Mixin)
|
9
9
|
base.class_eval do
|
10
|
-
param
|
10
|
+
param vis_data: nil
|
11
11
|
param options: nil
|
12
12
|
|
13
13
|
def _set_dom_node(dom_node)
|
@@ -29,7 +29,7 @@ module Hyperloop
|
|
29
29
|
def self.render_with_dom_node(tag = 'DIV', &block)
|
30
30
|
render do
|
31
31
|
@_vis_render_block = block
|
32
|
-
@_data = params.
|
32
|
+
@_data = params.vis_data
|
33
33
|
@_options = params.options
|
34
34
|
send(tag, ref: method(:_set_dom_node).to_proc)
|
35
35
|
end
|
@@ -47,8 +47,8 @@ module Hyperloop
|
|
47
47
|
|
48
48
|
before_receive_props do |new_props|
|
49
49
|
changed = false
|
50
|
-
if new_props[:
|
51
|
-
@_data = new_props[:
|
50
|
+
if new_props[:vis_data] != @_data
|
51
|
+
@_data = new_props[:vis_data]
|
52
52
|
changed = true
|
53
53
|
end
|
54
54
|
if new_props[:options] != @_options
|
@@ -14,7 +14,7 @@ describe 'Hyperloop::Vis::Component', js: true do
|
|
14
14
|
class OuterComponent < Hyperloop::Component
|
15
15
|
render do
|
16
16
|
data = Vis::DataSet.new([{id: 1, name: 'foo'}, {id: 2, name: 'bar'}, {id: 3, name: 'pub'}])
|
17
|
-
DIV { VisComponent(
|
17
|
+
DIV { VisComponent(vis_data: {nodes: data})}
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -31,10 +31,37 @@ describe 'Hyperloop::Vis::Component', js: true do
|
|
31
31
|
class OuterComponent < Hyperloop::Component
|
32
32
|
render do
|
33
33
|
data = Vis::DataSet.new([{id: 1, name: 'foo'}, {id: 2, name: 'bar'}, {id: 3, name: 'pub'}])
|
34
|
-
DIV { VisComponent(
|
34
|
+
DIV { VisComponent(vis_data: {nodes: data})}
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
38
38
|
expect(page.body).to include('<canvas')
|
39
39
|
end
|
40
|
+
|
41
|
+
it 'actually passes the params to the component' do
|
42
|
+
mount 'OuterComponent' do
|
43
|
+
class VisComponent < Hyperloop::Vis::Network::Component
|
44
|
+
def self.passed_data
|
45
|
+
@@passed_data
|
46
|
+
end
|
47
|
+
def self.passed_options
|
48
|
+
@@passed_options
|
49
|
+
end
|
50
|
+
render_with_dom_node do |dom_node, data, options|
|
51
|
+
@@passed_data = data
|
52
|
+
@@passed_options = options
|
53
|
+
net = Vis::Network.new(dom_node, data)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
class OuterComponent < Hyperloop::Component
|
57
|
+
render do
|
58
|
+
data = Vis::DataSet.new([{id: 1, name: 'foo'}, {id: 2, name: 'bar'}, {id: 3, name: 'pub'}])
|
59
|
+
DIV { VisComponent(vis_data: {nodes: data}, options: {autoresize: true})}
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
expect(page.body).to include('<canvas')
|
64
|
+
expect_evaluate_ruby('VisComponent.passed_data.has_key?(:nodes)').to eq(true)
|
65
|
+
expect_evaluate_ruby('VisComponent.passed_options.has_key?(:autoresize)').to eq(true)
|
66
|
+
end
|
40
67
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hyper-vis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.lap27
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Biedermann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opal
|