kame-remocon 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 327d2c1b65a8943ef242bfd4d8c043faa07e302f177769bf71a06d8230607aee
4
+ data.tar.gz: '085cca7bb4260f0bf63abd571dcec1f6a0f814723b43f54ccff5fe6e8bdf1e2e'
5
+ SHA512:
6
+ metadata.gz: fc414e89ae63c8527f4687373db0726637ccd7c14f47f9e2589e965692903b90bee4fadbb4b5eb9ffaacbf91c46d38e1feb5fc17640664ab760bbc13770efa73
7
+ data.tar.gz: 2f36850135b18c9f96d38b363ec76063067701a80a66645147909e2cf4bb20a53454c38c72282976bbc70061fa30867e698295e6b4259e7dc16c6e978ffd5c83
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in kame-remocon.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 youchan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # Kame::Remocon
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/kame/remocon`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'kame-remocon'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install kame-remocon
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/kame-remocon.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "kame/remocon"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/config.ru ADDED
@@ -0,0 +1,31 @@
1
+ require 'bundler/setup'
2
+ Bundler.require(:default)
3
+
4
+ require 'menilite'
5
+ require "drb/websocket"
6
+ require 'sinatra/activerecord'
7
+
8
+ require_relative "remote_object"
9
+ require_relative 'server'
10
+ Dir[File.expand_path('../app/models/', __FILE__) + '/**/*.rb'].each {|file| require(file) }
11
+ Dir[File.expand_path('../app/controllers/', __FILE__) + '/**/*.rb'].each {|file| require(file) }
12
+
13
+ app = Rack::Builder.app do
14
+ server = Server.new(host: 'localhost')
15
+
16
+ map '/' do
17
+ run server
18
+ end
19
+
20
+ map '/assets' do
21
+ run Server::OPAL.sprockets
22
+ end
23
+
24
+ map '/api' do
25
+ router = Menilite::Router.new
26
+ run router.routes(server.settings)
27
+ end
28
+ end
29
+
30
+ thin = Rack::Handler.get('thin')
31
+ thin.run(DRb::WebSocket::RackApp.new(app), Host: "127.0.0.1", Port: 9292)
@@ -0,0 +1,11 @@
1
+ development:
2
+ adapter: sqlite3
3
+ database: db/development.sqlite3
4
+
5
+ production:
6
+ adapter: sqlite3
7
+ database: db/production.sqlite3
8
+
9
+ test:
10
+ adapter: sqlite3
11
+ database: db/test.sqlite3
@@ -0,0 +1,41 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "kame/remocon/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "kame-remocon"
7
+ spec.version = Kame::Remocon::VERSION
8
+ spec.authors = ["youchan"]
9
+ spec.email = ["youchan01@gmail.com"]
10
+
11
+ spec.summary = %q{Turtle Graphics}
12
+ spec.description = %q{This is a remote controller to command for the turle draw graphics.}
13
+ spec.homepage = "https://github.com/youchan/kame-remocon"
14
+ spec.license = "MIT"
15
+
16
+ # Specify which files should be added to the gem when it is released.
17
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
18
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
19
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
+ end
21
+ spec.bindir = "exe"
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.add_dependency 'sinatra'
26
+ spec.add_dependency 'sinatra-contrib'
27
+ spec.add_dependency 'thin'
28
+ spec.add_dependency 'opal-haml'
29
+ spec.add_dependency 'hyalite'
30
+ spec.add_dependency 'menilite'
31
+ spec.add_dependency 'rake'
32
+ spec.add_dependency 'sqlite3'
33
+ spec.add_dependency 'haml'
34
+ spec.add_dependency 'sassc'
35
+ spec.add_dependency "opal-drb"
36
+ spec.add_dependency "drb-websocket"
37
+ spec.add_dependency "launchy"
38
+
39
+ spec.add_development_dependency "bundler", "~> 2.0"
40
+ spec.add_development_dependency "rake", "~> 10.0"
41
+ end
@@ -0,0 +1,58 @@
1
+ require_relative "remocon/version"
2
+
3
+ require "menilite"
4
+ require "drb/websocket"
5
+ require "sinatra/activerecord"
6
+ require "launchy"
7
+
8
+ require_relative "remocon/remote_object"
9
+ require_relative "remocon/server"
10
+
11
+ Dir[File.expand_path('../app/models/', __FILE__) + '/**/*.rb'].each {|file| require(file) }
12
+ Dir[File.expand_path('../app/controllers/', __FILE__) + '/**/*.rb'].each {|file| require(file) }
13
+
14
+ module Kame
15
+ module Remocon
16
+ class Error < StandardError; end
17
+ end
18
+
19
+ module App
20
+ def self.start
21
+ remote_object = nil
22
+
23
+ app = Rack::Builder.app do
24
+ server = Kame::Remocon::Server.new(host: 'localhost')
25
+
26
+ remote_object = server.settings.remote_object
27
+
28
+ map '/' do
29
+ run server
30
+ end
31
+
32
+ map '/assets' do
33
+ run Kame::Remocon::Server::OPAL.sprockets
34
+ end
35
+
36
+ map '/api' do
37
+ router = Menilite::Router.new
38
+ run router.routes(server.settings)
39
+ end
40
+ end
41
+
42
+ Thread.new do
43
+ thin = Rack::Handler.get('thin')
44
+ thin.run(DRb::WebSocket::RackApp.new(app), Host: "127.0.0.1", Port: 9292)
45
+ end.run
46
+
47
+ 10.times do
48
+ sleep 2
49
+ if defined? Rack::Handler::Thin
50
+ Launchy.open("http://localhost:9292")
51
+ break
52
+ end
53
+ end
54
+
55
+ @remote_object = remote_object
56
+ end
57
+ end
58
+ end
File without changes
@@ -0,0 +1,51 @@
1
+ class Commander
2
+ attr_reader :commands
3
+
4
+ def initialize(forward = nil)
5
+ if forward
6
+ @forward = forward
7
+ else
8
+ @commands = []
9
+ end
10
+ end
11
+
12
+ def <<(command)
13
+ if @forward
14
+ @forward.method(command.first).call(*command[1..-1])
15
+ else
16
+ @commands << command
17
+ end
18
+ end
19
+
20
+ def clear
21
+ self << [:clear]
22
+ end
23
+
24
+ def reset
25
+ self << [:reset]
26
+ end
27
+
28
+ def turn_left(digree)
29
+ self << [:turn_left, digree]
30
+ end
31
+
32
+ def turn_right(digree)
33
+ self << [:turn_right, digree]
34
+ end
35
+
36
+ def pen_down
37
+ self << [:pen_down]
38
+ end
39
+
40
+ def pen_up
41
+ self << [:pen_up]
42
+ end
43
+
44
+ def forward(dist)
45
+ self << [:forward, dist]
46
+ end
47
+
48
+ def backward(dist)
49
+ self << [:forward, -dist]
50
+ end
51
+ end
@@ -0,0 +1,68 @@
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
+ =begin
11
+ # n角形
12
+
13
+ n = 5
14
+
15
+ forward 100
16
+ turn_left 90
17
+ backword(Math::PI * 100 / n)
18
+
19
+ pen_down
20
+ n.times do
21
+ forward(Math::PI * 200 / n)
22
+ turn_left(360 / n)
23
+ end
24
+ =end
25
+
26
+ class AppView
27
+ include Hyalite::Component
28
+
29
+ def initialize
30
+ @program = <<~PROG
31
+ pen_down
32
+ forward(100)
33
+ turn_left(90)
34
+ forward(100)
35
+ turn_left(90)
36
+ forward(100)
37
+ turn_left(90)
38
+ forward(100)
39
+ PROG
40
+ end
41
+
42
+ def mounted(canvas)
43
+ @turtle = Turtle.new(canvas, wait: 0.3)
44
+ @turtle.exec @program
45
+
46
+ if Config.ws_enabled?
47
+ @remote = DRb::DRbObject.new_with_uri "ws://127.0.0.1:9292"
48
+ DRb.start_service("ws://127.0.0.1:9292/callback")
49
+ @remote.set_turtle DRb::DRbObject.new(@turtle)
50
+ end
51
+ end
52
+
53
+ def exec
54
+ @program = @refs[:program].value
55
+ @turtle.exec @program
56
+ end
57
+
58
+ def render
59
+ program = @program
60
+ div do
61
+ h2(nil, 'タートルグラフィックスに挑戦!!')
62
+ CanvasView.el(onMounted: -> canvas { mounted(canvas) })
63
+ textarea({style: {width: "400px", height: "200px"}, ref: :program}, program)
64
+ button({onClick: -> { exec() }, name: "exec"}, "Exec")
65
+ end
66
+ end
67
+ end
68
+ Hyalite.render(Hyalite.create_element(AppView), $document['.content'])
@@ -0,0 +1,43 @@
1
+ require "native"
2
+
3
+ class Canvas
4
+ include Native
5
+
6
+ native_accessor :width, :height
7
+
8
+ def get_context(type)
9
+ Context.new `#@native.getContext(type)`
10
+ end
11
+
12
+ class Context
13
+ include Native
14
+ include Native::Helpers
15
+
16
+ alias_native :save
17
+ alias_native :restore
18
+ alias_native :fill_style=, :fillStyle=
19
+ alias_native :fill_rect, :fillRect
20
+ alias_native :clear_rect, :clearRect
21
+ alias_native :begin_path, :beginPath
22
+ alias_native :close_path, :closePath
23
+ alias_native :line_to, :lineTo
24
+ alias_native :move_to, :moveTo
25
+ alias_native :stroke
26
+ alias_native :stroke_style=, :strokeStyle=
27
+ alias_native :stroke_style, :strokeStyle
28
+ alias_native :line_width=, :lineWidth=
29
+ alias_native :draw_image, :drawImage
30
+ alias_native :set_transform, :setTransform
31
+ end
32
+
33
+ class Path2D
34
+ include Native
35
+
36
+ def initialize
37
+ super `new Path2D()`
38
+ end
39
+
40
+ alias_native :line_to, :lineTo
41
+ alias_native :move_to, :moveTo
42
+ end
43
+ end
@@ -0,0 +1,5 @@
1
+ module Config
2
+ def self.ws_enabled?
3
+ `document.ws_enabled`
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ class ApplicationController < Menilite::Controller
2
+ end
@@ -0,0 +1,15 @@
1
+ class Image
2
+ include Native
3
+ include Native::Helpers
4
+
5
+ def initialize
6
+ super `new Image()`
7
+ end
8
+
9
+ alias_native :src=
10
+ alias_native :complete
11
+
12
+ def onload(&block)
13
+ `#@native.onload = block`
14
+ end
15
+ end
@@ -0,0 +1,165 @@
1
+ require "kame/remocon/commander"
2
+
3
+ require_relative "./image"
4
+
5
+ class Turtle
6
+ class Pos
7
+ attr_reader :x, :y
8
+
9
+ def initialize(x, y)
10
+ @x = x
11
+ @y = y
12
+ end
13
+
14
+ def move_to(x, y)
15
+ @x = x
16
+ @y = y
17
+ end
18
+
19
+ def canvas_coordinate
20
+ [@x + 200, @y + 200]
21
+ end
22
+ end
23
+
24
+ def initialize(canvas, wait: 0)
25
+ @canvas = canvas
26
+ @wait = wait
27
+ @context = @canvas.get_context("2d");
28
+ clear
29
+ reset
30
+
31
+ @kame = Image.new
32
+ @kame.src = "/assets/images/kame.png"
33
+ end
34
+
35
+ def new_commander
36
+ methods = [:clear, :reset, :pen_up, :pen_down, :turn_left, :turn_right, :forward, :backward]
37
+ forwarder = Forwarder.new(self, *methods) do
38
+ @context.clear_rect(0, 0, @canvas.width, @canvas.height)
39
+ @context.stroke(@path)
40
+ draw_kame
41
+ end
42
+
43
+ DRb::DRbObject.new(Commander.new(forwarder))
44
+ end
45
+
46
+ class Forwarder
47
+ def initialize(obj, *methods, &hook)
48
+ methods.each do |name|
49
+ define_singleton_method(name) do |*args|
50
+ obj.method(name).call(*args)
51
+ hook.call
52
+ end
53
+ end
54
+ end
55
+ end
56
+
57
+ def draw_kame
58
+ (x, y) = @pos.canvas_coordinate
59
+
60
+ c = Math.cos(@direction / 180 * Math::PI)
61
+ s = Math.sin(@direction / 180 * Math::PI)
62
+ transform = [c, s, -s, c, x - 10 * c + 10 * s, y - 10 * c - 10 * s]
63
+ @context.set_transform(*transform)
64
+ @context.draw_image(@kame, 0, 0, 20, 20)
65
+ @context.set_transform(1, 0, 0, 1, 0, 0)
66
+ end
67
+
68
+ def exec(program)
69
+ clear
70
+ reset
71
+ commander = Commander.new
72
+ commander.instance_eval program
73
+ exec_commands(commander.commands)
74
+ end
75
+
76
+ def exec_commands(commands, wait: nil)
77
+ wait ||= @wait
78
+ if wait > 0
79
+ exec = Proc.new do
80
+ if commands.length == 0
81
+ false
82
+ else
83
+ exec_command(commands.shift)
84
+ @context.clear_rect(0, 0, @canvas.width, @canvas.height)
85
+ @context.stroke(@path)
86
+ draw_kame
87
+ true
88
+ end
89
+ end
90
+ interval = wait * 1000
91
+ %x(
92
+ var timer = setInterval(function() {
93
+ if (!exec()) { clearInterval(timer); }
94
+ }, interval);
95
+ )
96
+ else
97
+ commands.each(&self.method(:exec_command))
98
+ @context.stroke(@path)
99
+ if @kame.complete
100
+ draw_kame
101
+ else
102
+ @kame.onload do
103
+ draw_kame
104
+ end
105
+ end
106
+ end
107
+ end
108
+
109
+ def exec_command(command)
110
+ self.method(command.first).call(*command[1..-1])
111
+ nil
112
+ end
113
+
114
+ def clear
115
+ @context.clear_rect(0, 0, @canvas.width, @canvas.height)
116
+ @path = Canvas::Path2D.new
117
+ nil
118
+ end
119
+
120
+ def reset
121
+ @pen_down = false
122
+ @direction = 0
123
+ @pos = Pos.new(0, 0)
124
+ @path.move_to(*@pos.canvas_coordinate)
125
+ @context.move_to(*@pos.canvas_coordinate)
126
+ @context.stroke_style = "white"
127
+ nil
128
+ end
129
+
130
+ def turn_left(digree)
131
+ @direction = (@direction - digree) % 360
132
+ nil
133
+ end
134
+
135
+ def turn_right(digree)
136
+ @direction = (@direction + digree) % 360
137
+ nil
138
+ end
139
+
140
+ def pen_down
141
+ @pen_down = true
142
+ nil
143
+ end
144
+
145
+ def pen_up
146
+ @pen_down = false
147
+ nil
148
+ end
149
+
150
+ def forward(dist)
151
+ @pos = position_to(dist)
152
+ if @pen_down
153
+ @path.line_to(*@pos.canvas_coordinate)
154
+ else
155
+ @path.move_to(*@pos.canvas_coordinate)
156
+ end
157
+ nil
158
+ end
159
+
160
+ def position_to(dist)
161
+ dx = Math.sin(Math::PI * @direction / 180) * dist
162
+ dy = - Math.cos(Math::PI * @direction / 180) * dist
163
+ Pos.new(@pos.x + dx, @pos.y + dy)
164
+ end
165
+ end
@@ -0,0 +1,7 @@
1
+ class Canvas
2
+ include Hyalite::Component
3
+
4
+ def render
5
+ canvas({width: 480, height: 480})
6
+ end
7
+ end
@@ -0,0 +1,15 @@
1
+ class CanvasView
2
+ include Hyalite::Component
3
+
4
+
5
+ def component_did_mount
6
+ el = @refs[:canvas]
7
+ @canvas = Canvas.new(el.native)
8
+
9
+ @props[:onMounted].call(@canvas)
10
+ end
11
+
12
+ def render
13
+ canvas({width: "400", height: "400", ref: :canvas, style: {"background-color": "black"}})
14
+ end
15
+ end
@@ -0,0 +1,35 @@
1
+ require_relative "commander"
2
+
3
+ class RemoteObject
4
+ def set_turtle(turtle)
5
+ @turtle = turtle
6
+ nil
7
+ end
8
+
9
+ def exec(str = nil, &block)
10
+ if @turtle
11
+ @turtle.clear
12
+ @turtle.reset
13
+ commander = @turtle.new_commander
14
+ if str
15
+ commander.instance_eval str
16
+ elsif block
17
+ commander.instance_eval &block
18
+ end
19
+ end
20
+ end
21
+
22
+ def exec_bulk(str = nil, &block)
23
+ if @turtle
24
+ @turtle.clear
25
+ @turtle.reset
26
+ commander = Commander.new
27
+ if str
28
+ commander.instance_eval str
29
+ elsif block
30
+ commander.instance_eval &block
31
+ end
32
+ @turtle.exec_commands(commander.commands, wait: 0)
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,69 @@
1
+ require 'sinatra'
2
+ require 'opal'
3
+ require 'opal/sprockets'
4
+ require 'sinatra/activerecord'
5
+
6
+ # if development?
7
+ # require 'sinatra/reloader'
8
+ # end
9
+
10
+ class Kame::Remocon::Server < Sinatra::Base
11
+ OPAL = Opal::Sprockets::Server.new do |server|
12
+ server.append_path File.expand_path("../opal", __FILE__)
13
+ server.append_path File.expand_path("../assets", __FILE__)
14
+ #server.append_path File.expand_path("../../../", __FILE__)
15
+ Opal.use_gem 'hyalite'
16
+ Opal.use_gem "opal-drb"
17
+ Opal.use_gem 'menilite'
18
+ Opal.use_gem 'kame-remocon'
19
+ Opal.paths.each {|path| server.append_path path }
20
+
21
+ server.main = 'application'
22
+ end
23
+
24
+ configure do
25
+ set opal: OPAL
26
+ enable :sessions
27
+ set :protection, except: :json_csrf
28
+
29
+ remote_object = RemoteObject.new
30
+ set :remote_object, remote_object
31
+
32
+ DRb::WebSocket::RackApp.config.use_rack = true
33
+ DRb.start_service("ws://127.0.0.1:9292", remote_object)
34
+ end
35
+
36
+ get '/' do
37
+ @enable_ws = true
38
+ haml :index
39
+ end
40
+
41
+ get "/polygon/:n" do
42
+ n = params["n"].to_i
43
+
44
+ EM.defer do
45
+ settings.remote_object.exec_bulk do
46
+ forward 100
47
+ turn_left 90
48
+ backward(Math::PI * 100 / n)
49
+
50
+ pen_down
51
+ n.times do
52
+ forward(Math::PI * 200 / n)
53
+ turn_left(360 / n)
54
+ end
55
+ end
56
+ end
57
+ end
58
+
59
+ post "/exec" do
60
+ body = request.body.read
61
+ EM.defer do
62
+ settings.remote_object.exec_bulk body
63
+ end
64
+ end
65
+
66
+ get "/favicon.ico" do
67
+ end
68
+ end
69
+
@@ -0,0 +1,43 @@
1
+ class TurtleProxy
2
+ def initialize(turtle)
3
+ @turtle = DRb::DRbObject.new(turtle)
4
+ end
5
+
6
+ def exec(&block)
7
+ @turtle.clear
8
+ @turtle.reset
9
+ self.instance_eval &block
10
+ end
11
+
12
+ def clear
13
+ @turtle.clear
14
+ end
15
+
16
+ def reset
17
+ @turtle.reset
18
+ end
19
+
20
+ def turn_left(digree)
21
+ @turtle.turn_left(digree)
22
+ end
23
+
24
+ def turn_right(digree)
25
+ @turtle.turn_right(digree)
26
+ end
27
+
28
+ def pen_down
29
+ @turtle.pen_down
30
+ end
31
+
32
+ def pen_up
33
+ @turtle.pen_up
34
+ end
35
+
36
+ def forward(dist)
37
+ @turtle.forward(dist)
38
+ end
39
+
40
+ def backward(dist)
41
+ @turtle.backward(dist)
42
+ end
43
+ end
@@ -0,0 +1,5 @@
1
+ module Kame
2
+ module Remocon
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,11 @@
1
+ !!!
2
+ %html(lang="en" data-framework="hyalite")
3
+ %head
4
+ %link{rel:"stylesheet", href:"assets/css/application.css"}
5
+
6
+ :javascript
7
+ document.ws_enabled = #{@enable_ws}
8
+ %body
9
+ .content
10
+
11
+ = ::Opal::Sprockets.javascript_include_tag('application', sprockets: settings.opal.sprockets, prefix: 'assets', debug: true)
@@ -0,0 +1 @@
1
+ require_relative "kame/remocon"
metadata ADDED
@@ -0,0 +1,283 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kame-remocon
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - youchan
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-02-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sinatra
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: sinatra-contrib
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: thin
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: opal-haml
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: hyalite
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: menilite
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rake
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: sqlite3
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: haml
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: sassc
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: opal-drb
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: drb-websocket
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :runtime
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: launchy
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ type: :runtime
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
195
+ - !ruby/object:Gem::Dependency
196
+ name: bundler
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - "~>"
200
+ - !ruby/object:Gem::Version
201
+ version: '2.0'
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - "~>"
207
+ - !ruby/object:Gem::Version
208
+ version: '2.0'
209
+ - !ruby/object:Gem::Dependency
210
+ name: rake
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - "~>"
214
+ - !ruby/object:Gem::Version
215
+ version: '10.0'
216
+ type: :development
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - "~>"
221
+ - !ruby/object:Gem::Version
222
+ version: '10.0'
223
+ description: This is a remote controller to command for the turle draw graphics.
224
+ email:
225
+ - youchan01@gmail.com
226
+ executables: []
227
+ extensions: []
228
+ extra_rdoc_files: []
229
+ files:
230
+ - ".gitignore"
231
+ - Gemfile
232
+ - Gemfile.lock
233
+ - LICENSE.txt
234
+ - README.md
235
+ - Rakefile
236
+ - bin/console
237
+ - bin/setup
238
+ - config.ru
239
+ - config/database.yml
240
+ - kame-remocon.gemspec
241
+ - lib/kame/remocon.rb
242
+ - lib/kame/remocon/assets/css/application.scss
243
+ - lib/kame/remocon/assets/images/kame.png
244
+ - lib/kame/remocon/commander.rb
245
+ - lib/kame/remocon/opal/application.rb
246
+ - lib/kame/remocon/opal/canvas.rb
247
+ - lib/kame/remocon/opal/config.rb
248
+ - lib/kame/remocon/opal/controllers/application_controller.rb
249
+ - lib/kame/remocon/opal/image.rb
250
+ - lib/kame/remocon/opal/turtle.rb
251
+ - lib/kame/remocon/opal/views/canvas.rb
252
+ - lib/kame/remocon/opal/views/canvas_view.rb
253
+ - lib/kame/remocon/remote_object.rb
254
+ - lib/kame/remocon/server.rb
255
+ - lib/kame/remocon/turtle_proxy.rb
256
+ - lib/kame/remocon/version.rb
257
+ - lib/kame/remocon/views/index.haml
258
+ - lib/kame_remocon.rb
259
+ homepage: https://github.com/youchan/kame-remocon
260
+ licenses:
261
+ - MIT
262
+ metadata: {}
263
+ post_install_message:
264
+ rdoc_options: []
265
+ require_paths:
266
+ - lib
267
+ required_ruby_version: !ruby/object:Gem::Requirement
268
+ requirements:
269
+ - - ">="
270
+ - !ruby/object:Gem::Version
271
+ version: '0'
272
+ required_rubygems_version: !ruby/object:Gem::Requirement
273
+ requirements:
274
+ - - ">="
275
+ - !ruby/object:Gem::Version
276
+ version: '0'
277
+ requirements: []
278
+ rubyforge_project:
279
+ rubygems_version: 2.7.6
280
+ signing_key:
281
+ specification_version: 4
282
+ summary: Turtle Graphics
283
+ test_files: []