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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3216ff980c9176d6f7bf355403ee8eaba8fea721487f87854d86903126224b53
4
- data.tar.gz: 41a175c20d104a0ed9e700b44028c481829fa184b9168ebde2b2c896ed662036
3
+ metadata.gz: 589e5a727aa65644fbecd0b824c9c92ae23557c0307d59945e1212d63eb4a712
4
+ data.tar.gz: c4aec1813a7c3a94dc64d1c6d28bcfd94d6977b3c0fcb773d191c0a333fdc7a1
5
5
  SHA512:
6
- metadata.gz: 62a1a85d0477903c931b35dd8fd85124d9fd7c15203f9a3e647842032b95fc7c2afb95bbdcde93b760f93759f738b766e70635690568b0b2486fbf0c89090c7a
7
- data.tar.gz: 3f9b6bd5bfe892acabd3d0bed030f3f187a8718d65a15603df5883bb5af8f498f73013db78b8de8d36cd69b16bea0483e8150000b7979f1aa976cafeb8f853a7
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
- require "drb/websocket"
4
- require "launchy"
5
-
6
- require_relative "remocon/remote_object"
7
- require_relative "remocon/server"
8
-
9
- module Kame
10
- module Remocon
11
- class Error < StandardError; end
12
- end
13
-
14
- module App
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
@@ -0,0 +1,7 @@
1
+ require 'hyalite'
2
+ require "opal-parser"
3
+ require "opal/drb"
4
+
5
+ require_relative "kame_remocon"
6
+
7
+ Hyalite.render(Hyalite.create_element(Kame::Remocon::Opal::AppView), $document['.content'])
@@ -1,6 +1,6 @@
1
1
  require "native"
2
2
 
3
- class Canvas
3
+ class Kame::Remocon::Opal::Canvas
4
4
  include Native
5
5
 
6
6
  native_accessor :width, :height
@@ -1,4 +1,4 @@
1
- module Config
1
+ module Kame::Remocon::Opal::Config
2
2
  def self.ws_enabled?
3
3
  `document.ws_enabled`
4
4
  end
@@ -1,4 +1,4 @@
1
- class Image
1
+ class Kame::Remocon::Opal::Image
2
2
  include Native
3
3
  include Native::Helpers
4
4
 
@@ -0,0 +1,13 @@
1
+ module Kame
2
+ module Remocon
3
+ module Opal
4
+ end
5
+ end
6
+ end
7
+
8
+ require_relative "config"
9
+ require_relative "canvas"
10
+ require_relative "turtle"
11
+ require_relative "image"
12
+ require_relative "views/app_view"
13
+ require_relative "views/canvas_view"
@@ -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
@@ -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("../../../opal", __FILE__)
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)
@@ -1,5 +1,5 @@
1
1
  module Kame
2
2
  module Remocon
3
- VERSION = "0.1.6"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
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.1.6
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-04 00:00:00.000000000 Z
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: sassc
98
+ name: sass
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '2.0'
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: '2.0'
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/opal/application.rb
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