hybridgroup-sphero 1.4.0 → 1.5.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9489e051b7741739de177d300237fde32e83c389
4
+ data.tar.gz: 7dfbef2bd387098056e68bd0dcf0720a2a58933b
5
+ SHA512:
6
+ metadata.gz: 1a84f98465cbbd43be2db4377b34cc6f8404ee7d9a000904c21c006f729b311a21b040064e70faf6bafee9ca289e3c7256499f4e211492b55d97dee7f5da6ddc
7
+ data.tar.gz: bd986b6e790b9ea326a9a2db4fc9a3abb596c8974192075a832fc4eae4160cb5285694872046e9daae21e6a8a30e5633e0cb68351e5a856bb2e31bb3a0886618
@@ -0,0 +1,4 @@
1
+ pkg
2
+ .rvmrc
3
+ .rbx
4
+ Gemfile.lock
@@ -0,0 +1,10 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 2.1.0
5
+ - 1.9.3
6
+ - jruby
7
+ - rbx-2.2.10
8
+ script:
9
+ - bundle install
10
+ - bundle exec rake test
@@ -37,3 +37,9 @@
37
37
  * 1 enhancement
38
38
 
39
39
  * Add constants FORWARD, BACKWARD, RIGHT, & LEFT for quick directionality
40
+
41
+ === 1.5.0 / 2014-02-06
42
+
43
+ * Many enhancements and bugfixes
44
+
45
+ * Been too long since our last changelog entry. Many bugfixes and enhancements.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ # A sample Gemfile
2
+ source "https://rubygems.org"
3
+
4
+ gemspec
@@ -2,6 +2,8 @@
2
2
 
3
3
  * http://github.com/hybridgroup/sphero
4
4
 
5
+ [![Build Status](https://travis-ci.org/hybridgroup/sphero.png?branch=master)](https://travis-ci.org/hybridgroup/sphero)
6
+
5
7
  ## DESCRIPTION:
6
8
 
7
9
  A ruby gem for controlling your Sphero ball. Sends commands over the TTY
@@ -101,7 +103,7 @@ You may now access the sphero from `/dev/rfcomm0`
101
103
 
102
104
  ## INSTALL:
103
105
 
104
- * gem install hybridgroup-sphero
106
+ * gem install sphero
105
107
 
106
108
  ## LICENSE:
107
109
 
data/Rakefile CHANGED
@@ -1,23 +1,11 @@
1
- # -*- ruby -*-
2
-
3
- require 'rubygems'
4
- require 'hoe'
5
-
6
- Hoe.plugins.delete :rubyforge
7
- Hoe.plugins.delete :flog
8
- Hoe.plugin :minitest
9
- Hoe.plugin :gemspec # `gem install hoe-gemspec`
10
- Hoe.plugin :git # `gem install hoe-git`
11
-
12
- Hoe.spec 'hybridgroup-sphero' do
13
- developer('Hybrid Group', 'sphero@hybridgroup.com')
14
- self.readme_file = 'README.markdown'
15
- self.history_file = 'CHANGELOG.rdoc'
16
- self.extra_rdoc_files = FileList['*.{rdoc,markdown}']
17
-
18
- self.spec_extras = {
19
- :required_ruby_version => '>= 1.9.2'
20
- }
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require 'rake/testtask'
4
+
5
+ Rake::TestTask.new do |t|
6
+ t.libs.push "lib"
7
+ t.test_files = FileList['test/*.rb']
8
+ t.verbose = true
21
9
  end
22
10
 
23
- # vim: syntax=ruby
11
+ task :default => [:test]
@@ -1,10 +1,9 @@
1
1
  require 'sphero/request'
2
2
  require 'sphero/response'
3
3
  require 'thread'
4
+ require 'rubyserial'
4
5
 
5
6
  class Sphero
6
- VERSION = '1.4.0'
7
-
8
7
  FORWARD = 0
9
8
  RIGHT = 90
10
9
  BACKWARD = 180
@@ -12,7 +11,7 @@ class Sphero
12
11
 
13
12
  DEFAULT_RETRIES = 3
14
13
 
15
- attr_accessor :connection_types, :messages
14
+ attr_accessor :connection_types, :messages, :packets, :response_queue, :responses
16
15
 
17
16
  class << self
18
17
  def start(dev, &block)
@@ -21,17 +20,19 @@ class Sphero
21
20
  sphero = self.new dev
22
21
  if (block_given?)
23
22
  begin
24
- sphero.instance_eval(&block)
23
+ sphero.instance_eval(&block)
25
24
  ensure
26
- sphero.close
25
+ sphero.close
27
26
  end
28
27
  return nil
29
28
  end
30
- return sphero
31
- rescue Errno::EBUSY
32
- puts retries_left
33
- retries_left = retries_left - 1
34
- retry unless retries_left < 0
29
+ return sphero
30
+ rescue RubySerial::Exception => e
31
+ if e.message == 'EBUSY'
32
+ puts retries_left
33
+ retries_left = retries_left - 1
34
+ retry unless retries_left < 0
35
+ end
35
36
  end
36
37
  end
37
38
  end
@@ -47,11 +48,26 @@ class Sphero
47
48
  @seq = 0x00
48
49
  @lock = Mutex.new
49
50
  @messages = Queue.new
51
+ @packets = Queue.new
52
+ @response_queue = Queue.new
53
+ @responses = []
54
+ Thread.new {
55
+ loop do
56
+ write @packets.pop
57
+ end
58
+ }
59
+ Thread.new {
60
+ loop do
61
+ @responses << @response_queue.pop
62
+ end
63
+ }
50
64
  end
51
-
65
+
52
66
  def close
67
+ return if @sp.nil? || @sp.closed?
53
68
  begin
54
69
  stop
70
+ sleep 2
55
71
  rescue Exception => e
56
72
  puts e.message
57
73
  ensure
@@ -60,39 +76,57 @@ class Sphero
60
76
  end
61
77
 
62
78
  def ping
63
- write Request::Ping.new(@seq)
79
+ packet = Request::Ping.new(@seq)
80
+ queue_packet packet
81
+ return sync_response packet.seq
64
82
  end
65
83
 
66
84
  def version
67
- write Request::GetVersioning.new(@seq)
85
+ packet = Request::GetVersioning.new(@seq)
86
+ queue_packet packet
87
+ return sync_response packet.seq
68
88
  end
69
89
 
70
90
  def bluetooth_info
71
- write Request::GetBluetoothInfo.new(@seq)
91
+ packet = Request::GetBluetoothInfo.new(@seq)
92
+ queue_packet packet
93
+ return sync_response packet.seq
94
+ end
95
+
96
+ # This retrieves the "user LED color" which is stored in the config block
97
+ # (which may or may not be actively driven to the RGB LED).
98
+ def user_led
99
+ packet = Request::GetRGB.new(@seq)
100
+ queue_packet packet
101
+ return sync_response packet.seq
72
102
  end
73
103
 
74
104
  def auto_reconnect= time_s
75
- write Request::SetAutoReconnect.new(@seq, time_s)
105
+ queue_packet Request::SetAutoReconnect.new(@seq, limit1(time_s) )
76
106
  end
77
107
 
78
108
  def auto_reconnect
79
- write(Request::GetAutoReconnect.new(@seq)).time
109
+ queue_packet(Request::GetAutoReconnect.new(@seq)).time
80
110
  end
81
111
 
82
112
  def disable_auto_reconnect
83
- write Request::SetAutoReconnect.new(@seq, 0, 0x00)
113
+ queue_packet Request::SetAutoReconnect.new(@seq, 0, flag(false) )
114
+ end
115
+
116
+ def enable_stop_on_disconnect
117
+ queue_packet Request::SetTempOptionFlags.new(@seq, flag(true))
84
118
  end
85
119
 
86
120
  def power_state
87
- write Request::GetPowerState.new(@seq)
121
+ queue_packet Request::GetPowerState.new(@seq)
88
122
  end
89
123
 
90
124
  def sphero_sleep wakeup = 0, macro = 0
91
- write Request::Sleep.new(@seq, wakeup, macro)
125
+ queue_packet Request::Sleep.new(@seq, limit2(wakeup), limit1(macro) )
92
126
  end
93
127
 
94
128
  def roll speed, heading, state = true
95
- write Request::Roll.new(@seq, speed, heading, state ? 0x01 : 0x00)
129
+ queue_packet Request::Roll.new(@seq, limit1(speed), degrees(heading), flag(state) )
96
130
  end
97
131
 
98
132
  def stop
@@ -100,7 +134,11 @@ class Sphero
100
134
  end
101
135
 
102
136
  def heading= h
103
- write Request::Heading.new(@seq, h)
137
+ queue_packet Request::Heading.new(@seq, degrees(h) )
138
+ end
139
+
140
+ def stabilization= on
141
+ queue_packet Request::Stabilization.new(@seq, on)
104
142
  end
105
143
 
106
144
  def color colorname, persistant = false
@@ -109,23 +147,18 @@ class Sphero
109
147
  end
110
148
 
111
149
  def rgb r, g, b, persistant = false
112
- write Request::SetRGB.new(@seq, r, g, b, persistant ? 0x01 : 0x00)
150
+ queue_packet Request::SetRGB.new(@seq, limit1(r), limit1(g), limit1(b), flag(persistant) )
113
151
  end
114
152
 
115
- # This retrieves the "user LED color" which is stored in the config block
116
- # (which may or may not be actively driven to the RGB LED).
117
- def user_led
118
- write Request::GetRGB.new(@seq)
119
- end
120
153
 
121
154
  # Brightness 0x00 - 0xFF
122
155
  def back_led_output= h
123
- write Request::SetBackLEDOutput.new(@seq, h)
156
+ queue_packet Request::SetBackLEDOutput.new(@seq, limit1(h) )
124
157
  end
125
158
 
126
159
  # Rotation Rate 0x00 - 0xFF
127
160
  def rotation_rate= h
128
- write Request::SetRotationRate.new(@seq, h)
161
+ queue_packet Request::SetRotationRate.new(@seq, limit1(h))
129
162
  end
130
163
 
131
164
  # just a nicer alias for Ruby's own sleep
@@ -137,21 +170,82 @@ class Sphero
137
170
 
138
171
  # configure power notification messages
139
172
  def set_power_notification enable=true
140
- write Request::SetPowerNotification.new(@seq, enable ? 0x01 : 0x00)
173
+ queue_packet Request::SetPowerNotification.new(@seq, flag(enable) )
141
174
  end
142
175
 
143
176
  # configure data streaming notification messages
144
177
  def set_data_streaming n, m, mask, pcnt, mask2
145
- write Request::SetDataStreaming.new(@seq, n, m, mask, pcnt, mask2)
178
+ queue_packet Request::SetDataStreaming.new(@seq, limit2(n), limit2(m),
179
+ limit4(mask), limit1(pcnt), limit4(mask2) )
146
180
  end
147
181
 
148
182
  # configure collision detection messages
149
183
  def configure_collision_detection meth, x_t, y_t, x_spd, y_spd, dead
150
- write Request::ConfigureCollisionDetection.new(@seq, meth, x_t, y_t, x_spd, y_spd, dead)
184
+ queue_packet Request::ConfigureCollisionDetection.new(@seq, limit1(meth),
185
+ limit1(x_t), limit1(y_t),
186
+ limit1(x_spd), limit1(y_spd),
187
+ limit1(dead) )
151
188
  end
152
-
189
+
153
190
  private
154
-
191
+
192
+ def sync_response seq
193
+ 100.times do
194
+ @responses.each do |response|
195
+ if response.seq == seq
196
+ @responses.delete(response)
197
+ return response
198
+ end
199
+ end
200
+ sleep 0.001
201
+ end
202
+ return nil
203
+ end
204
+
205
+ def limit(value, max)
206
+ return nil if value.nil?
207
+
208
+ value = value.to_i
209
+ if value < 0
210
+ 0
211
+ elsif value > max
212
+ max
213
+ else
214
+ value
215
+ end
216
+ end
217
+
218
+ def wrap(value, max)
219
+ value && (value.to_i % max)
220
+ end
221
+
222
+ def degrees(value)
223
+ wrap value, 360
224
+ end
225
+
226
+ def limit1(value)
227
+ limit value, 0xFF
228
+ end
229
+
230
+ def limit2(value)
231
+ limit value, 0xFFFF
232
+ end
233
+
234
+ def limit4(value)
235
+ limit value, 0xFFFFFFFF
236
+ end
237
+
238
+ def flag(value)
239
+ case value
240
+ when true
241
+ 0x01
242
+ when false
243
+ 0x00
244
+ else
245
+ value
246
+ end
247
+ end
248
+
155
249
  def is_windows?
156
250
  os = RUBY_PLATFORM.split("-")[1]
157
251
  if (os == 'mswin' or os == 'bccwin' or os == 'mingw' or os == 'mingw32')
@@ -162,36 +256,26 @@ class Sphero
162
256
  end
163
257
 
164
258
  def initialize_serialport dev
165
- require 'serialport'
166
- @sp = SerialPort.new dev, 115200, 8, 1, SerialPort::NONE
167
- if is_windows?
168
- @sp.read_timeout=1000
169
- @sp.write_timeout=0
170
- @sp.initial_byte_offset=5
171
- end
172
- rescue LoadError
173
- puts "Please 'gem install hybridgroup-serialport' for serial port support."
259
+ @sp = Serial.new dev, 115200
260
+ rescue RubySerial::Exception => e
261
+ retry if e.message == 'EBUSY'
262
+ end
263
+
264
+ def queue_packet packet
265
+ @packets << packet
174
266
  end
175
267
 
176
268
  def write packet
177
269
  header, body = nil
178
270
 
179
- IO.select([], [@sp], [], 20)
180
-
181
- @lock.synchronize do
182
- @sp.write packet.to_str
183
- @seq += 1
184
- end
185
-
186
- IO.select([@sp], [], [], 20)
271
+ @sp.write packet.to_str
272
+ @seq += 1
187
273
  header = read_header(true)
188
274
  body = read_body(header.last, true) if header
189
-
190
275
  # pick off asynch packets and store, till we get to the message response
191
276
  while header && Response.async?(header)
192
277
  messages << Response::AsyncResponse.response(header, body)
193
278
 
194
- IO.select([@sp], [], [], 20)
195
279
  header = read_header(true)
196
280
  if header
197
281
  body = read_body(header.last, true)
@@ -203,9 +287,9 @@ class Sphero
203
287
  response = packet.response header, body
204
288
 
205
289
  if response.success?
206
- response
290
+ @response_queue << response
207
291
  else
208
- raise "Unable to write to Sphero!"
292
+ puts "Unable to write to Sphero!"
209
293
  end
210
294
  end
211
295
 
@@ -213,10 +297,10 @@ class Sphero
213
297
  header = nil
214
298
  begin
215
299
  data = read_next_chunk(5, blocking)
216
- return nil unless data
300
+ return nil unless data && data.length == 5
217
301
  header = data.unpack 'C5'
218
- rescue Errno::EBUSY
219
- retry
302
+ rescue RubySerial::Exception => e
303
+ retry if e.message == 'EBUSY'
220
304
  rescue Exception => e
221
305
  puts e.message
222
306
  puts e.backtrace.inspect
@@ -231,8 +315,8 @@ class Sphero
231
315
  begin
232
316
  data = read_next_chunk(len, blocking)
233
317
  return nil unless data && data.length == len
234
- rescue Errno::EBUSY
235
- retry
318
+ rescue RubySerial::Exception => e
319
+ retry if e.message == 'EBUSY'
236
320
  rescue Exception => e
237
321
  puts e.message
238
322
  puts e.backtrace.inspect
@@ -245,15 +329,13 @@ class Sphero
245
329
  def read_next_chunk(len, blocking=false)
246
330
  data = nil
247
331
  begin
248
- @lock.synchronize do
249
- if blocking || is_windows?
250
- data = @sp.read(len)
251
- else
252
- data = @sp.read_nonblock(len)
253
- end
332
+ if blocking || is_windows?
333
+ data = @sp.read(len)
334
+ else
335
+ data = @sp.read_nonblock(len)
254
336
  end
255
- rescue Errno::EBUSY
256
- retry
337
+ rescue RubySerial::Exception => e
338
+ retry if e.message == 'EBUSY'
257
339
  rescue Exception => e
258
340
  puts e.message
259
341
  puts e.backtrace.inspect
@@ -376,6 +458,7 @@ class Sphero
376
458
  'plum' => {:r => 221, :g => 160, :b => 221},
377
459
  'powderblue' => {:r => 176, :g => 224, :b => 230},
378
460
  'purple' => {:r => 128, :g => 0, :b => 128},
461
+ 'rebeccapurple' => {:r => 102, :g => 51, :b => 153},
379
462
  'red' => {:r => 255, :g => 0, :b => 0},
380
463
  'rosybrown' => {:r => 188, :g => 143, :b => 143},
381
464
  'royalblue' => {:r => 65, :g => 105, :b => 225},
@@ -3,7 +3,7 @@ class Sphero
3
3
  SOP1 = 0xFF
4
4
  SOP2 = 0xFF
5
5
 
6
- attr_reader :data
6
+ attr_reader :data, :seq
7
7
 
8
8
  def initialize seq, data = []
9
9
  @seq = seq
@@ -89,7 +89,7 @@ class Sphero
89
89
  end
90
90
  end
91
91
 
92
- class Heading < Request
92
+ class Heading < Sphero
93
93
  def initialize seq, heading
94
94
  super(seq, [heading])
95
95
  @cid = 0x01
@@ -101,6 +101,18 @@ class Sphero
101
101
  end
102
102
  end
103
103
 
104
+ class Stabilization < Sphero
105
+ def initialize seq, on
106
+ super(seq, [on ? 1 : 0])
107
+ @cid = 0x02
108
+ end
109
+
110
+ private
111
+ def packet_body
112
+ @data.pack 'C'
113
+ end
114
+ end
115
+
104
116
  class Sleep < Request
105
117
  def initialize seq, wakeup, macro
106
118
  super(seq, [wakeup, macro])
@@ -114,13 +126,26 @@ class Sphero
114
126
  end
115
127
  end
116
128
 
117
- class SetPowerNotification < Sphero
129
+ class SetPowerNotification < Request
118
130
  def initialize seq, enable
119
131
  super(seq, [enable])
120
132
  @cid = 0x21
121
133
  end
122
134
  end
123
135
 
136
+ class SetTempOptionFlags < Request
137
+ def initialize seq, flag
138
+ super(seq, [flag])
139
+ @cid = 0x37
140
+ @did = 0x02
141
+ end
142
+
143
+ private
144
+ def packet_body
145
+ @data.pack 'N'
146
+ end
147
+ end
148
+
124
149
  GYRO_AXIS_H_FILTERED = 0x0000_0001
125
150
  GYRO_AXIS_M_FILTERED = 0x0000_0002
126
151
  GYRO_AXIS_L_FILTERED = 0x0000_0004
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ Gem::Specification.new do |gem|
3
+ gem.authors = ["The Hybrid Group"]
4
+ gem.email = ["sphero@hybridgroup.com"]
5
+ gem.description = "A ruby gem for controlling your Sphero ball. Sends commands over the TTY\nprovided by the bluetooth connection."
6
+ gem.summary = "A ruby gem for controlling your Sphero ball"
7
+ gem.homepage = "http://github.com/hybridgroup/sphero"
8
+
9
+ gem.files = `git ls-files`.split($\)
10
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
11
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
12
+ gem.name = "hybridgroup-sphero"
13
+ gem.require_paths = ["lib"]
14
+ gem.version = "1.5.2"
15
+
16
+ gem.add_development_dependency "rake", "~>10.0.4"
17
+ gem.add_development_dependency "mocha", "~>0.13.3"
18
+ gem.add_development_dependency "minitest", "~>5.0.8"
19
+
20
+ gem.add_runtime_dependency "rubyserial", "~>0.1.1"
21
+ end
@@ -23,49 +23,55 @@ class TestSphero < MiniTest::Unit::TestCase
23
23
  end
24
24
 
25
25
  def test_ping
26
- Sphero::Request::Ping.expects(:new).with(@seq)
27
- @sphero.expects(:write)
26
+ packet = mock 'packet'
27
+ packet.stubs(:seq).returns(@seq)
28
+ Sphero::Request::Ping.expects(:new).with(@seq).returns(packet)
29
+ @sphero.expects(:queue_packet).returns(packet)
28
30
  @sphero.ping
29
31
  end
30
32
 
31
33
  def test_version
32
- Sphero::Request::GetVersioning.expects(:new).with(@seq)
33
- @sphero.expects(:write)
34
+ packet = mock 'packet'
35
+ packet.stubs(:seq).returns(@seq)
36
+ Sphero::Request::GetVersioning.expects(:new).with(@seq).returns(packet)
37
+ @sphero.expects(:queue_packet).returns(packet)
34
38
  @sphero.version
35
39
  end
36
40
 
37
41
  def test_bluetooth_info
38
- Sphero::Request::GetBluetoothInfo.expects(:new).with(@seq)
39
- @sphero.expects(:write)
42
+ packet = mock 'packet'
43
+ packet.stubs(:seq).returns(@seq)
44
+ Sphero::Request::GetBluetoothInfo.expects(:new).with(@seq).returns(packet)
45
+ @sphero.expects(:queue_packet).returns(packet)
40
46
  @sphero.bluetooth_info
41
47
  end
42
48
 
43
49
  def test_auto_reconnect=
44
- @time_s = "10"
50
+ @time_s = 10
45
51
  Sphero::Request::SetAutoReconnect.expects(:new).with(@seq, @time_s)
46
- @sphero.expects(:write)
52
+ @sphero.expects(:queue_packet)
47
53
  @sphero.auto_reconnect = @time_s
48
54
  end
49
55
 
50
56
  def test_auto_reconnect
51
- @time_s = "10"
57
+ @time_s = 10
52
58
  packet = mock 'packet'
53
59
  packet.stubs(:time).returns(@time_s)
54
60
 
55
61
  Sphero::Request::GetAutoReconnect.expects(:new).with(@seq)
56
- @sphero.expects(:write).returns(packet)
62
+ @sphero.expects(:queue_packet).returns(packet)
57
63
  assert_equal @sphero.auto_reconnect, @time_s
58
64
  end
59
65
 
60
66
  def test_disable_auto_reconnect
61
67
  Sphero::Request::SetAutoReconnect.expects(:new).with(@seq, 0, 0x00)
62
- @sphero.expects(:write)
68
+ @sphero.expects(:queue_packet)
63
69
  @sphero.disable_auto_reconnect
64
70
  end
65
71
 
66
72
  def test_power_state
67
73
  Sphero::Request::GetPowerState.expects(:new).with(@seq)
68
- @sphero.expects(:write)
74
+ @sphero.expects(:queue_packet)
69
75
  @sphero.power_state
70
76
  end
71
77
 
@@ -73,19 +79,73 @@ class TestSphero < MiniTest::Unit::TestCase
73
79
  wakeup = 1
74
80
  macro = 2
75
81
  Sphero::Request::Sleep.expects(:new).with(@seq, wakeup, macro)
76
- @sphero.expects(:write)
82
+ @sphero.expects(:queue_packet)
77
83
  @sphero.sphero_sleep wakeup, macro
78
84
  end
79
85
 
86
+ def test_stabilization
87
+ Sphero::Request::Stabilization.expects(:new).with(@seq, true)
88
+ @sphero.expects(:queue_packet)
89
+ @sphero.stabilization = true
90
+ end
91
+
80
92
  def test_roll
81
93
  speed = 1
82
94
  heading = 2
83
95
  state = 1
84
96
  Sphero::Request::Roll.expects(:new).with(@seq, speed, heading, state)
85
- @sphero.expects(:write)
97
+ @sphero.expects(:queue_packet)
86
98
  @sphero.roll speed, heading, true
87
99
  end
88
100
 
101
+ def test_roll_upper_limit
102
+ heading = 2
103
+ state = 1
104
+ Sphero::Request::Roll.expects(:new).with(@seq, 255, heading, state)
105
+ @sphero.expects(:queue_packet)
106
+ @sphero.roll 300, heading, true
107
+ end
108
+
109
+ def test_roll_lower_limit
110
+ heading = 2
111
+ state = 1
112
+ Sphero::Request::Roll.expects(:new).with(@seq, 0, heading, state)
113
+ @sphero.expects(:queue_packet)
114
+ @sphero.roll( -10, heading, true )
115
+ end
116
+
117
+ def test_roll_limit_conversion
118
+ heading = 2
119
+ state = 1
120
+ Sphero::Request::Roll.expects(:new).with(@seq, 123, heading, state)
121
+ @sphero.expects(:queue_packet)
122
+ @sphero.roll 123.4, heading, true
123
+ end
124
+
125
+ def test_roll_upper_wrap
126
+ speed = 3
127
+ state = 1
128
+ Sphero::Request::Roll.expects(:new).with(@seq, speed, 1, state)
129
+ @sphero.expects(:queue_packet)
130
+ @sphero.roll speed, 361, true
131
+ end
132
+
133
+ def test_roll_lower_wrap
134
+ speed = 3
135
+ state = 1
136
+ Sphero::Request::Roll.expects(:new).with(@seq, speed, 359, state)
137
+ @sphero.expects(:queue_packet)
138
+ @sphero.roll( speed, -1, true )
139
+ end
140
+
141
+ def test_roll_limit_wrap
142
+ speed = 3
143
+ state = 1
144
+ Sphero::Request::Roll.expects(:new).with(@seq, speed, 123, state)
145
+ @sphero.expects(:queue_packet)
146
+ @sphero.roll speed, 123.4, true
147
+ end
148
+
89
149
  def test_stop
90
150
  @sphero.expects(:roll).with(0, 0)
91
151
  @sphero.stop
metadata CHANGED
@@ -1,64 +1,86 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hybridgroup-sphero
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
5
- prerelease:
4
+ version: 1.5.2
6
5
  platform: ruby
7
6
  authors:
8
- - Hybrid Group
7
+ - The Hybrid Group
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-07-25 00:00:00.000000000 Z
11
+ date: 2014-09-24 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- name: rdoc
14
+ name: rake
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
- version: '4.0'
19
+ version: 10.0.4
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
- version: '4.0'
26
+ version: 10.0.4
30
27
  - !ruby/object:Gem::Dependency
31
- name: hoe
28
+ name: mocha
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ~>
31
+ - - "~>"
36
32
  - !ruby/object:Gem::Version
37
- version: '3.6'
33
+ version: 0.13.3
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ~>
38
+ - - "~>"
44
39
  - !ruby/object:Gem::Version
45
- version: '3.6'
46
- description: ! 'A ruby gem for controlling your Sphero ball. Sends commands over
47
- the TTY
48
-
49
- provided by the bluetooth connection.'
40
+ version: 0.13.3
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 5.0.8
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 5.0.8
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubyserial
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.1.1
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.1.1
69
+ description: |-
70
+ A ruby gem for controlling your Sphero ball. Sends commands over the TTY
71
+ provided by the bluetooth connection.
50
72
  email:
51
73
  - sphero@hybridgroup.com
52
74
  executables:
53
75
  - sphero
54
76
  extensions: []
55
- extra_rdoc_files:
56
- - CHANGELOG.rdoc
57
- - Manifest.txt
58
- - README.markdown
77
+ extra_rdoc_files: []
59
78
  files:
60
- - .autotest
79
+ - ".autotest"
80
+ - ".gitignore"
81
+ - ".travis.yml"
61
82
  - CHANGELOG.rdoc
83
+ - Gemfile
62
84
  - Manifest.txt
63
85
  - README.markdown
64
86
  - Rakefile
@@ -66,35 +88,33 @@ files:
66
88
  - lib/sphero.rb
67
89
  - lib/sphero/request.rb
68
90
  - lib/sphero/response.rb
91
+ - sphero.gemspec
69
92
  - test/test_sphero.rb
70
93
  - test/test_sphero_request.rb
71
- - .gemtest
72
94
  homepage: http://github.com/hybridgroup/sphero
73
95
  licenses: []
96
+ metadata: {}
74
97
  post_install_message:
75
- rdoc_options:
76
- - --main
77
- - README.markdown
98
+ rdoc_options: []
78
99
  require_paths:
79
100
  - lib
80
101
  required_ruby_version: !ruby/object:Gem::Requirement
81
- none: false
82
102
  requirements:
83
- - - ! '>='
103
+ - - ">="
84
104
  - !ruby/object:Gem::Version
85
- version: 1.9.2
105
+ version: '0'
86
106
  required_rubygems_version: !ruby/object:Gem::Requirement
87
- none: false
88
107
  requirements:
89
- - - ! '>='
108
+ - - ">="
90
109
  - !ruby/object:Gem::Version
91
110
  version: '0'
92
111
  requirements: []
93
- rubyforge_project: hybridgroup-sphero
94
- rubygems_version: 1.8.24
112
+ rubyforge_project:
113
+ rubygems_version: 2.2.2
95
114
  signing_key:
96
- specification_version: 3
115
+ specification_version: 4
97
116
  summary: A ruby gem for controlling your Sphero ball
98
117
  test_files:
99
118
  - test/test_sphero.rb
100
119
  - test/test_sphero_request.rb
120
+ has_rdoc:
data/.gemtest DELETED
File without changes