kame-remocon 0.1.6 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kame/app.rb +60 -0
- data/lib/kame/remocon.rb +12 -64
- data/lib/kame/remocon/opal/application.rb +7 -0
- data/lib/{opal → kame/remocon/opal}/canvas.rb +1 -1
- data/lib/{opal → kame/remocon/opal}/config.rb +1 -1
- data/lib/{opal → kame/remocon/opal}/image.rb +1 -1
- data/lib/kame/remocon/opal/kame_remocon.rb +13 -0
- data/lib/{opal → kame/remocon/opal}/turtle.rb +3 -3
- data/lib/{opal/application.rb → kame/remocon/opal/views/app_view.rb} +4 -14
- data/lib/{opal → kame/remocon/opal}/views/canvas_view.rb +2 -2
- data/lib/kame/remocon/server.rb +2 -1
- data/lib/kame/remocon/version.rb +1 -1
- data/lib/{kame/remocon/views → views}/index.haml +0 -0
- metadata +15 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 589e5a727aa65644fbecd0b824c9c92ae23557c0307d59945e1212d63eb4a712
|
4
|
+
data.tar.gz: c4aec1813a7c3a94dc64d1c6d28bcfd94d6977b3c0fcb773d191c0a333fdc7a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c595d82b0ce4810578f1898e1c048e1266d3d6ba840e0b4d4740e5734726c6bf5537e5ee2f5b0e37e0d865a188dc24b691dffdba7f9b97abb218af2dff4cc1e5
|
7
|
+
data.tar.gz: fbe5454e0841494ed808967d49d9ea4966a7e960ece8e90ce3c5eeb5606c7700bb304268b3885e7cf2d4c52ee49905b1466c0efcb0bf5c22c2d632cf4bbf9c52
|
data/lib/kame/app.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
require_relative "remocon/server"
|
2
|
+
|
3
|
+
module Kame
|
4
|
+
module App
|
5
|
+
def self.start(context=nil)
|
6
|
+
|
7
|
+
remote_object = nil
|
8
|
+
|
9
|
+
app = Rack::Builder.app do
|
10
|
+
server = Kame::Remocon::Server.new(host: 'localhost')
|
11
|
+
|
12
|
+
remote_object = server.settings.remote_object
|
13
|
+
|
14
|
+
map '/' do
|
15
|
+
run server
|
16
|
+
end
|
17
|
+
|
18
|
+
map '/assets' do
|
19
|
+
run Kame::Remocon::Server::OPAL.sprockets
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
Thread.new do
|
24
|
+
thin = Rack::Handler.get('thin')
|
25
|
+
thin.run(DRb::WebSocket::RackApp.new(app), Host: "127.0.0.1", Port: 9292)
|
26
|
+
end.run
|
27
|
+
|
28
|
+
10.times do
|
29
|
+
sleep 2
|
30
|
+
if defined? Rack::Handler::Thin
|
31
|
+
Launchy.open("http://localhost:9292")
|
32
|
+
break
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
@remote_object = remote_object
|
37
|
+
|
38
|
+
print "Waiting for the client is up"
|
39
|
+
|
40
|
+
100.times do
|
41
|
+
if @remote_object.turtle
|
42
|
+
puts
|
43
|
+
commander = @remote_object.turtle.new_commander
|
44
|
+
|
45
|
+
if context
|
46
|
+
Commander::METHODS.each do |name|
|
47
|
+
context.define_singleton_method(name) do |*args|
|
48
|
+
commander.method_missing(name, *args)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
break commander
|
54
|
+
end
|
55
|
+
print "."
|
56
|
+
sleep(1)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
data/lib/kame/remocon.rb
CHANGED
@@ -1,69 +1,17 @@
|
|
1
1
|
require_relative "remocon/version"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
def self.start(context=nil)
|
16
|
-
remote_object = nil
|
17
|
-
|
18
|
-
app = Rack::Builder.app do
|
19
|
-
server = Kame::Remocon::Server.new(host: 'localhost')
|
20
|
-
|
21
|
-
remote_object = server.settings.remote_object
|
22
|
-
|
23
|
-
map '/' do
|
24
|
-
run server
|
25
|
-
end
|
26
|
-
|
27
|
-
map '/assets' do
|
28
|
-
run Kame::Remocon::Server::OPAL.sprockets
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
Thread.new do
|
33
|
-
thin = Rack::Handler.get('thin')
|
34
|
-
thin.run(DRb::WebSocket::RackApp.new(app), Host: "127.0.0.1", Port: 9292)
|
35
|
-
end.run
|
36
|
-
|
37
|
-
10.times do
|
38
|
-
sleep 2
|
39
|
-
if defined? Rack::Handler::Thin
|
40
|
-
Launchy.open("http://localhost:9292")
|
41
|
-
break
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
@remote_object = remote_object
|
46
|
-
|
47
|
-
print "Waiting for the client is up"
|
48
|
-
|
49
|
-
100.times do
|
50
|
-
if @remote_object.turtle
|
51
|
-
puts
|
52
|
-
commander = @remote_object.turtle.new_commander
|
53
|
-
|
54
|
-
if context
|
55
|
-
Commander::METHODS.each do |name|
|
56
|
-
context.define_singleton_method(name) do |*args|
|
57
|
-
commander.method_missing(name, *args)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
break commander
|
63
|
-
end
|
64
|
-
print "."
|
65
|
-
sleep(1)
|
66
|
-
end
|
3
|
+
if RUBY_ENGINE == "opal"
|
4
|
+
require_relative "remocon/opal/application"
|
5
|
+
else
|
6
|
+
require "drb/websocket"
|
7
|
+
require "launchy"
|
8
|
+
|
9
|
+
require_relative "remocon/remote_object"
|
10
|
+
require_relative "app"
|
11
|
+
|
12
|
+
module Kame
|
13
|
+
module Remocon
|
14
|
+
class Error < StandardError; end
|
67
15
|
end
|
68
16
|
end
|
69
17
|
end
|
@@ -2,7 +2,7 @@ require "kame/remocon/commander"
|
|
2
2
|
|
3
3
|
require_relative "./image"
|
4
4
|
|
5
|
-
class Turtle
|
5
|
+
class Kame::Remocon::Opal::Turtle
|
6
6
|
attr_accessor :default_color
|
7
7
|
|
8
8
|
class Pos
|
@@ -31,7 +31,7 @@ class Turtle
|
|
31
31
|
clear
|
32
32
|
reset
|
33
33
|
|
34
|
-
@kame = Image.new
|
34
|
+
@kame = Kame::Remocon::Opal::Image.new
|
35
35
|
@kame.src = "/assets/images/kame.png"
|
36
36
|
end
|
37
37
|
|
@@ -124,7 +124,7 @@ class Turtle
|
|
124
124
|
|
125
125
|
def clear
|
126
126
|
@context.clear_rect(0, 0, @canvas.width, @canvas.height)
|
127
|
-
@path = Canvas::Path2D.new
|
127
|
+
@path = Kame::Remocon::Opal::Canvas::Path2D.new
|
128
128
|
@paths = [[@path, @default_color]]
|
129
129
|
nil
|
130
130
|
end
|
@@ -1,12 +1,3 @@
|
|
1
|
-
require 'hyalite'
|
2
|
-
require "opal-parser"
|
3
|
-
require "opal/drb"
|
4
|
-
|
5
|
-
require_relative "config"
|
6
|
-
require_relative "views/canvas_view"
|
7
|
-
require_relative "canvas"
|
8
|
-
require_relative "turtle"
|
9
|
-
|
10
1
|
=begin
|
11
2
|
# n角形
|
12
3
|
|
@@ -23,7 +14,7 @@ n.times do
|
|
23
14
|
end
|
24
15
|
=end
|
25
16
|
|
26
|
-
class AppView
|
17
|
+
class Kame::Remocon::Opal::AppView
|
27
18
|
include Hyalite::Component
|
28
19
|
|
29
20
|
state :render_image, false
|
@@ -43,10 +34,10 @@ class AppView
|
|
43
34
|
end
|
44
35
|
|
45
36
|
def mounted(canvas)
|
46
|
-
@turtle = Turtle.new(canvas)
|
37
|
+
@turtle = Kame::Remocon::Opal::Turtle.new(canvas)
|
47
38
|
@turtle.exec @program
|
48
39
|
|
49
|
-
if Config.ws_enabled?
|
40
|
+
if Kame::Remocon::Opal::Config.ws_enabled?
|
50
41
|
@remote = DRb::DRbObject.new_with_uri "ws://127.0.0.1:9292"
|
51
42
|
DRb.start_service("ws://127.0.0.1:9292/callback")
|
52
43
|
@remote.set_turtle DRb::DRbObject.new(@turtle)
|
@@ -75,7 +66,7 @@ class AppView
|
|
75
66
|
bg_color = @state[:bg_color]
|
76
67
|
div do
|
77
68
|
h2(nil, 'タートルグラフィックスに挑戦!!')
|
78
|
-
CanvasView.el(onMounted: -> canvas { mounted(canvas) }, render_image: render_image, bg_color: bg_color)
|
69
|
+
Kame::Remocon::Opal::CanvasView.el(onMounted: -> canvas { mounted(canvas) }, render_image: render_image, bg_color: bg_color)
|
79
70
|
textarea({style: {width: "400px", height: "200px"}, ref: :program}, program)
|
80
71
|
input({type: :checkbox, checked: true, id: :wait, ref: :wait})
|
81
72
|
label({for: :wait}, "描く過程を表示する")
|
@@ -86,4 +77,3 @@ class AppView
|
|
86
77
|
end
|
87
78
|
end
|
88
79
|
end
|
89
|
-
Hyalite.render(Hyalite.create_element(AppView), $document['.content'])
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class CanvasView
|
1
|
+
class Kame::Remocon::Opal::CanvasView
|
2
2
|
include Hyalite::Component
|
3
3
|
|
4
4
|
def create_image
|
@@ -8,7 +8,7 @@ class CanvasView
|
|
8
8
|
|
9
9
|
def component_did_mount
|
10
10
|
el = @refs[:canvas]
|
11
|
-
@canvas = Canvas.new(el.native)
|
11
|
+
@canvas = Kame::Remocon::Opal::Canvas.new(el.native)
|
12
12
|
|
13
13
|
@props[:onMounted].call(@canvas)
|
14
14
|
end
|
data/lib/kame/remocon/server.rb
CHANGED
@@ -8,7 +8,7 @@ require 'opal/sprockets'
|
|
8
8
|
|
9
9
|
class Kame::Remocon::Server < Sinatra::Base
|
10
10
|
OPAL = Opal::Sprockets::Server.new do |server|
|
11
|
-
server.append_path File.expand_path("
|
11
|
+
server.append_path File.expand_path("../opal", __FILE__)
|
12
12
|
server.append_path File.expand_path("../../../assets", __FILE__)
|
13
13
|
#server.append_path File.expand_path("../../../", __FILE__)
|
14
14
|
Opal.use_gem 'hyalite'
|
@@ -26,6 +26,7 @@ class Kame::Remocon::Server < Sinatra::Base
|
|
26
26
|
|
27
27
|
remote_object = RemoteObject.new
|
28
28
|
set :remote_object, remote_object
|
29
|
+
set :views, File.expand_path("../../../views", __FILE__)
|
29
30
|
|
30
31
|
DRb::WebSocket::RackApp.config.use_rack = true
|
31
32
|
DRb.start_service("ws://127.0.0.1:9292", remote_object)
|
data/lib/kame/remocon/version.rb
CHANGED
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kame-remocon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- youchan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-04-
|
11
|
+
date: 2019-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
@@ -95,19 +95,19 @@ dependencies:
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '5.0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: sass
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
103
|
+
version: '3.7'
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
110
|
+
version: '3.7'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: opal-drb
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -187,20 +187,23 @@ extra_rdoc_files: []
|
|
187
187
|
files:
|
188
188
|
- lib/assets/css/application.scss
|
189
189
|
- lib/assets/images/kame.png
|
190
|
+
- lib/kame/app.rb
|
190
191
|
- lib/kame/remocon.rb
|
191
192
|
- lib/kame/remocon/commander.rb
|
193
|
+
- lib/kame/remocon/opal/application.rb
|
194
|
+
- lib/kame/remocon/opal/canvas.rb
|
195
|
+
- lib/kame/remocon/opal/config.rb
|
196
|
+
- lib/kame/remocon/opal/image.rb
|
197
|
+
- lib/kame/remocon/opal/kame_remocon.rb
|
198
|
+
- lib/kame/remocon/opal/turtle.rb
|
199
|
+
- lib/kame/remocon/opal/views/app_view.rb
|
200
|
+
- lib/kame/remocon/opal/views/canvas_view.rb
|
192
201
|
- lib/kame/remocon/remote_object.rb
|
193
202
|
- lib/kame/remocon/server.rb
|
194
203
|
- lib/kame/remocon/turtle_proxy.rb
|
195
204
|
- lib/kame/remocon/version.rb
|
196
|
-
- lib/kame/remocon/views/index.haml
|
197
205
|
- lib/kame_remocon.rb
|
198
|
-
- lib/
|
199
|
-
- lib/opal/canvas.rb
|
200
|
-
- lib/opal/config.rb
|
201
|
-
- lib/opal/image.rb
|
202
|
-
- lib/opal/turtle.rb
|
203
|
-
- lib/opal/views/canvas_view.rb
|
206
|
+
- lib/views/index.haml
|
204
207
|
homepage: https://github.com/youchan/kame-remocon
|
205
208
|
licenses:
|
206
209
|
- MIT
|