leapmotion 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +30 -0
- data/History.txt +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +72 -0
- data/Rakefile +1 -0
- data/leapmotion.gemspec +28 -0
- data/lib/leapmotion.rb +10 -0
- data/lib/leapmotion/main.rb +42 -0
- data/lib/leapmotion/version.rb +3 -0
- data/samples/dump.rb +26 -0
- metadata +140 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8a7745b555b8eee26548bb59ad793ea27597171f
|
4
|
+
data.tar.gz: 9fe17f8b3a625be013e5ba1ee7bec776302a2cc7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f0a3519eb71a44a84f01e58e149937beeaa851bb9f03be70af3b856526cff4326cac0005413c2715f926bfa50b1c17d28ec4624429b534e10aae28df0d13895c
|
7
|
+
data.tar.gz: cae818cf0ec459333b2ed7228d7190467bae747ea90f015a410a131b7cd7006d60b2a1190fc3d456e4f86b4c382427181774dc041b11933ead7942a8b2d695eb
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
leapmotion (0.0.1)
|
5
|
+
event_emitter
|
6
|
+
hashie
|
7
|
+
json
|
8
|
+
websocket-client-simple
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: https://rubygems.org/
|
12
|
+
specs:
|
13
|
+
event_emitter (0.2.5)
|
14
|
+
hashie (2.0.5)
|
15
|
+
json (1.8.0)
|
16
|
+
json (1.8.0-java)
|
17
|
+
rake (10.1.0)
|
18
|
+
websocket (1.1.1)
|
19
|
+
websocket-client-simple (0.0.5)
|
20
|
+
event_emitter
|
21
|
+
websocket
|
22
|
+
|
23
|
+
PLATFORMS
|
24
|
+
java
|
25
|
+
ruby
|
26
|
+
|
27
|
+
DEPENDENCIES
|
28
|
+
bundler (~> 1.3)
|
29
|
+
leapmotion!
|
30
|
+
rake
|
data/History.txt
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Sho Hashimoto
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
LeapMotion
|
2
|
+
==========
|
3
|
+
LeapMotion WebSocket wrapper for Ruby
|
4
|
+
|
5
|
+
Install
|
6
|
+
-------
|
7
|
+
|
8
|
+
% gem install leapmotion
|
9
|
+
|
10
|
+
|
11
|
+
Requirements
|
12
|
+
------------
|
13
|
+
|
14
|
+
- Ruby1.8.7+
|
15
|
+
- [Leap Motion.app](https://www.leapmotion.com/setup)
|
16
|
+
|
17
|
+
|
18
|
+
Samples
|
19
|
+
-------
|
20
|
+
- https://github.com/shokai/ruby-leapmotion/tree/master/samples
|
21
|
+
|
22
|
+
|
23
|
+
Usage
|
24
|
+
-----
|
25
|
+
|
26
|
+
### start "Leap Motion.app"
|
27
|
+
|
28
|
+
- `/Applications/Leap Motion.app`
|
29
|
+
- It provides WebSocket API.
|
30
|
+
|
31
|
+
<img src="http://shokai.org/archive/file/31d034b4fa72350a67a94f85a00b83a2.png">
|
32
|
+
|
33
|
+
|
34
|
+
### run ruby
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
require 'rubygems'
|
38
|
+
require 'leapmotion'
|
39
|
+
|
40
|
+
leap = LeapMotion.connect
|
41
|
+
|
42
|
+
leap.on :connect do
|
43
|
+
puts "connect"
|
44
|
+
end
|
45
|
+
|
46
|
+
leap.on :disconnect do
|
47
|
+
puts "disconnect"
|
48
|
+
exit
|
49
|
+
end
|
50
|
+
|
51
|
+
leap.on :data do |data|
|
52
|
+
puts "hands #{data.hands.size}"
|
53
|
+
puts "pointables #{data.pointables.size}"
|
54
|
+
puts data
|
55
|
+
puts "-"*5
|
56
|
+
end
|
57
|
+
|
58
|
+
leap.on :error do |err|
|
59
|
+
STDERR.puts err
|
60
|
+
end
|
61
|
+
|
62
|
+
leap.wait
|
63
|
+
```
|
64
|
+
|
65
|
+
|
66
|
+
Contributing
|
67
|
+
------------
|
68
|
+
1. Fork it
|
69
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
70
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
71
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
72
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/leapmotion.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'leapmotion/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "leapmotion"
|
8
|
+
spec.version = LeapMotion::VERSION
|
9
|
+
spec.authors = ["Sho Hashimoto"]
|
10
|
+
spec.email = ["hashimoto@shokai.org"]
|
11
|
+
spec.description = %q{LeapMotion WebSocket wrapper for Ruby}
|
12
|
+
spec.summary = spec.description
|
13
|
+
spec.homepage = "https://github.com/shokai/ruby-leapmotion"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "websocket-client-simple"
|
22
|
+
spec.add_dependency "event_emitter"
|
23
|
+
spec.add_dependency "json"
|
24
|
+
spec.add_dependency "hashie"
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
27
|
+
spec.add_development_dependency "rake"
|
28
|
+
end
|
data/lib/leapmotion.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
module LeapMotion
|
2
|
+
def self.connect(ws_url=nil)
|
3
|
+
ws_url = "http://localhost:6437" unless ws_url
|
4
|
+
LeapMotion::Device.new ws_url
|
5
|
+
end
|
6
|
+
|
7
|
+
class Data < Hashie::Mash
|
8
|
+
end
|
9
|
+
|
10
|
+
class Device
|
11
|
+
include EventEmitter
|
12
|
+
attr_accessor :version
|
13
|
+
|
14
|
+
def initialize(ws_url)
|
15
|
+
@ws = WebSocket::Client::Simple.connect ws_url
|
16
|
+
@version = nil
|
17
|
+
this = self
|
18
|
+
@ws.on :message do |msg|
|
19
|
+
data = Data.new JSON.parse msg.data rescue this.emit :error, "JSON parse error"
|
20
|
+
if data.has_key? "currentFrameRate"
|
21
|
+
this.emit :data, data
|
22
|
+
elsif data.has_key? "version"
|
23
|
+
this.version = data.version
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
@ws.on :open do
|
28
|
+
this.emit :connect
|
29
|
+
end
|
30
|
+
|
31
|
+
@ws.on :close do
|
32
|
+
this.emit :disconnect
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def wait
|
37
|
+
loop do
|
38
|
+
sleep 1
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/samples/dump.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
$:.unshift File.expand_path "../lib", File.dirname(__FILE__)
|
2
|
+
require 'leapmotion'
|
3
|
+
|
4
|
+
leap = LeapMotion.connect ARGV.shift
|
5
|
+
|
6
|
+
leap.on :connect do
|
7
|
+
puts "connect"
|
8
|
+
end
|
9
|
+
|
10
|
+
leap.on :disconnect do
|
11
|
+
puts "disconnect"
|
12
|
+
exit
|
13
|
+
end
|
14
|
+
|
15
|
+
leap.on :data do |data|
|
16
|
+
puts "hands #{data.hands.size}"
|
17
|
+
puts "pointables #{data.pointables.size}"
|
18
|
+
puts data
|
19
|
+
puts "-"*5
|
20
|
+
end
|
21
|
+
|
22
|
+
leap.on :error do |err|
|
23
|
+
STDERR.puts err
|
24
|
+
end
|
25
|
+
|
26
|
+
leap.wait
|
metadata
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: leapmotion
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sho Hashimoto
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-07-31 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: websocket-client-simple
|
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: event_emitter
|
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: json
|
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: hashie
|
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: bundler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.3'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.3'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: LeapMotion WebSocket wrapper for Ruby
|
98
|
+
email:
|
99
|
+
- hashimoto@shokai.org
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- .gitignore
|
105
|
+
- Gemfile
|
106
|
+
- Gemfile.lock
|
107
|
+
- History.txt
|
108
|
+
- LICENSE.txt
|
109
|
+
- README.md
|
110
|
+
- Rakefile
|
111
|
+
- leapmotion.gemspec
|
112
|
+
- lib/leapmotion.rb
|
113
|
+
- lib/leapmotion/main.rb
|
114
|
+
- lib/leapmotion/version.rb
|
115
|
+
- samples/dump.rb
|
116
|
+
homepage: https://github.com/shokai/ruby-leapmotion
|
117
|
+
licenses:
|
118
|
+
- MIT
|
119
|
+
metadata: {}
|
120
|
+
post_install_message:
|
121
|
+
rdoc_options: []
|
122
|
+
require_paths:
|
123
|
+
- lib
|
124
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - '>='
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
requirements: []
|
135
|
+
rubyforge_project:
|
136
|
+
rubygems_version: 2.0.5
|
137
|
+
signing_key:
|
138
|
+
specification_version: 4
|
139
|
+
summary: LeapMotion WebSocket wrapper for Ruby
|
140
|
+
test_files: []
|