hyper-vis 1.0.0.lap24
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +51 -0
- data/Gemfile +3 -0
- data/LICENSE +21 -0
- data/README.md +1 -0
- data/hyper-vis.gemspec +28 -0
- data/lib/hyper-vis.rb +15 -0
- data/lib/hyperloop/vis/component.rb +12 -0
- data/lib/hyperloop/vis/mixin.rb +50 -0
- data/lib/hyperloop/vis/version.rb +5 -0
- data/lib/vis.rb +9 -0
- data/lib/vis/data_common.rb +23 -0
- data/lib/vis/data_set.rb +91 -0
- data/lib/vis/data_view.rb +29 -0
- data/lib/vis/event_support.rb +24 -0
- data/lib/vis/native.rb +11 -0
- data/lib/vis/network.rb +212 -0
- data/lib/vis/source/vis.js +59957 -0
- data/lib/vis/utilities.rb +205 -0
- data/spec/spec_helper.rb +24 -0
- data/spec/test_app/.gitignore +23 -0
- data/spec/test_app/Gemfile +42 -0
- data/spec/test_app/README.md +24 -0
- data/spec/test_app/Rakefile +6 -0
- data/spec/test_app/app/assets/config/manifest.js +3 -0
- data/spec/test_app/app/assets/images/.keep +0 -0
- data/spec/test_app/app/assets/javascripts/application.js +14 -0
- data/spec/test_app/app/assets/javascripts/cable.js +13 -0
- data/spec/test_app/app/assets/javascripts/channels/.keep +0 -0
- data/spec/test_app/app/assets/stylesheets/application.css +15 -0
- data/spec/test_app/app/channels/application_cable/channel.rb +4 -0
- data/spec/test_app/app/channels/application_cable/connection.rb +4 -0
- data/spec/test_app/app/controllers/application_controller.rb +3 -0
- data/spec/test_app/app/controllers/concerns/.keep +0 -0
- data/spec/test_app/app/helpers/application_helper.rb +2 -0
- data/spec/test_app/app/hyperloop/components/.keep +0 -0
- data/spec/test_app/app/hyperloop/models/.keep +0 -0
- data/spec/test_app/app/hyperloop/operations/.keep +0 -0
- data/spec/test_app/app/hyperloop/stores/.keep +0 -0
- data/spec/test_app/app/jobs/application_job.rb +2 -0
- data/spec/test_app/app/mailers/application_mailer.rb +4 -0
- data/spec/test_app/app/models/application_record.rb +3 -0
- data/spec/test_app/app/models/concerns/.keep +0 -0
- data/spec/test_app/app/policies/application_policy.rb +14 -0
- data/spec/test_app/app/views/layouts/application.html.erb +14 -0
- data/spec/test_app/app/views/layouts/mailer.html.erb +13 -0
- data/spec/test_app/app/views/layouts/mailer.text.erb +1 -0
- data/spec/test_app/bin/bundle +3 -0
- data/spec/test_app/bin/rails +9 -0
- data/spec/test_app/bin/rake +9 -0
- data/spec/test_app/bin/setup +38 -0
- data/spec/test_app/bin/spring +17 -0
- data/spec/test_app/bin/update +29 -0
- data/spec/test_app/bin/yarn +11 -0
- data/spec/test_app/config.ru +5 -0
- data/spec/test_app/config/application.rb +19 -0
- data/spec/test_app/config/boot.rb +3 -0
- data/spec/test_app/config/cable.yml +10 -0
- data/spec/test_app/config/database.yml +25 -0
- data/spec/test_app/config/environment.rb +5 -0
- data/spec/test_app/config/environments/development.rb +54 -0
- data/spec/test_app/config/environments/production.rb +91 -0
- data/spec/test_app/config/environments/test.rb +42 -0
- data/spec/test_app/config/initializers/application_controller_renderer.rb +8 -0
- data/spec/test_app/config/initializers/assets.rb +14 -0
- data/spec/test_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/test_app/config/initializers/cookies_serializer.rb +5 -0
- data/spec/test_app/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/test_app/config/initializers/hyperloop.rb +8 -0
- data/spec/test_app/config/initializers/inflections.rb +16 -0
- data/spec/test_app/config/initializers/mime_types.rb +4 -0
- data/spec/test_app/config/initializers/wrap_parameters.rb +14 -0
- data/spec/test_app/config/locales/en.yml +33 -0
- data/spec/test_app/config/puma.rb +56 -0
- data/spec/test_app/config/routes.rb +4 -0
- data/spec/test_app/config/secrets.yml +32 -0
- data/spec/test_app/config/spring.rb +6 -0
- data/spec/test_app/db/seeds.rb +7 -0
- data/spec/test_app/lib/assets/.keep +0 -0
- data/spec/test_app/lib/tasks/.keep +0 -0
- data/spec/test_app/log/.keep +0 -0
- data/spec/test_app/package.json +5 -0
- data/spec/test_app/public/404.html +67 -0
- data/spec/test_app/public/422.html +67 -0
- data/spec/test_app/public/500.html +66 -0
- data/spec/test_app/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/test_app/public/apple-touch-icon.png +0 -0
- data/spec/test_app/public/favicon.ico +0 -0
- data/spec/test_app/public/robots.txt +1 -0
- data/spec/test_app/test/application_system_test_case.rb +5 -0
- data/spec/test_app/test/controllers/.keep +0 -0
- data/spec/test_app/test/fixtures/.keep +0 -0
- data/spec/test_app/test/fixtures/files/.keep +0 -0
- data/spec/test_app/test/helpers/.keep +0 -0
- data/spec/test_app/test/integration/.keep +0 -0
- data/spec/test_app/test/mailers/.keep +0 -0
- data/spec/test_app/test/models/.keep +0 -0
- data/spec/test_app/test/system/.keep +0 -0
- data/spec/test_app/test/test_helper.rb +10 -0
- data/spec/test_app/tmp/.keep +0 -0
- data/spec/test_app/vendor/.keep +0 -0
- data/spec/vis_component_spec.rb +40 -0
- data/spec/vis_data_set_spec.rb +184 -0
- data/spec/vis_data_view_spec.rb +112 -0
- data/spec/vis_network_spec.rb +557 -0
- metadata +387 -0
@@ -0,0 +1,205 @@
|
|
1
|
+
module Vis
|
2
|
+
module Utilities
|
3
|
+
def self.included(klass)
|
4
|
+
klass.extend Vis::Utilities::Native
|
5
|
+
end
|
6
|
+
|
7
|
+
module Native
|
8
|
+
def native_methods_with_options(js_names)
|
9
|
+
js_names.each do |js_name|
|
10
|
+
native_method_with_options(js_name)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def native_method_with_options(js_name)
|
15
|
+
define_method(js_name.underscore) do |options|
|
16
|
+
@native.JS.call(js_name, options_to_native(options))
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def hash_array_to_native(array)
|
22
|
+
array.map(&:to_n)
|
23
|
+
end
|
24
|
+
|
25
|
+
def native_to_hash_array(array)
|
26
|
+
array.map { |i| `Opal.Hash.$new(i)` }
|
27
|
+
end
|
28
|
+
|
29
|
+
def lower_camelize(snake_cased_word)
|
30
|
+
words = snake_cased_word.split('_')
|
31
|
+
result = [words.first]
|
32
|
+
result.concat(words[1..-1].map {|word| word[0].upcase + word[1..-1] }).join('')
|
33
|
+
end
|
34
|
+
|
35
|
+
def lower_camelize_hash(hash)
|
36
|
+
camel_options = {}
|
37
|
+
hash.each do |key, value|
|
38
|
+
value = lower_camelize_hash(value) if `Opal.is_a(value, Opal.Hash)`
|
39
|
+
camel_options[lower_camelize(key)] = value
|
40
|
+
end
|
41
|
+
camel_options
|
42
|
+
end
|
43
|
+
|
44
|
+
def options_to_native(options)
|
45
|
+
return unless options
|
46
|
+
_rubyfy_configure_options(options) if options.has_key?(:configure)
|
47
|
+
_rubyfy_edges_options(options) if options.has_key?(:edges)
|
48
|
+
_rubyfy_manipulation_options(options) if options.has_key?(:manipulation)
|
49
|
+
_rubyfy_nodes_options(options) if options.has_key?(:nodes)
|
50
|
+
|
51
|
+
if options.has_key?(:join_condition)
|
52
|
+
block = options[:join_condition]
|
53
|
+
if `typeof block === "function"`
|
54
|
+
options[:join_condition] = %x{
|
55
|
+
function(node_options, child_options) {
|
56
|
+
if (child_options !== undefined && child_options !== null) {
|
57
|
+
return #{block.call(`Opal.Hash.$new(node_options)`, `Opal.Hash.$new(child_options)`)};
|
58
|
+
} else {
|
59
|
+
return #{block.call(`Opal.Hash.$new(node_options)`)};
|
60
|
+
}
|
61
|
+
}
|
62
|
+
}
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
if options.has_key?(:process_properties)
|
67
|
+
block = options[:process_properties]
|
68
|
+
if `typeof block === "function"`
|
69
|
+
options[:process_properties] = %x{
|
70
|
+
function(item) {
|
71
|
+
var res = #{block.call(`Opal.Hash.$new(item)`)};
|
72
|
+
return res.$to_n();
|
73
|
+
}
|
74
|
+
}
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
if options.has_key?(:filter)
|
79
|
+
block = options[:filter]
|
80
|
+
if `typeof block === "function"`
|
81
|
+
options[:filter] = %x{
|
82
|
+
function(item) {
|
83
|
+
return #{block.call(`Opal.Hash.$new(item)`)};
|
84
|
+
}
|
85
|
+
}
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
lower_camelize_hash(options).to_n
|
90
|
+
end
|
91
|
+
|
92
|
+
def _rubyfy_configure_options(options)
|
93
|
+
if options[:configure].has_key?(:filter)
|
94
|
+
block = options[:configure][:filter]
|
95
|
+
if `typeof block === "function"`
|
96
|
+
options[:configure][:filter] = %x{
|
97
|
+
function(option, path) {
|
98
|
+
return #{block.call(`Opal.Hash.$new(options)`, `path`)};
|
99
|
+
}
|
100
|
+
}
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def _rubyfy_edges_options(options)
|
106
|
+
if options[:edges].has_key?(:chosen)
|
107
|
+
chosen = options[:edges][:chosen]
|
108
|
+
[:edge, :label].each do |key|
|
109
|
+
if chosen.has_key?(key)
|
110
|
+
block = chosen[key]
|
111
|
+
if `typeof block === "function"`
|
112
|
+
options[:edges][:chosen][key] = %x{
|
113
|
+
function(values, id, selected, hovering) {
|
114
|
+
return #{block.call(`Opal.Hash.$new(values)`, `id`, `selected`, `hovering`)};
|
115
|
+
}
|
116
|
+
}
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
[:hover_width, :selection_width].each do |key|
|
122
|
+
if options[:edges].has_key?(key)
|
123
|
+
block = options[:edges][key]
|
124
|
+
if `typeof block === "function"`
|
125
|
+
options[:edgea][key] = %x{
|
126
|
+
function(width) {
|
127
|
+
return #{block.call(`width`)};
|
128
|
+
}
|
129
|
+
}
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
if options[:edges].has_key?(:scaling)
|
134
|
+
if options[:edges][:scaling].has_key?(:custom_scaling_function)
|
135
|
+
block = options[:edges][:scaling][:custom_scaling_function]
|
136
|
+
if `typeof block === "function"`
|
137
|
+
options[:edgea][:scaling][:custom_scaling_function] = %x{
|
138
|
+
function(min, max, total, value) {
|
139
|
+
return #{block.call(`min`, `max`, `total`, `value`)};
|
140
|
+
}
|
141
|
+
}
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
def _rubyfy_manipulation_options(options)
|
148
|
+
[:add_edge, :add_node, :edit_edge, :edit_node].each do |key|
|
149
|
+
if options[:manipulation].has_key?(key)
|
150
|
+
block = options[:manipulation][key]
|
151
|
+
if `typeof block === "function"`
|
152
|
+
options[:manipulation][key] = %x{
|
153
|
+
function(nodeData, callback) {
|
154
|
+
return #{block.call(`Opal.Hash.$new(nodeData)`, `callback`)};
|
155
|
+
}
|
156
|
+
}
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
# for delete the order of args for the callback is not clear
|
161
|
+
[:delete_edge, :delete_node].each do |key|
|
162
|
+
if options[:manipulation].has_key?(key)
|
163
|
+
block = options[:manipulation][key]
|
164
|
+
if `typeof block === "function"`
|
165
|
+
options[:manipulation][key] = %x{
|
166
|
+
function(nodeData, callback) {
|
167
|
+
return #{block.call(`Opal.Hash.$new(nodeData)`, `callback`)};
|
168
|
+
}
|
169
|
+
}
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
def _rubyfy_nodes_options(options)
|
177
|
+
if options[:nodes].has_key?(:chosen)
|
178
|
+
chosen = options[:nodes][:chosen]
|
179
|
+
[:node, :label].each do |key|
|
180
|
+
if chosen.has_key?(key)
|
181
|
+
block = chosen[key]
|
182
|
+
if `typeof block === "function"`
|
183
|
+
options[:nodes][:chosen][key] = %x{
|
184
|
+
function(values, id, selected, hovering) {
|
185
|
+
return #{block.call(`Opal.Hash.$new(values)`, `id`, `selected`, `hovering`)};
|
186
|
+
}
|
187
|
+
}
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
if options[:nodes].has_key?(:scaling)
|
193
|
+
if options[:nodes][:scaling].has_key?(:custom_scaling_function)
|
194
|
+
block = options[:nodes][:scaling][:custom_scaling_function]
|
195
|
+
if `typeof block === "function"`
|
196
|
+
options[:nodes][:scaling][:custom_scaling_function] = %x{
|
197
|
+
function(min, max, total, value) {
|
198
|
+
return #{block.call(`min`, `max`, `total`, `value`)};
|
199
|
+
}
|
200
|
+
}
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
ENV["RAILS_ENV"] ||= 'test'
|
2
|
+
require File.expand_path('../test_app/config/environment', __FILE__)
|
3
|
+
require 'rspec/rails'
|
4
|
+
require 'hyper-spec'
|
5
|
+
|
6
|
+
RSpec.configure do |config|
|
7
|
+
|
8
|
+
# Fail tests on JavaScript errors in Chrome Headless
|
9
|
+
# class JavaScriptError < StandardError; end
|
10
|
+
|
11
|
+
# config.after(:each, js: true) do |spec|
|
12
|
+
# logs = page.driver.browser.manage.logs.get(:browser)
|
13
|
+
# errors = logs.select { |e| e.level == "SEVERE" && e.message.present? }
|
14
|
+
# .map { |m| m.message.gsub(/\\n/, "\n") }.to_a
|
15
|
+
# if client_options[:deprecation_warnings] == :on
|
16
|
+
# warnings = logs.select { |e| e.level == "WARNING" && e.message.present? }
|
17
|
+
# .map { |m| m.message.gsub(/\\n/, "\n") }.to_a
|
18
|
+
# puts "\033[0;33;1m\nJavascript client console warnings:\n\n" + warnings.join("\n\n") + "\033[0;30;21m" if warnings.present?
|
19
|
+
# end
|
20
|
+
# unless client_options[:raise_on_js_errors] == :off
|
21
|
+
# raise JavaScriptError, errors.join("\n\n") if errors.present?
|
22
|
+
# end
|
23
|
+
# end
|
24
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
|
2
|
+
#
|
3
|
+
# If you find yourself ignoring temporary files generated by your text editor
|
4
|
+
# or operating system, you probably want to add a global ignore instead:
|
5
|
+
# git config --global core.excludesfile '~/.gitignore_global'
|
6
|
+
|
7
|
+
# Ignore bundler config.
|
8
|
+
/.bundle
|
9
|
+
|
10
|
+
# Ignore the default SQLite database.
|
11
|
+
/db/*.sqlite3
|
12
|
+
/db/*.sqlite3-journal
|
13
|
+
|
14
|
+
# Ignore all logfiles and tempfiles.
|
15
|
+
/log/*
|
16
|
+
/tmp/*
|
17
|
+
!/log/.keep
|
18
|
+
!/tmp/.keep
|
19
|
+
|
20
|
+
/node_modules
|
21
|
+
/yarn-error.log
|
22
|
+
|
23
|
+
.byebug_history
|
@@ -0,0 +1,42 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
git_source(:github) do |repo_name|
|
4
|
+
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
|
5
|
+
"https://github.com/#{repo_name}.git"
|
6
|
+
end
|
7
|
+
|
8
|
+
|
9
|
+
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
10
|
+
gem 'rails', '~> 5.1.5'
|
11
|
+
# Use sqlite3 as the database for Active Record
|
12
|
+
gem 'sqlite3'
|
13
|
+
# Use Puma as the app server
|
14
|
+
gem 'puma', '~> 3.7'
|
15
|
+
|
16
|
+
gem "opal-jquery", git: "https://github.com/opal/opal-jquery.git", branch: "master"
|
17
|
+
gem 'hyperloop', '~> 1.0.0.lap23'
|
18
|
+
gem 'hyper-vis', path: '../../'
|
19
|
+
|
20
|
+
# Use Capistrano for deployment
|
21
|
+
# gem 'capistrano-rails', group: :development
|
22
|
+
|
23
|
+
group :development, :test do
|
24
|
+
gem 'hyper-spec', '~> 1.0.0.lap23'
|
25
|
+
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
26
|
+
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
|
27
|
+
# Adds support for Capybara system testing and selenium driver
|
28
|
+
gem 'capybara', '~> 2.13'
|
29
|
+
gem 'selenium-webdriver'
|
30
|
+
end
|
31
|
+
|
32
|
+
group :development do
|
33
|
+
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
|
34
|
+
gem 'web-console', '>= 3.3.0'
|
35
|
+
gem 'listen', '>= 3.0.5', '< 3.2'
|
36
|
+
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
|
37
|
+
gem 'spring'
|
38
|
+
gem 'spring-watcher-listen', '~> 2.0.0'
|
39
|
+
end
|
40
|
+
|
41
|
+
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
|
42
|
+
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# README
|
2
|
+
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
4
|
+
application up and running.
|
5
|
+
|
6
|
+
Things you may want to cover:
|
7
|
+
|
8
|
+
* Ruby version
|
9
|
+
|
10
|
+
* System dependencies
|
11
|
+
|
12
|
+
* Configuration
|
13
|
+
|
14
|
+
* Database creation
|
15
|
+
|
16
|
+
* Database initialization
|
17
|
+
|
18
|
+
* How to run the test suite
|
19
|
+
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
21
|
+
|
22
|
+
* Deployment instructions
|
23
|
+
|
24
|
+
* ...
|
File without changes
|
@@ -0,0 +1,14 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's
|
5
|
+
// vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//= require cable
|
13
|
+
//= require_tree .
|
14
|
+
//= require hyperloop-loader
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// Action Cable provides the framework to deal with WebSockets in Rails.
|
2
|
+
// You can generate new channels where WebSocket features live using the `rails generate channel` command.
|
3
|
+
//
|
4
|
+
//= require action_cable
|
5
|
+
//= require_self
|
6
|
+
//= require_tree ./channels
|
7
|
+
|
8
|
+
(function() {
|
9
|
+
this.App || (this.App = {});
|
10
|
+
|
11
|
+
App.cable = ActionCable.createConsumer();
|
12
|
+
|
13
|
+
}).call(this);
|
File without changes
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's
|
6
|
+
* vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# app/policies/application_policy
|
2
|
+
|
3
|
+
# Policies regulate access to your public models
|
4
|
+
# The following policy will open up full access (but only in development)
|
5
|
+
# The policy system is very flexible and powerful. See the documentation
|
6
|
+
# for complete details.
|
7
|
+
class Hyperloop::ApplicationPolicy
|
8
|
+
# Allow any session to connect:
|
9
|
+
always_allow_connection
|
10
|
+
# Send all attributes from all public models
|
11
|
+
regulate_all_broadcasts { |policy| policy.send_all }
|
12
|
+
# Allow all changes to public models
|
13
|
+
allow_change(to: :all, on: [:create, :update, :destroy]) { true }
|
14
|
+
end unless Rails.env.production?
|