hyper-vis 1.0.0.lap26 → 1.0.0.lap27

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: a5ca235e1473450e7e8bb6d5d6dc3d9e3cbc5434beaf9817acce9b28ef8b614d
4
- data.tar.gz: 7210dd81862749f8ab0bad615f4f10eaa40b236d2d9b1695e9aad6c111ee22ba
3
+ metadata.gz: 7ede951b3499ae42da49b376e7de770a63e8157deb0bb0a3dacd67aae88c76ab
4
+ data.tar.gz: 87900a67da3127c3e15d24efe822d9ca7d7a1950fdb7214fb5323542cd33750d
5
5
  SHA512:
6
- metadata.gz: 7198cc58880d826bdd3c035c2573d1bf900742bdd89e56551193b74ae6d22c9482682699035275dce33a88fb2dc0015cfc9af7434ee442c6898526c8e6a18e91
7
- data.tar.gz: 9ff30ffb4c13436d2b7e17dbbee8f1ec5a7e938fb94dba19c5988ad9896b2e6500feebeded9b713f7326f764a8fb7fdb8e774e5bfda717269dd9a3a043d4a8ee
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(data: data, otions: options)}
60
+ DIV { MyVisNetworkComponent(vis_data: data, otions: options)}
60
61
  end
61
62
  end
62
63
  ```
@@ -5,7 +5,7 @@ module Hyperloop
5
5
  include Hyperloop::Vis::Network::Mixin
6
6
  def self.inherited(base)
7
7
  base.class_eval do
8
- param data: nil
8
+ param vis_data: nil
9
9
  param options: nil
10
10
  end
11
11
  end
@@ -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 data: nil
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.data
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[:data] != @_data
51
- @_data = new_props[:data]
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
@@ -1,5 +1,5 @@
1
1
  module Hyperloop
2
2
  module Vis
3
- VERSION = '1.0.0.lap26'
3
+ VERSION = '1.0.0.lap27'
4
4
  end
5
5
  end
@@ -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(data: data)}
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(data: data)}
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.lap26
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-25 00:00:00.000000000 Z
11
+ date: 2018-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opal