kame-remocon 0.1.0 → 0.1.1

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: 327d2c1b65a8943ef242bfd4d8c043faa07e302f177769bf71a06d8230607aee
4
- data.tar.gz: '085cca7bb4260f0bf63abd571dcec1f6a0f814723b43f54ccff5fe6e8bdf1e2e'
3
+ metadata.gz: 0afcb5b1e212f5c114f7f61b45a74b9eaf430bae2544574fa9c592612bc335d0
4
+ data.tar.gz: d96dfddb20e7953a91c1025eb2be9a773cb2f00a942f0ea8389965980fbaf973
5
5
  SHA512:
6
- metadata.gz: fc414e89ae63c8527f4687373db0726637ccd7c14f47f9e2589e965692903b90bee4fadbb4b5eb9ffaacbf91c46d38e1feb5fc17640664ab760bbc13770efa73
7
- data.tar.gz: 2f36850135b18c9f96d38b363ec76063067701a80a66645147909e2cf4bb20a53454c38c72282976bbc70061fa30867e698295e6b4259e7dc16c6e978ffd5c83
6
+ metadata.gz: a3a8539d32c7a9199f676c78f38ce700a4db224d5c10685075ab13d0d73a6f7fff4cea45e6b180fedf6b949d7591e486b3dbd000db45d6c17e6bbf13a4c92d20
7
+ data.tar.gz: f474f1a2fac6d0d706a71ce7a92583dae3ae050a43ffa6bf530324a028f5f24509fd53f3918f00ed31970e255c6dce95c1d65a9e9a90bf88fe8e7e2d8ce01eca
@@ -1,23 +1,18 @@
1
1
  require_relative "remocon/version"
2
2
 
3
- require "menilite"
4
3
  require "drb/websocket"
5
- require "sinatra/activerecord"
6
4
  require "launchy"
7
5
 
8
6
  require_relative "remocon/remote_object"
9
7
  require_relative "remocon/server"
10
8
 
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
9
  module Kame
15
10
  module Remocon
16
11
  class Error < StandardError; end
17
12
  end
18
13
 
19
14
  module App
20
- def self.start
15
+ def self.start(context=nil)
21
16
  remote_object = nil
22
17
 
23
18
  app = Rack::Builder.app do
@@ -32,11 +27,6 @@ module Kame
32
27
  map '/assets' do
33
28
  run Kame::Remocon::Server::OPAL.sprockets
34
29
  end
35
-
36
- map '/api' do
37
- router = Menilite::Router.new
38
- run router.routes(server.settings)
39
- end
40
30
  end
41
31
 
42
32
  Thread.new do
@@ -53,6 +43,27 @@ module Kame
53
43
  end
54
44
 
55
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
56
67
  end
57
68
  end
58
69
  end
@@ -1,6 +1,8 @@
1
1
  class Commander
2
2
  attr_reader :commands
3
3
 
4
+ METHODS = [:clear, :reset, :pen_up, :pen_down, :turn_left, :turn_right, :forward, :backward, :move_to]
5
+
4
6
  def initialize(forward = nil)
5
7
  if forward
6
8
  @forward = forward
@@ -48,4 +50,8 @@ class Commander
48
50
  def backward(dist)
49
51
  self << [:forward, -dist]
50
52
  end
53
+
54
+ def move_to(x, y)
55
+ self << [:move_to, x, y]
56
+ end
51
57
  end
@@ -33,8 +33,7 @@ class Turtle
33
33
  end
34
34
 
35
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
36
+ forwarder = Forwarder.new(self, *Commander::METHODS) do
38
37
  @context.clear_rect(0, 0, @canvas.width, @canvas.height)
39
38
  @context.stroke(@path)
40
39
  draw_kame
@@ -149,12 +148,22 @@ class Turtle
149
148
 
150
149
  def forward(dist)
151
150
  @pos = position_to(dist)
151
+ move
152
+ nil
153
+ end
154
+
155
+ def move_to(x, y)
156
+ @pos = Pos.new(x, y)
157
+ move
158
+ nil
159
+ end
160
+
161
+ def move
152
162
  if @pen_down
153
163
  @path.line_to(*@pos.canvas_coordinate)
154
164
  else
155
165
  @path.move_to(*@pos.canvas_coordinate)
156
166
  end
157
- nil
158
167
  end
159
168
 
160
169
  def position_to(dist)
@@ -1,6 +1,8 @@
1
1
  require_relative "commander"
2
2
 
3
3
  class RemoteObject
4
+ attr_reader :turtle
5
+
4
6
  def set_turtle(turtle)
5
7
  @turtle = turtle
6
8
  nil
@@ -1,7 +1,6 @@
1
1
  require 'sinatra'
2
2
  require 'opal'
3
3
  require 'opal/sprockets'
4
- require 'sinatra/activerecord'
5
4
 
6
5
  # if development?
7
6
  # require 'sinatra/reloader'
@@ -14,7 +13,6 @@ class Kame::Remocon::Server < Sinatra::Base
14
13
  #server.append_path File.expand_path("../../../", __FILE__)
15
14
  Opal.use_gem 'hyalite'
16
15
  Opal.use_gem "opal-drb"
17
- Opal.use_gem 'menilite'
18
16
  Opal.use_gem 'kame-remocon'
19
17
  Opal.paths.each {|path| server.append_path path }
20
18
 
@@ -40,4 +40,8 @@ class TurtleProxy
40
40
  def backward(dist)
41
41
  @turtle.backward(dist)
42
42
  end
43
+
44
+ def move_to(x,y)
45
+ @turtle.move_to(x, y)
46
+ end
43
47
  end
@@ -1,5 +1,5 @@
1
1
  module Kame
2
2
  module Remocon
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,197 +1,155 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kame-remocon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - youchan
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-04 00:00:00.000000000 Z
11
+ date: 2019-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
15
15
  requirement: !ruby/object:Gem::Requirement
16
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
- - - ">="
17
+ - - "~>"
32
18
  - !ruby/object:Gem::Version
33
- version: '0'
19
+ version: '2.0'
34
20
  type: :runtime
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
- - - ">="
24
+ - - "~>"
39
25
  - !ruby/object:Gem::Version
40
- version: '0'
26
+ version: '2.0'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: thin
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
- - - ">="
31
+ - - "~>"
46
32
  - !ruby/object:Gem::Version
47
- version: '0'
33
+ version: '1.7'
48
34
  type: :runtime
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
- - - ">="
38
+ - - "~>"
53
39
  - !ruby/object:Gem::Version
54
- version: '0'
40
+ version: '1.7'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: opal-haml
57
43
  requirement: !ruby/object:Gem::Requirement
58
44
  requirements:
59
- - - ">="
45
+ - - "~>"
60
46
  - !ruby/object:Gem::Version
61
- version: '0'
47
+ version: '0.4'
62
48
  type: :runtime
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
- - - ">="
52
+ - - "~>"
67
53
  - !ruby/object:Gem::Version
68
- version: '0'
54
+ version: '0.4'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: hyalite
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  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
- - - ">="
59
+ - - "~>"
88
60
  - !ruby/object:Gem::Version
89
- version: '0'
61
+ version: '0.2'
90
62
  type: :runtime
91
63
  prerelease: false
92
64
  version_requirements: !ruby/object:Gem::Requirement
93
65
  requirements:
94
- - - ">="
66
+ - - "~>"
95
67
  - !ruby/object:Gem::Version
96
- version: '0'
68
+ version: '0.2'
97
69
  - !ruby/object:Gem::Dependency
98
70
  name: rake
99
71
  requirement: !ruby/object:Gem::Requirement
100
72
  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
- - - ">="
73
+ - - "~>"
116
74
  - !ruby/object:Gem::Version
117
- version: '0'
75
+ version: '10.5'
118
76
  type: :runtime
119
77
  prerelease: false
120
78
  version_requirements: !ruby/object:Gem::Requirement
121
79
  requirements:
122
- - - ">="
80
+ - - "~>"
123
81
  - !ruby/object:Gem::Version
124
- version: '0'
82
+ version: '10.5'
125
83
  - !ruby/object:Gem::Dependency
126
84
  name: haml
127
85
  requirement: !ruby/object:Gem::Requirement
128
86
  requirements:
129
- - - ">="
87
+ - - "~>"
130
88
  - !ruby/object:Gem::Version
131
- version: '0'
89
+ version: '5.0'
132
90
  type: :runtime
133
91
  prerelease: false
134
92
  version_requirements: !ruby/object:Gem::Requirement
135
93
  requirements:
136
- - - ">="
94
+ - - "~>"
137
95
  - !ruby/object:Gem::Version
138
- version: '0'
96
+ version: '5.0'
139
97
  - !ruby/object:Gem::Dependency
140
98
  name: sassc
141
99
  requirement: !ruby/object:Gem::Requirement
142
100
  requirements:
143
- - - ">="
101
+ - - "~>"
144
102
  - !ruby/object:Gem::Version
145
- version: '0'
103
+ version: '2.0'
146
104
  type: :runtime
147
105
  prerelease: false
148
106
  version_requirements: !ruby/object:Gem::Requirement
149
107
  requirements:
150
- - - ">="
108
+ - - "~>"
151
109
  - !ruby/object:Gem::Version
152
- version: '0'
110
+ version: '2.0'
153
111
  - !ruby/object:Gem::Dependency
154
112
  name: opal-drb
155
113
  requirement: !ruby/object:Gem::Requirement
156
114
  requirements:
157
- - - ">="
115
+ - - "~>"
158
116
  - !ruby/object:Gem::Version
159
- version: '0'
117
+ version: '0.4'
160
118
  type: :runtime
161
119
  prerelease: false
162
120
  version_requirements: !ruby/object:Gem::Requirement
163
121
  requirements:
164
- - - ">="
122
+ - - "~>"
165
123
  - !ruby/object:Gem::Version
166
- version: '0'
124
+ version: '0.4'
167
125
  - !ruby/object:Gem::Dependency
168
126
  name: drb-websocket
169
127
  requirement: !ruby/object:Gem::Requirement
170
128
  requirements:
171
- - - ">="
129
+ - - "~>"
172
130
  - !ruby/object:Gem::Version
173
- version: '0'
131
+ version: '0.5'
174
132
  type: :runtime
175
133
  prerelease: false
176
134
  version_requirements: !ruby/object:Gem::Requirement
177
135
  requirements:
178
- - - ">="
136
+ - - "~>"
179
137
  - !ruby/object:Gem::Version
180
- version: '0'
138
+ version: '0.5'
181
139
  - !ruby/object:Gem::Dependency
182
140
  name: launchy
183
141
  requirement: !ruby/object:Gem::Requirement
184
142
  requirements:
185
- - - ">="
143
+ - - "~>"
186
144
  - !ruby/object:Gem::Version
187
- version: '0'
145
+ version: '2.4'
188
146
  type: :runtime
189
147
  prerelease: false
190
148
  version_requirements: !ruby/object:Gem::Requirement
191
149
  requirements:
192
- - - ">="
150
+ - - "~>"
193
151
  - !ruby/object:Gem::Version
194
- version: '0'
152
+ version: '2.4'
195
153
  - !ruby/object:Gem::Dependency
196
154
  name: bundler
197
155
  requirement: !ruby/object:Gem::Requirement
@@ -220,24 +178,13 @@ dependencies:
220
178
  - - "~>"
221
179
  - !ruby/object:Gem::Version
222
180
  version: '10.0'
223
- description: This is a remote controller to command for the turle draw graphics.
181
+ description: This is a remote controller to command for the turtle draw graphics.
224
182
  email:
225
183
  - youchan01@gmail.com
226
184
  executables: []
227
185
  extensions: []
228
186
  extra_rdoc_files: []
229
187
  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
188
  - lib/kame/remocon.rb
242
189
  - lib/kame/remocon/assets/css/application.scss
243
190
  - lib/kame/remocon/assets/images/kame.png
@@ -275,8 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
275
222
  - !ruby/object:Gem::Version
276
223
  version: '0'
277
224
  requirements: []
278
- rubyforge_project:
279
- rubygems_version: 2.7.6
225
+ rubygems_version: 3.0.1
280
226
  signing_key:
281
227
  specification_version: 4
282
228
  summary: Turtle Graphics
data/.gitignore DELETED
@@ -1,9 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
- Gemfile.lock
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- # Specify your gem's dependencies in kame-remocon.gemspec
4
- gemspec
@@ -1,21 +0,0 @@
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 DELETED
@@ -1,39 +0,0 @@
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 DELETED
@@ -1,2 +0,0 @@
1
- require "bundler/gem_tasks"
2
- task :default => :spec
@@ -1,14 +0,0 @@
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 DELETED
@@ -1,8 +0,0 @@
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 DELETED
@@ -1,31 +0,0 @@
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)
@@ -1,11 +0,0 @@
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
@@ -1,41 +0,0 @@
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