first step of switch to opal
This commit is contained in:
parent
758ab419d5
commit
9af1937a71
24
Gemfile
24
Gemfile
@ -1,19 +1,7 @@
|
||||
source 'https://rubygems.org'
|
||||
|
||||
gem 'volt', :path => "../volt"
|
||||
|
||||
# volt uses mongo as the default data store.
|
||||
gem 'volt-mongo', '~> 0.1.0'
|
||||
|
||||
# The following gem's are optional for themeing
|
||||
# Twitter bootstrap
|
||||
gem 'volt-bootstrap', '~> 0.0.10'
|
||||
|
||||
# Asset compilation gems, they will be required when needed.
|
||||
gem 'csso-rails', '~> 0.3.4', require: false
|
||||
gem 'uglifier', '>= 2.4.0', require: false
|
||||
|
||||
gem 'opal-pixi' , :path => "../opal-pixi"
|
||||
gem 'opal-browser'
|
||||
|
||||
#gem "salama" , "0.2" , :path => "../salama"
|
||||
|
||||
@ -32,13 +20,3 @@ group :test do
|
||||
gem 'chromedriver2-helper', '~> 0.0.8'
|
||||
gem 'poltergeist', '~> 1.5.0'
|
||||
end
|
||||
|
||||
# Server for MRI
|
||||
platform :mri, :mingw do
|
||||
# The implementation of ReadWriteLock in Volt uses concurrent ruby and ext helps performance.
|
||||
gem 'concurrent-ruby-ext', '~> 0.8.0'
|
||||
|
||||
# Thin is the default volt server, Puma is also supported
|
||||
gem 'thin', '~> 1.6.0'
|
||||
gem 'bson_ext', '~> 1.9.0'
|
||||
end
|
||||
|
101
Gemfile.lock
101
Gemfile.lock
@ -1,9 +1,3 @@
|
||||
PATH
|
||||
remote: ../opal-pixi
|
||||
specs:
|
||||
opal-pixi (0.1.0)
|
||||
opal (~> 0.7.0)
|
||||
|
||||
PATH
|
||||
remote: ../parslet
|
||||
specs:
|
||||
@ -27,30 +21,9 @@ PATH
|
||||
salama-reader (0.2.0)
|
||||
parslet (~> 1.7.0)
|
||||
|
||||
PATH
|
||||
remote: ../volt
|
||||
specs:
|
||||
volt (0.9.4)
|
||||
bcrypt (~> 3.1.9)
|
||||
bundler (>= 1.5)
|
||||
concurrent-ruby (= 0.8.0)
|
||||
configurations (~> 2.0.0.pre)
|
||||
faye-websocket (~> 0.9.2)
|
||||
listen (~> 3.0.1)
|
||||
opal (~> 0.7.2)
|
||||
pry (~> 0.10.1)
|
||||
rack (~> 1.5.0)
|
||||
sass (~> 3.2.5)
|
||||
sprockets-sass (~> 1.0.0)
|
||||
thor (~> 0.19.0)
|
||||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
bcrypt (3.1.10)
|
||||
bson (1.9.2)
|
||||
bson_ext (1.9.2)
|
||||
bson (~> 1.9.2)
|
||||
capybara (2.4.4)
|
||||
mime-types (>= 1.16)
|
||||
nokogiri (>= 1.3.3)
|
||||
@ -62,58 +35,33 @@ GEM
|
||||
chromedriver2-helper (0.0.8)
|
||||
nokogiri
|
||||
cliver (0.3.2)
|
||||
coderay (1.1.0)
|
||||
concurrent-ruby (0.8.0)
|
||||
ref (~> 1.0, >= 1.0.5)
|
||||
concurrent-ruby-ext (0.8.0)
|
||||
concurrent-ruby (~> 0.8.0)
|
||||
configurations (2.0.0)
|
||||
csso-rails (0.3.4)
|
||||
execjs (>= 1)
|
||||
daemons (1.2.3)
|
||||
diff-lcs (1.2.5)
|
||||
eventmachine (1.0.7)
|
||||
execjs (2.5.2)
|
||||
faye-websocket (0.9.2)
|
||||
eventmachine (>= 0.12.0)
|
||||
websocket-driver (>= 0.5.1)
|
||||
ffi (1.9.10)
|
||||
hike (1.2.3)
|
||||
json (1.8.3)
|
||||
listen (3.0.2)
|
||||
rb-fsevent (>= 0.9.3)
|
||||
rb-inotify (>= 0.9)
|
||||
method_source (0.8.2)
|
||||
mime-types (2.6.1)
|
||||
mini_portile (0.6.2)
|
||||
mongo (1.9.2)
|
||||
bson (~> 1.9.2)
|
||||
multi_json (1.11.2)
|
||||
nokogiri (1.6.6.2)
|
||||
mini_portile (~> 0.6.0)
|
||||
opal (0.7.2)
|
||||
opal (0.8.0.rc3)
|
||||
hike (~> 1.2)
|
||||
sourcemap (~> 0.1.0)
|
||||
sprockets (>= 2.2.3, < 3.0.0)
|
||||
tilt (~> 1.4)
|
||||
sprockets (~> 3.1)
|
||||
tilt (>= 1.4)
|
||||
opal-browser (0.1.0.beta1)
|
||||
opal (>= 0.5.5)
|
||||
paggio
|
||||
opal-rspec (0.4.3)
|
||||
opal (>= 0.7.0, < 0.9)
|
||||
paggio (0.2.4)
|
||||
poltergeist (1.5.1)
|
||||
capybara (~> 2.1)
|
||||
cliver (~> 0.3.1)
|
||||
multi_json (~> 1.0)
|
||||
websocket-driver (>= 0.2.0)
|
||||
pry (0.10.1)
|
||||
coderay (~> 1.1.0)
|
||||
method_source (~> 0.8.1)
|
||||
slop (~> 3.4)
|
||||
rack (1.5.5)
|
||||
rack (1.6.4)
|
||||
rack-test (0.6.3)
|
||||
rack (>= 1.0)
|
||||
rb-fsevent (0.9.5)
|
||||
rb-inotify (0.9.5)
|
||||
ffi (>= 0.5.0)
|
||||
ref (1.0.5)
|
||||
rspec (3.2.0)
|
||||
rspec-core (~> 3.2.0)
|
||||
rspec-expectations (~> 3.2.0)
|
||||
@ -128,34 +76,15 @@ GEM
|
||||
rspec-support (~> 3.2.0)
|
||||
rspec-support (3.2.2)
|
||||
rubyzip (1.1.7)
|
||||
sass (3.2.19)
|
||||
selenium-webdriver (2.43.0)
|
||||
childprocess (~> 0.5)
|
||||
multi_json (~> 1.0)
|
||||
rubyzip (~> 1.0)
|
||||
websocket (~> 1.0)
|
||||
slop (3.6.0)
|
||||
sourcemap (0.1.1)
|
||||
sprockets (2.12.4)
|
||||
hike (~> 1.2)
|
||||
multi_json (~> 1.0)
|
||||
sprockets (3.2.0)
|
||||
rack (~> 1.0)
|
||||
tilt (~> 1.1, != 1.3.0)
|
||||
sprockets-sass (1.0.3)
|
||||
sprockets (~> 2.0)
|
||||
tilt (~> 1.1)
|
||||
thin (1.6.3)
|
||||
daemons (~> 1.0, >= 1.0.9)
|
||||
eventmachine (~> 1.0)
|
||||
rack (~> 1.0)
|
||||
thor (0.19.1)
|
||||
tilt (1.4.1)
|
||||
uglifier (2.7.1)
|
||||
execjs (>= 0.3.0)
|
||||
json (>= 1.8.0)
|
||||
volt-bootstrap (0.0.10)
|
||||
volt-mongo (0.1.1)
|
||||
mongo (~> 1.9.0)
|
||||
tilt (2.0.1)
|
||||
websocket (1.2.2)
|
||||
websocket-driver (0.5.4)
|
||||
websocket-extensions (>= 0.1.0)
|
||||
@ -167,12 +96,9 @@ PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
bson_ext (~> 1.9.0)
|
||||
capybara (~> 2.4.2)
|
||||
chromedriver2-helper (~> 0.0.8)
|
||||
concurrent-ruby-ext (~> 0.8.0)
|
||||
csso-rails (~> 0.3.4)
|
||||
opal-pixi!
|
||||
opal-browser
|
||||
opal-rspec (~> 0.4.2)
|
||||
parslet!
|
||||
poltergeist (~> 1.5.0)
|
||||
@ -181,8 +107,3 @@ DEPENDENCIES
|
||||
salama-object-file!
|
||||
salama-reader!
|
||||
selenium-webdriver (~> 2.43.0)
|
||||
thin (~> 1.6.0)
|
||||
uglifier (>= 2.4.0)
|
||||
volt!
|
||||
volt-bootstrap (~> 0.0.10)
|
||||
volt-mongo (~> 0.1.0)
|
||||
|
@ -1,36 +0,0 @@
|
||||
# By default Volt generates this controller for your Main component
|
||||
require "salama"
|
||||
|
||||
if RUBY_PLATFORM == 'opal'
|
||||
require "main/lib/main_view"
|
||||
end
|
||||
|
||||
Virtual::Machine.boot
|
||||
|
||||
module Main
|
||||
class MainController < Volt::ModelController
|
||||
|
||||
def index
|
||||
MainView.new()
|
||||
end
|
||||
|
||||
def about
|
||||
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# The main template contains a #template binding that shows another
|
||||
# template. This is the path to that template. It may change based
|
||||
# on the params._component, params._controller, and params._action values.
|
||||
def main_path
|
||||
"#{params._component || 'main'}/#{params._controller || 'main'}/#{params._action || 'index'}"
|
||||
end
|
||||
|
||||
# Determine if the current nav component is the active one by looking
|
||||
# at the first part of the url against the href attribute.
|
||||
def active_tab?
|
||||
url.path.split('/')[1] == attrs.href.split('/')[1]
|
||||
end
|
||||
end
|
||||
end
|
15
config.ru
15
config.ru
@ -1,4 +1,11 @@
|
||||
# Run via rack server
|
||||
require 'bundler/setup'
|
||||
require 'volt/server'
|
||||
run Volt::Server.new.app
|
||||
require 'bundler'
|
||||
Bundler.require
|
||||
|
||||
require "opal"
|
||||
Opal.use_gem("salama")
|
||||
|
||||
run Opal::Server.new { |s|
|
||||
s.main = 'debugger'
|
||||
s.append_path 'lib'
|
||||
s.debug = true
|
||||
}
|
||||
|
8
lib/debugger.rb
Normal file
8
lib/debugger.rb
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
require "opal"
|
||||
|
||||
require "main_view"
|
||||
|
||||
Virtual::Machine.boot
|
||||
|
||||
MainView.new()
|
@ -1,4 +1,4 @@
|
||||
require 'opal/pixi'
|
||||
require 'browser'
|
||||
require 'native'
|
||||
require "salama"
|
||||
|
||||
@ -9,18 +9,18 @@ require_relative "space_view"
|
||||
class MainView
|
||||
|
||||
def initialize
|
||||
@container = PIXI::Container.new
|
||||
@canvas = Browser::Canvas.new
|
||||
|
||||
height = `window.innerHeight`
|
||||
width = `window.innerWidth`
|
||||
renderer = PIXI::WebGLRenderer.new( width - 100 , height - 100, {"backgroundColor" => 0xFFFFFF})
|
||||
|
||||
body = Native(`window.document.body`)
|
||||
# bit of a hack as it assumes index's structure
|
||||
html_con = body.firstElementChild
|
||||
html_con.insertBefore renderer.view , html_con.lastElementChild
|
||||
|
||||
registers = RegisterView.new(height - 150)
|
||||
@container.add_child registers
|
||||
@canvas.add_child registers
|
||||
|
||||
ParseTask.parse(1).then do |result|
|
||||
is = Ast::Expression.from_basic(result)
|
@ -5,8 +5,8 @@ class ObjectView
|
||||
|
||||
def initialize o
|
||||
super()
|
||||
self.text = PIXI::Text.new("no")
|
||||
self.text.position = PIXI::Point.new( rand(1000) , rand(550))
|
||||
self.text = Text.new("no")
|
||||
self.text.position = Point.new( rand(1000) , rand(550))
|
||||
puts "NO O " unless o
|
||||
self.object = o
|
||||
self.text.text = short
|
@ -1,5 +1,5 @@
|
||||
|
||||
class RegisterView < PIXI::Container
|
||||
class RegisterView
|
||||
|
||||
@@register_names = (0..8).collect {|i| "r#{i}"}
|
||||
|
||||
@ -8,8 +8,8 @@ class RegisterView < PIXI::Container
|
||||
@registers = {}
|
||||
x = 0
|
||||
@@register_names.each do |name|
|
||||
reg = PIXI::Text.new( name )
|
||||
reg.position = PIXI::Point.new x , at_y
|
||||
reg = Text.new( name )
|
||||
reg.position = Point.new x , at_y
|
||||
x += reg.width + 20
|
||||
@registers[name] = reg
|
||||
self.add_child reg
|
@ -1,7 +1,7 @@
|
||||
|
||||
require "math"
|
||||
|
||||
PIXI::Point.class_eval do
|
||||
Point.class_eval do
|
||||
alias_native :y=
|
||||
|
||||
def add point
|
||||
@ -21,7 +21,7 @@ PIXI::Point.class_eval do
|
||||
end
|
||||
end
|
||||
|
||||
class SpaceView < PIXI::Graphics
|
||||
class SpaceView < Graphics
|
||||
include Sof::Util
|
||||
|
||||
def initialize
|
||||
@ -77,7 +77,7 @@ class SpaceView < PIXI::Graphics
|
||||
f = 0.01 if f < 0.01
|
||||
f = f / 100
|
||||
#puts "force #{f}"
|
||||
PIXI::Point.new( dir_x / f , dir_y / f)
|
||||
Point.new( dir_x / f , dir_y / f)
|
||||
end
|
||||
|
||||
def update_positions
|
||||
@ -91,10 +91,10 @@ class SpaceView < PIXI::Graphics
|
||||
view.position.add force( view.position , v.position )
|
||||
end
|
||||
offset = 0.0
|
||||
view.position.add force( view.position , PIXI::Point.new(view.position.x , -offset) )
|
||||
view.position.add force( view.position , PIXI::Point.new(-offset , view.position.y) )
|
||||
view.position.add force( view.position , PIXI::Point.new(view.position.x , 550 + offset) )
|
||||
view.position.add force( view.position , PIXI::Point.new(1000 + offset , view.position.y) )
|
||||
view.position.add force( view.position , Point.new(view.position.x , -offset) )
|
||||
view.position.add force( view.position , Point.new(-offset , view.position.y) )
|
||||
view.position.add force( view.position , Point.new(view.position.x , 550 + offset) )
|
||||
view.position.add force( view.position , Point.new(1000 + offset , view.position.y) )
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user