blinky 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,7 +6,8 @@ module Blinky
6
6
  self.extend(recipe)
7
7
  plugins.each do |plugin|
8
8
  self.extend(plugin)
9
- end
9
+ end
10
+ self.init
10
11
  end
11
12
 
12
13
  def where_are_you?
@@ -1,3 +1,3 @@
1
1
  module Blinky
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -27,6 +27,9 @@ module Blinky
27
27
  set_colour("\x00")
28
28
  end
29
29
 
30
+ def init
31
+ end
32
+
30
33
  private
31
34
  def set_colour colour
32
35
  @handle.usb_control_msg(0x21, 0x09, 0x0635, 0x000, "\x65\x0C#{colour}\xFF\x00\x00\x00\x00", 0)
@@ -9,7 +9,6 @@ module Blinky
9
9
 
10
10
  def failure!
11
11
  stop
12
- set_flash_pattern("\xFF\x00\x00")
13
12
  play
14
13
  end
15
14
 
@@ -28,32 +27,36 @@ module Blinky
28
27
  set_colour("\x00\x00\x00")
29
28
  end
30
29
 
30
+ def init
31
+ set_flash_pattern("\xFF\x00\x00")
32
+ end
33
+
31
34
  private
32
35
  def set_colour colour
33
- @handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01\x6E#{colour}\x00\x00\x00\x00", 1000)
36
+ @handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01\x6E#{colour}\x00\x00\x00\x00", 0)
34
37
  end
35
38
 
36
39
  def play
37
- @handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01p\x01\x01\x00\x00\x00\x00\x00", 1000)
40
+ @handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01p\x01\x01\x00\x00\x00\x00\x00", 0)
38
41
  end
39
42
 
40
43
  def stop
41
- @handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01p\x00\x01\x00\x00\x00\x00\x00", 1000)
44
+ @handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01p\x00\x01\x00\x00\x00\x00\x00", 0)
42
45
  end
43
46
 
44
47
  def set_flash_pattern colour
45
- @handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P#{colour}\x00\x0A\x00\x00", 1000)
46
- @handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P\x00\x00\x00\x00\x0A\x01\x00", 1000)
47
- @handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P\x00\x00\x00\x00\x00\x02\x00", 1000)
48
- @handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P\x00\x00\x00\x00\x00\x03\x00", 1000)
49
- @handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P\x00\x00\x00\x00\x00\x04\x00", 1000)
50
- @handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P\x00\x00\x00\x00\x00\x05\x00", 1000)
51
- @handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P\x00\x00\x00\x00\x00\x06\x00", 1000)
52
- @handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P\x00\x00\x00\x00\x00\x07\x00", 1000)
53
- @handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P\x00\x00\x00\x00\x00\x08\x00", 1000)
54
- @handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P\x00\x00\x00\x00\x00\x09\x00", 1000)
55
- @handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P\x00\x00\x00\x00\x00\x0A\x00", 1000)
56
- @handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P\x00\x00\x00\x00\x00\x0B\x00", 1000)
48
+ @handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P#{colour}\x00\x0A\x00\x00", 0)
49
+ @handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P\x00\x00\x00\x00\x0A\x01\x00", 0)
50
+ @handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P\x00\x00\x00\x00\x00\x02\x00", 0)
51
+ @handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P\x00\x00\x00\x00\x00\x03\x00", 0)
52
+ @handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P\x00\x00\x00\x00\x00\x04\x00", 0)
53
+ @handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P\x00\x00\x00\x00\x00\x05\x00", 0)
54
+ @handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P\x00\x00\x00\x00\x00\x06\x00", 0)
55
+ @handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P\x00\x00\x00\x00\x00\x07\x00", 0)
56
+ @handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P\x00\x00\x00\x00\x00\x08\x00", 0)
57
+ @handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P\x00\x00\x00\x00\x00\x09\x00", 0)
58
+ @handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P\x00\x00\x00\x00\x00\x0A\x00", 0)
59
+ @handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P\x00\x00\x00\x00\x00\x0B\x00", 0)
57
60
  end
58
61
 
59
62
  end
@@ -5,6 +5,9 @@ module Blinky
5
5
  def success!
6
6
  @handle.indicate_success
7
7
  end
8
+
9
+ def init
10
+ end
8
11
 
9
12
  end
10
13
  end
@@ -6,6 +6,9 @@ module Blinky
6
6
  @handle.indicate_success
7
7
  end
8
8
 
9
+ def init
10
+ end
11
+
9
12
  end
10
13
  end
11
14
  end
@@ -14,6 +14,9 @@ module Blinky
14
14
  @handle.turn_off
15
15
  end
16
16
 
17
+ def init
18
+ end
19
+
17
20
  end
18
21
  end
19
22
  end
@@ -6,7 +6,12 @@ module Blinky
6
6
  module TestModel
7
7
  def success!
8
8
  @handle.indicate_success
9
- end
9
+ end
10
+
11
+ def init
12
+ @handle.init
13
+ end
14
+
10
15
  end
11
16
  end
12
17
 
@@ -24,11 +29,18 @@ module Blinky
24
29
 
25
30
 
26
31
  describe "Light" do
32
+
33
+ it "will use device recipe to initialise itself on construction" do
34
+ supported_device = double("supported device",:idVendor => 0x2000, :idProduct => 0x2222)
35
+ supported_device.should_receive(:init)
36
+ Light.new(supported_device, TestEngineering::TestModel, [MockCiPlugin, AnotherMockCiPlugin ] )
37
+ end
27
38
 
28
39
  describe "that has been constructed with a device, a device recipe, and some CI plugins" do
29
40
 
30
41
  before(:each) do
31
- @supported_device = double("supported device",:idVendor => 0x2000, :idProduct => 0x2222)
42
+ @supported_device = double("supported device",:idVendor => 0x2000, :idProduct => 0x2222)
43
+ @supported_device.stub(:init)
32
44
  @light = Light.new(@supported_device, TestEngineering::TestModel, [MockCiPlugin, AnotherMockCiPlugin ] )
33
45
  end
34
46
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blinky
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: