hyper-vis 1.0.0.lap28 → 1.0.0.lap29

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
  SHA256:
3
- metadata.gz: 7bea13d14dc540c492236959cd126c99ed1698f6a42e1260cb293445b4837e56
4
- data.tar.gz: '0409e01c7632eeef3d17220eab96c8c6252e132694d4bafe3a1990fa06c76b1e'
3
+ metadata.gz: 51ebf1dd7cffeef29a5c842de5ad6d3be75d1f1b18bdd512303b725ed8b4abe3
4
+ data.tar.gz: 3a056f946d0425fa0f157dcfb540ca650cd6cfeb70c583908aeca3a082ee4077
5
5
  SHA512:
6
- metadata.gz: 27cc2b94166c5cbf633ebf40612b53df09f979ba022ec8dbd5ed6b4b616d9abf49174744202aaf28d4069b97f79e98b507638a8cf64cd804133a7bc8aeb2b42c
7
- data.tar.gz: 764a0aaefcf31684fee9b1599a12ec007b7e4e857d45f5908247d5de0526a685c9cd780b028feed695ff921d4d607ff5e15646d33119e1794e6bc365ab2e8e43
6
+ metadata.gz: 8614266c5254f555bd5cce838fb0c86fdfb23b9ef51c6efd4be3543e28e9e94707e346fbf2a0de804d8d6e33231e2fda2dff2cd0c1ca50a1f9f095f37992d60f
7
+ data.tar.gz: 8515cb2ee34ba375822451fdb57331bb77c3a9add6b1043ace4c48fab89856876038522c3d5555fef10585bc676eb9752949e36154aacfab7beee61bd498a19b
@@ -41,7 +41,7 @@ module Hyperloop
41
41
 
42
42
  after_mount do
43
43
  if @_dom_node && @_vis_render_block
44
- @_vis_render_block.call(@_dom_node, @_data, @_options)
44
+ instance_exec(@_dom_node, @_data, @_options, &@_vis_render_block)
45
45
  end
46
46
  end
47
47
 
@@ -56,7 +56,7 @@ module Hyperloop
56
56
  changed = true
57
57
  end
58
58
  if changed && @_dom_node && @_vis_render_block
59
- @_vis_render_block.call(@_dom_node, @_data, @_options)
59
+ instance_exec(@_dom_node, @_data, @_options, &@_vis_render_block)
60
60
  end
61
61
  end
62
62
  end
@@ -1,5 +1,5 @@
1
1
  module Hyperloop
2
2
  module Vis
3
- VERSION = '1.0.0.lap28'
3
+ VERSION = '1.0.0.lap29'
4
4
  end
5
5
  end
@@ -50,18 +50,68 @@ describe 'Hyperloop::Vis::Component', js: true do
50
50
  render_with_dom_node do |dom_node, data, options|
51
51
  @@passed_data = data
52
52
  @@passed_options = options
53
- net = Vis::Network.new(dom_node, data)
53
+ net = Vis::Network.new(dom_node, data, options)
54
54
  end
55
55
  end
56
56
  class OuterComponent < Hyperloop::Component
57
57
  render do
58
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})}
59
+ options = {
60
+ :auto_resize => true,
61
+ :locale => 'en',
62
+ :nodes => {
63
+ :scaling => {
64
+ :min => 16,
65
+ :max => 32
66
+ },
67
+ :shadow => true
68
+ },
69
+ :edges => {
70
+ :color => "#ff0000",
71
+ :smooth => false,
72
+ :shadow => true
73
+ }
74
+ }
75
+ DIV { VisComponent(vis_data: {nodes: data}, options: options)}
60
76
  end
61
77
  end
62
78
  end
63
79
  expect(page.body).to include('<canvas')
64
80
  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)
81
+ expect_evaluate_ruby('VisComponent.passed_options.has_key?(:auto_resize)').to eq(true)
82
+ end
83
+
84
+ it 'can call a event_handler callback from render_with_dom_node' do
85
+ mount 'OuterComponent' do
86
+ class VisComponent < Hyperloop::Vis::Network::Component
87
+
88
+ def self.received_calls
89
+ @@recc ||= []
90
+ @@recc
91
+ end
92
+
93
+ def test_handler_method(arg)
94
+ @@recc ||= []
95
+ @@recc << arg
96
+ end
97
+
98
+ render_with_dom_node do |dom_node, data|
99
+ net = Vis::Network.new(dom_node, data)
100
+ net.on(:resize) do |coords|
101
+ test_handler_method(coords)
102
+ end
103
+ net.set_size(100, 100)
104
+ end
105
+ end
106
+
107
+ class OuterComponent < Hyperloop::Component
108
+ render do
109
+ data = Vis::DataSet.new([{id: 1, name: 'foo'}, {id: 2, name: 'bar'}, {id: 3, name: 'pub'}])
110
+ DIV { VisComponent(vis_data: {nodes: data})}
111
+ end
112
+ end
113
+ end
114
+ expect(page.body).to include('<canvas')
115
+ expect_evaluate_ruby('VisComponent.received_calls.size').to eq(1)
66
116
  end
67
117
  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.lap28
4
+ version: 1.0.0.lap29
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-26 00:00:00.000000000 Z
11
+ date: 2018-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opal