blinky 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.rdoc +91 -0
- data/Rakefile +42 -0
- data/VERSION +1 -0
- data/blinky.gemspec +78 -0
- data/lib/blinky.rb +57 -0
- data/lib/blinky/no_supported_devices_found.rb +17 -0
- data/lib/ci_server_plugins/test_server_plugin.rb +39 -0
- data/lib/device_recipes/delcom_engineering/visual_indicator_gen_one.rb +37 -0
- data/lib/device_recipes/delcom_engineering/visual_indicator_gen_two.rb +33 -0
- data/lib/plugins.rb +1 -0
- data/lib/recipes.rb +13 -0
- data/notes.txt +29 -0
- data/spec/blinky_spec.rb +123 -0
- data/spec/ci_server_plugins/test_server_plugin_spec.rb +34 -0
- data/spec/fixtures/ci_server_plugins/mock_ci_server.rb +7 -0
- data/spec/fixtures/device_recipes/aenima_engineering/model_462.rb +11 -0
- data/spec/fixtures/device_recipes/aenima_engineering/model_eulogy.rb +11 -0
- data/spec/fixtures/device_recipes/fragile_engineering/wretched.rb +11 -0
- data/spec/fixtures/plugins.rb +1 -0
- data/spec/fixtures/recipes.rb +13 -0
- data/spec/spec_helper.rb +8 -0
- metadata +128 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Perryn Fowler
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
= blinky
|
2
|
+
|
3
|
+
blinky helps you see the light - get a build light up and running in a few minutes.
|
4
|
+
|
5
|
+
== Why blinky?
|
6
|
+
|
7
|
+
Setting up a build light on a new project always seems to be more of a hassle than it should be. Somehow it always seems that no one else has ever dealt with the exact combination of OS, CI Server and build light that you have in your sweaty little hands, and you have to write something from scratch. Again.
|
8
|
+
|
9
|
+
blinky is an attempt to fix that.
|
10
|
+
|
11
|
+
blinky aims to supply plug and play support for all combinations of
|
12
|
+
* USB Light Model (or any other USB Device used to indicate build status)
|
13
|
+
* Operating System
|
14
|
+
|
15
|
+
== How do I use blinky?
|
16
|
+
|
17
|
+
Plug in your USB light, and then do something like this
|
18
|
+
|
19
|
+
require 'rubygems'
|
20
|
+
require 'blinky'
|
21
|
+
|
22
|
+
blinky = Blinky.new
|
23
|
+
|
24
|
+
You can also manipulate the light directly
|
25
|
+
|
26
|
+
blinky.success!
|
27
|
+
blinky.failure!
|
28
|
+
blinky.building!
|
29
|
+
blinky.warning!
|
30
|
+
blinky.off!
|
31
|
+
|
32
|
+
|
33
|
+
== What is currently supported?
|
34
|
+
|
35
|
+
=== Lights/ Build Indicators
|
36
|
+
* Delcom Engineering USB Visual Indicator Generation I
|
37
|
+
* Delcom Engineering USB Visual Indicator Generation II
|
38
|
+
|
39
|
+
=== Operating Systems
|
40
|
+
* OSX
|
41
|
+
* Linux
|
42
|
+
* Windows (Theoretically)
|
43
|
+
|
44
|
+
NOTE: I haven't been able to test fully on Windows yet. Any assistance with doing so, and/or providing more complete installation instructions would be gratefully received.
|
45
|
+
|
46
|
+
== How Do I install blinky?
|
47
|
+
|
48
|
+
=== 1) Install support for lib-usb-0.1 (http://www.libusb.org)
|
49
|
+
|
50
|
+
==== OSX and Linux
|
51
|
+
|
52
|
+
Install lib-usb-1.0 and the lib-usb-compat-0.1 layer with your favourite package manager.
|
53
|
+
|
54
|
+
For example, on OSX
|
55
|
+
|
56
|
+
brew install libusb-compat
|
57
|
+
|
58
|
+
==== Windows
|
59
|
+
|
60
|
+
install lib-usb-win32. See http://www.libusb.org/wiki/libusb-win32
|
61
|
+
|
62
|
+
(Despite the name, this apparently supports both win-32 and win-64)
|
63
|
+
|
64
|
+
=== 2) Install the blinky gem
|
65
|
+
|
66
|
+
gem install blinky
|
67
|
+
|
68
|
+
NOTE: on OSX will probably need to provide your machine architecture. For example:
|
69
|
+
|
70
|
+
ARCHFLAGS="-arch x86_64" gem install blinky
|
71
|
+
|
72
|
+
=== 3) Test your installation
|
73
|
+
|
74
|
+
Plug in your light and then do this:
|
75
|
+
|
76
|
+
require 'rubygems'
|
77
|
+
require 'blinky'
|
78
|
+
|
79
|
+
blinky = Blinky.new
|
80
|
+
blinky.watch_test_server
|
81
|
+
|
82
|
+
Watch the pretty lights!
|
83
|
+
|
84
|
+
== How do I contribute support for more lights
|
85
|
+
|
86
|
+
COMING SOON
|
87
|
+
|
88
|
+
|
89
|
+
== Copyright
|
90
|
+
|
91
|
+
Copyright (c) 2010 Perryn Fowler. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
desc "Check if blinky is working with your USB device"
|
5
|
+
task :check_device do
|
6
|
+
require 'manual_tests/device_checker'
|
7
|
+
DeviceChecker.new.check
|
8
|
+
end
|
9
|
+
|
10
|
+
begin
|
11
|
+
require 'jeweler'
|
12
|
+
Jeweler::Tasks.new do |gem|
|
13
|
+
gem.name = "blinky"
|
14
|
+
gem.summary = %Q{helps you see the light}
|
15
|
+
gem.description = %Q{plug and play support for USB build status indicators}
|
16
|
+
gem.email = "perryn.fowler@gmail.com"
|
17
|
+
gem.homepage = "http://github.com/perryn/blinky"
|
18
|
+
gem.authors = ["Perryn Fowler"]
|
19
|
+
gem.add_dependency "ruby-usb", ">= 0.2.1"
|
20
|
+
gem.add_development_dependency "rspec", ">= 0"
|
21
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
22
|
+
end
|
23
|
+
Jeweler::GemcutterTasks.new
|
24
|
+
rescue LoadError
|
25
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
26
|
+
end
|
27
|
+
|
28
|
+
require 'spec/rake/spectask'
|
29
|
+
|
30
|
+
Spec::Rake::SpecTask.new do |t|
|
31
|
+
t.warning = true
|
32
|
+
end
|
33
|
+
|
34
|
+
require 'rake/rdoctask'
|
35
|
+
Rake::RDocTask.new do |rdoc|
|
36
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
37
|
+
|
38
|
+
rdoc.rdoc_dir = 'rdoc'
|
39
|
+
rdoc.title = "blinky #{version}"
|
40
|
+
rdoc.rdoc_files.include('README*')
|
41
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
42
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
data/blinky.gemspec
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{blinky}
|
8
|
+
s.version = "0.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Perryn Fowler"]
|
12
|
+
s.date = %q{2011-01-14}
|
13
|
+
s.description = %q{plug and play support for USB build status indicators}
|
14
|
+
s.email = %q{perryn.fowler@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
"LICENSE",
|
23
|
+
"README.rdoc",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"blinky.gemspec",
|
27
|
+
"lib/blinky.rb",
|
28
|
+
"lib/blinky/no_supported_devices_found.rb",
|
29
|
+
"lib/ci_server_plugins/test_server_plugin.rb",
|
30
|
+
"lib/device_recipes/delcom_engineering/visual_indicator_gen_one.rb",
|
31
|
+
"lib/device_recipes/delcom_engineering/visual_indicator_gen_two.rb",
|
32
|
+
"lib/plugins.rb",
|
33
|
+
"lib/recipes.rb",
|
34
|
+
"notes.txt",
|
35
|
+
"spec/blinky_spec.rb",
|
36
|
+
"spec/ci_server_plugins/test_server_plugin_spec.rb",
|
37
|
+
"spec/fixtures/ci_server_plugins/mock_ci_server.rb",
|
38
|
+
"spec/fixtures/device_recipes/aenima_engineering/model_462.rb",
|
39
|
+
"spec/fixtures/device_recipes/aenima_engineering/model_eulogy.rb",
|
40
|
+
"spec/fixtures/device_recipes/fragile_engineering/wretched.rb",
|
41
|
+
"spec/fixtures/plugins.rb",
|
42
|
+
"spec/fixtures/recipes.rb",
|
43
|
+
"spec/spec_helper.rb"
|
44
|
+
]
|
45
|
+
s.homepage = %q{http://github.com/perryn/blinky}
|
46
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
47
|
+
s.require_paths = ["lib"]
|
48
|
+
s.rubygems_version = %q{1.3.7}
|
49
|
+
s.summary = %q{helps you see the light}
|
50
|
+
s.test_files = [
|
51
|
+
"spec/blinky_spec.rb",
|
52
|
+
"spec/ci_server_plugins/test_server_plugin_spec.rb",
|
53
|
+
"spec/fixtures/ci_server_plugins/mock_ci_server.rb",
|
54
|
+
"spec/fixtures/device_recipes/aenima_engineering/model_462.rb",
|
55
|
+
"spec/fixtures/device_recipes/aenima_engineering/model_eulogy.rb",
|
56
|
+
"spec/fixtures/device_recipes/fragile_engineering/wretched.rb",
|
57
|
+
"spec/fixtures/plugins.rb",
|
58
|
+
"spec/fixtures/recipes.rb",
|
59
|
+
"spec/spec_helper.rb"
|
60
|
+
]
|
61
|
+
|
62
|
+
if s.respond_to? :specification_version then
|
63
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
64
|
+
s.specification_version = 3
|
65
|
+
|
66
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
67
|
+
s.add_runtime_dependency(%q<ruby-usb>, [">= 0.2.1"])
|
68
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
69
|
+
else
|
70
|
+
s.add_dependency(%q<ruby-usb>, [">= 0.2.1"])
|
71
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
72
|
+
end
|
73
|
+
else
|
74
|
+
s.add_dependency(%q<ruby-usb>, [">= 0.2.1"])
|
75
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
data/lib/blinky.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__))
|
2
|
+
|
3
|
+
require 'usb'
|
4
|
+
require 'blinky/no_supported_devices_found'
|
5
|
+
|
6
|
+
module Blinky
|
7
|
+
|
8
|
+
def self.new
|
9
|
+
Blinky.new
|
10
|
+
end
|
11
|
+
|
12
|
+
class Blinky
|
13
|
+
|
14
|
+
def initialize(path = File.dirname(__FILE__))
|
15
|
+
|
16
|
+
Dir["#{path}/device_recipes/**/*.rb"].each { |f| require(f) }
|
17
|
+
Dir["#{path}/ci_server_plugins/**/*.rb"].each { |f| require(f) }
|
18
|
+
@recipes = Hash.new(:default => {})
|
19
|
+
@plugins = []
|
20
|
+
instance_eval(File.read("#{path}/recipes.rb"))
|
21
|
+
instance_eval(File.read("#{path}/plugins.rb"))
|
22
|
+
|
23
|
+
@plugins.each do |plugin|
|
24
|
+
self.extend(plugin)
|
25
|
+
end
|
26
|
+
found_devices = []
|
27
|
+
|
28
|
+
@handle = nil
|
29
|
+
|
30
|
+
USB.devices.each do |device|
|
31
|
+
found_devices << device
|
32
|
+
matching_recipe = @recipes[device.idVendor][device.idProduct]
|
33
|
+
if matching_recipe
|
34
|
+
self.extend(matching_recipe)
|
35
|
+
@handle = device.usb_open
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
raise NoSupportedDevicesFound.new found_devices unless @handle
|
40
|
+
end
|
41
|
+
|
42
|
+
def recipe recipe_module, details
|
43
|
+
if @recipes[details[:usb_vendor_id]].empty?
|
44
|
+
@recipes[details[:usb_vendor_id]] = {details[:usb_product_id] => recipe_module}
|
45
|
+
else
|
46
|
+
@recipes[details[:usb_vendor_id]][details[:usb_product_id]] = recipe_module
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
def plugin plugin_module
|
52
|
+
@plugins << plugin_module
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'pp'
|
2
|
+
|
3
|
+
module Blinky
|
4
|
+
class NoSupportedDevicesFound < RuntimeError
|
5
|
+
def initialize found_devices
|
6
|
+
@found_devices = found_devices
|
7
|
+
end
|
8
|
+
|
9
|
+
#TODO - this doesn't work with ribusb - there is no nice inspect method
|
10
|
+
def to_s
|
11
|
+
"Blinky was unable to find a supported device \n" +
|
12
|
+
"The devices I did find were:\n" +
|
13
|
+
"#{@found_devices.pretty_inspect}\n"
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Blinky
|
2
|
+
module TestCiServer
|
3
|
+
def watch_test_server
|
4
|
+
puts "BUILDING!"
|
5
|
+
building!
|
6
|
+
sleep(2)
|
7
|
+
puts "-"
|
8
|
+
|
9
|
+
puts "BUILD FAILED!"
|
10
|
+
failure!
|
11
|
+
sleep(2)
|
12
|
+
puts "-"
|
13
|
+
|
14
|
+
puts "BUILDING!\n"
|
15
|
+
building!
|
16
|
+
sleep(2)
|
17
|
+
puts "-"
|
18
|
+
|
19
|
+
puts "WARNING!\n"
|
20
|
+
warning!
|
21
|
+
sleep(2)
|
22
|
+
puts "-"
|
23
|
+
|
24
|
+
puts "BUILDING!\n"
|
25
|
+
building!
|
26
|
+
sleep(2)
|
27
|
+
puts "-"
|
28
|
+
|
29
|
+
puts "BUILD PASSED!\n"
|
30
|
+
success!
|
31
|
+
sleep(2)
|
32
|
+
puts "-"
|
33
|
+
|
34
|
+
puts "TEST OVER\n"
|
35
|
+
off!
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Blinky
|
2
|
+
module DelcomEngineering
|
3
|
+
module VisualIndicator
|
4
|
+
module GenerationI
|
5
|
+
|
6
|
+
def success!
|
7
|
+
set_colour(0xFF && ~0x01)
|
8
|
+
end
|
9
|
+
|
10
|
+
def failure!
|
11
|
+
set_colour(0xFF && ~0x02)
|
12
|
+
end
|
13
|
+
|
14
|
+
def building!
|
15
|
+
set_colour(0xFF && ~0x04)
|
16
|
+
end
|
17
|
+
|
18
|
+
def warning!
|
19
|
+
set_colour(0xFF && ~0x03)
|
20
|
+
end
|
21
|
+
|
22
|
+
def off!
|
23
|
+
set_colour(0xFF)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
def set_colour colour
|
28
|
+
begin
|
29
|
+
@handle.usb_control_msg(0xc8, 0x12, 0x020a, colour,"",0)
|
30
|
+
rescue Errno::EPIPE
|
31
|
+
# broken pipe error are always thrown here - this is fixed in the ribusb branch
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Blinky
|
2
|
+
module DelcomEngineering
|
3
|
+
module VisualIndicator
|
4
|
+
module GenerationII
|
5
|
+
|
6
|
+
def success!
|
7
|
+
set_colour("\x01")
|
8
|
+
end
|
9
|
+
|
10
|
+
def failure!
|
11
|
+
set_colour("\x02")
|
12
|
+
end
|
13
|
+
|
14
|
+
def building!
|
15
|
+
set_colour("\x04")
|
16
|
+
end
|
17
|
+
|
18
|
+
def warning!
|
19
|
+
set_colour("\x07")
|
20
|
+
end
|
21
|
+
|
22
|
+
def off!
|
23
|
+
set_colour("\x00")
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
def set_colour colour
|
28
|
+
@handle.usb_control_msg(0x21, 0x09, 0x0635, 0x000, "\x65\x0C#{colour}\xFF\x00\x00\x00\x00", 0)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/plugins.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
plugin TestCiServer
|
data/lib/recipes.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
recipe DelcomEngineering::VisualIndicator::GenerationI, {:usb_vendor_id => 0x0fc5,
|
2
|
+
:usb_product_id => 0x1223,
|
3
|
+
:description => "USB Visual Signal Indicator Gen I"}
|
4
|
+
|
5
|
+
recipe DelcomEngineering::VisualIndicator::GenerationII, {:usb_vendor_id => 0x0fc5,
|
6
|
+
:usb_product_id => 0xb080,
|
7
|
+
:description => "USB Visual Signal Indicator Gen II"}
|
8
|
+
|
9
|
+
|
10
|
+
#TODO - use treeop to allow a syntax like this
|
11
|
+
|
12
|
+
# DelcomEngineering 0x0fc5
|
13
|
+
# Model804005 0x1223 "USB HID Visual Signal Indicator RGB"
|
data/notes.txt
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
- To use ruby-usb you need the libusb-compat-0.1
|
2
|
+
- ??? make a new binding for libusb-1.0? - ribusb??
|
3
|
+
|
4
|
+
- sudo ARCHFLAGS="-arch x86_64" gem install blinky
|
5
|
+
- might be a better way of fixing this?
|
6
|
+
|
7
|
+
- add rescue to usb.rb
|
8
|
+
|
9
|
+
- names of usb_control_msg parameters are basically piffle - just send data in them
|
10
|
+
|
11
|
+
- need to swap data around for some reason? low order byte * 256?
|
12
|
+
|
13
|
+
- Errno::EPIPE: Broken pipe - usb_control_msg
|
14
|
+
why does this happen? endpoint initialization?
|
15
|
+
|
16
|
+
|
17
|
+
------------- ubuntu
|
18
|
+
|
19
|
+
no libusb-compat? came automatically in some other package
|
20
|
+
|
21
|
+
--------------- window
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
---- ribusb
|
28
|
+
|
29
|
+
none of above necessary - maybe libusb compat is still needed?
|
data/spec/blinky_spec.rb
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '/spec_helper')
|
2
|
+
|
3
|
+
module Blinky
|
4
|
+
describe "Blinky" do
|
5
|
+
|
6
|
+
describe "that has a supported device connected" do
|
7
|
+
|
8
|
+
before(:each) do
|
9
|
+
@supported_device = OpenStruct.new(:idVendor => 0x2000, :idProduct => 0x2222)
|
10
|
+
self.connected_devices = [
|
11
|
+
OpenStruct.new(:idVendor => 0x1234, :idProduct => 0x5678),
|
12
|
+
@supported_device,
|
13
|
+
OpenStruct.new(:idVendor => 0x5678, :idProduct => 0x1234)
|
14
|
+
]
|
15
|
+
@blinky = Blinky.new("#{File.dirname(__FILE__)}/fixtures")
|
16
|
+
end
|
17
|
+
|
18
|
+
it "can call recipe methods on the device" do
|
19
|
+
@supported_device.should_receive(:indicate_success)
|
20
|
+
@blinky.success!
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "that supports two devices from the same vendor" do
|
26
|
+
|
27
|
+
it "can call recipe methods on the first device" do
|
28
|
+
supported_device_one = OpenStruct.new(:idVendor => 0x1000, :idProduct => 0x1111)
|
29
|
+
self.connected_devices = [supported_device_one]
|
30
|
+
@blinky = Blinky.new("#{File.dirname(__FILE__)}/fixtures")
|
31
|
+
supported_device_one.should_receive(:indicate_success)
|
32
|
+
@blinky.success!
|
33
|
+
end
|
34
|
+
|
35
|
+
it "can call recipe methods on the second device" do
|
36
|
+
supported_device_two = OpenStruct.new(:idVendor => 0x1000, :idProduct => 0x2222)
|
37
|
+
self.connected_devices = [supported_device_two]
|
38
|
+
@blinky = Blinky.new("#{File.dirname(__FILE__)}/fixtures")
|
39
|
+
supported_device_two.should_receive(:indicate_success)
|
40
|
+
@blinky.success!
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "that has no supported devices connected" do
|
45
|
+
|
46
|
+
before(:each) do
|
47
|
+
@devices = [
|
48
|
+
OpenStruct.new(:idVendor => 0x1234, :idProduct => 0x5678),
|
49
|
+
OpenStruct.new(:idVendor => 0x5678, :idProduct => 0x1234)
|
50
|
+
]
|
51
|
+
self.connected_devices= @devices
|
52
|
+
end
|
53
|
+
|
54
|
+
it "will complain" do
|
55
|
+
exception = Exception.new("foo")
|
56
|
+
NoSupportedDevicesFound.should_receive(:new).with(@devices).and_return(exception)
|
57
|
+
lambda{Blinky.new("#{File.dirname(__FILE__)}/fixtures")}.should raise_error("foo")
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
describe "that has no supported devices connected - but does have one from the same vendor" do
|
63
|
+
|
64
|
+
before(:each) do
|
65
|
+
@devices = [
|
66
|
+
OpenStruct.new(:idVendor => 0x1000, :idProduct => 0x5678),
|
67
|
+
OpenStruct.new(:idVendor => 0x5678, :idProduct => 0x1234)
|
68
|
+
]
|
69
|
+
self.connected_devices= @devices
|
70
|
+
end
|
71
|
+
|
72
|
+
it "will complain" do
|
73
|
+
exception = Exception.new("foo")
|
74
|
+
NoSupportedDevicesFound.should_receive(:new).with(@devices).and_return(exception)
|
75
|
+
lambda{Blinky.new("#{File.dirname(__FILE__)}/fixtures")}.should raise_error("foo")
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
describe "that has two supported devices connected" do
|
81
|
+
|
82
|
+
before(:each) do
|
83
|
+
@supported_device_one = OpenStruct.new(:idVendor => 0x1000, :idProduct => 0x1111)
|
84
|
+
@supported_device_two = OpenStruct.new(:idVendor => 0x2000, :idProduct => 0x2222)
|
85
|
+
|
86
|
+
self.connected_devices = [
|
87
|
+
OpenStruct.new(:idVendor => 0x1234, :idProduct => 0x5678),
|
88
|
+
@supported_device_one,
|
89
|
+
@supported_device_two
|
90
|
+
]
|
91
|
+
@blinky = Blinky.new("#{File.dirname(__FILE__)}/fixtures")
|
92
|
+
end
|
93
|
+
|
94
|
+
it "will choose the second device" do
|
95
|
+
@supported_device_one.should_not_receive(:indicate_success)
|
96
|
+
@supported_device_two.should_receive(:indicate_success)
|
97
|
+
@blinky.success!
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe "that is asked to watch a supported CI server" do
|
102
|
+
|
103
|
+
before(:each) do
|
104
|
+
self.connected_devices = [OpenStruct.new(:idVendor => 0x1000, :idProduct => 0x1111)]
|
105
|
+
@blinky = Blinky.new("#{File.dirname(__FILE__)}/fixtures")
|
106
|
+
end
|
107
|
+
|
108
|
+
it "can receive call backs from the server" do
|
109
|
+
@blinky.should_receive(:notify_build_status)
|
110
|
+
@blinky.watch_mock_ci_server
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
def connected_devices= devices
|
116
|
+
devices.each do |device|
|
117
|
+
device.stub!(:usb_open).and_return(device)
|
118
|
+
end
|
119
|
+
USB.stub!(:devices).and_return(devices)
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
123
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', '/spec_helper')
|
2
|
+
require 'ci_server_plugins/test_server_plugin'
|
3
|
+
module Blinky
|
4
|
+
|
5
|
+
class StubBlinky
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "TestCiServer" do
|
9
|
+
|
10
|
+
before(:each) do
|
11
|
+
@blinky = StubBlinky.new
|
12
|
+
@blinky.extend(TestCiServer)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "cycles through all possible statuses" do
|
16
|
+
@blinky.should_receive(:building!).ordered
|
17
|
+
@blinky.should_receive(:sleep).ordered
|
18
|
+
@blinky.should_receive(:failure!).ordered
|
19
|
+
@blinky.should_receive(:sleep).ordered
|
20
|
+
@blinky.should_receive(:building!).ordered
|
21
|
+
@blinky.should_receive(:sleep).ordered
|
22
|
+
@blinky.should_receive(:warning!).ordered
|
23
|
+
@blinky.should_receive(:sleep).ordered
|
24
|
+
@blinky.should_receive(:building!).ordered
|
25
|
+
@blinky.should_receive(:sleep).ordered
|
26
|
+
@blinky.should_receive(:success!).ordered
|
27
|
+
@blinky.should_receive(:sleep).ordered
|
28
|
+
@blinky.should_receive(:off!).ordered
|
29
|
+
|
30
|
+
@blinky.watch_test_server
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
plugin MockCiServer
|
@@ -0,0 +1,13 @@
|
|
1
|
+
recipe AenimaEngineering::ModelEulogy, {:usb_vendor_id => 0x1000,
|
2
|
+
:usb_product_id => 0x2222,
|
3
|
+
:description => "We need the space to nail the next fool martyr"}
|
4
|
+
|
5
|
+
recipe AenimaEngineering::Model462, {:usb_vendor_id => 0x1000,
|
6
|
+
:usb_product_id => 0x1111,
|
7
|
+
:description => "I've been picking my scabs again"}
|
8
|
+
|
9
|
+
recipe FragileEngineering::ModelWretched, {:usb_vendor_id => 0x2000,
|
10
|
+
:usb_product_id => 0x2222,
|
11
|
+
:description => "It didn't turn out like you wanted it to"}
|
12
|
+
|
13
|
+
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: blinky
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Perryn Fowler
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-01-14 00:00:00 +11:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: ruby-usb
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 21
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
- 2
|
33
|
+
- 1
|
34
|
+
version: 0.2.1
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: rspec
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 3
|
46
|
+
segments:
|
47
|
+
- 0
|
48
|
+
version: "0"
|
49
|
+
type: :development
|
50
|
+
version_requirements: *id002
|
51
|
+
description: plug and play support for USB build status indicators
|
52
|
+
email: perryn.fowler@gmail.com
|
53
|
+
executables: []
|
54
|
+
|
55
|
+
extensions: []
|
56
|
+
|
57
|
+
extra_rdoc_files:
|
58
|
+
- LICENSE
|
59
|
+
- README.rdoc
|
60
|
+
files:
|
61
|
+
- .document
|
62
|
+
- .gitignore
|
63
|
+
- LICENSE
|
64
|
+
- README.rdoc
|
65
|
+
- Rakefile
|
66
|
+
- VERSION
|
67
|
+
- blinky.gemspec
|
68
|
+
- lib/blinky.rb
|
69
|
+
- lib/blinky/no_supported_devices_found.rb
|
70
|
+
- lib/ci_server_plugins/test_server_plugin.rb
|
71
|
+
- lib/device_recipes/delcom_engineering/visual_indicator_gen_one.rb
|
72
|
+
- lib/device_recipes/delcom_engineering/visual_indicator_gen_two.rb
|
73
|
+
- lib/plugins.rb
|
74
|
+
- lib/recipes.rb
|
75
|
+
- notes.txt
|
76
|
+
- spec/blinky_spec.rb
|
77
|
+
- spec/ci_server_plugins/test_server_plugin_spec.rb
|
78
|
+
- spec/fixtures/ci_server_plugins/mock_ci_server.rb
|
79
|
+
- spec/fixtures/device_recipes/aenima_engineering/model_462.rb
|
80
|
+
- spec/fixtures/device_recipes/aenima_engineering/model_eulogy.rb
|
81
|
+
- spec/fixtures/device_recipes/fragile_engineering/wretched.rb
|
82
|
+
- spec/fixtures/plugins.rb
|
83
|
+
- spec/fixtures/recipes.rb
|
84
|
+
- spec/spec_helper.rb
|
85
|
+
has_rdoc: true
|
86
|
+
homepage: http://github.com/perryn/blinky
|
87
|
+
licenses: []
|
88
|
+
|
89
|
+
post_install_message:
|
90
|
+
rdoc_options:
|
91
|
+
- --charset=UTF-8
|
92
|
+
require_paths:
|
93
|
+
- lib
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
none: false
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
hash: 3
|
100
|
+
segments:
|
101
|
+
- 0
|
102
|
+
version: "0"
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
none: false
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
hash: 3
|
109
|
+
segments:
|
110
|
+
- 0
|
111
|
+
version: "0"
|
112
|
+
requirements: []
|
113
|
+
|
114
|
+
rubyforge_project:
|
115
|
+
rubygems_version: 1.3.7
|
116
|
+
signing_key:
|
117
|
+
specification_version: 3
|
118
|
+
summary: helps you see the light
|
119
|
+
test_files:
|
120
|
+
- spec/blinky_spec.rb
|
121
|
+
- spec/ci_server_plugins/test_server_plugin_spec.rb
|
122
|
+
- spec/fixtures/ci_server_plugins/mock_ci_server.rb
|
123
|
+
- spec/fixtures/device_recipes/aenima_engineering/model_462.rb
|
124
|
+
- spec/fixtures/device_recipes/aenima_engineering/model_eulogy.rb
|
125
|
+
- spec/fixtures/device_recipes/fragile_engineering/wretched.rb
|
126
|
+
- spec/fixtures/plugins.rb
|
127
|
+
- spec/fixtures/recipes.rb
|
128
|
+
- spec/spec_helper.rb
|