blinky 0.0.3 → 0.0.4

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.
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in blinky.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,30 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ blinky (0.0.4)
5
+ libusb (~> 0.2.2)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ diff-lcs (1.1.3)
11
+ ffi (1.2.0)
12
+ libusb (0.2.2)
13
+ ffi (>= 1.0)
14
+ rake (10.0.2)
15
+ rspec (2.11.0)
16
+ rspec-core (~> 2.11.0)
17
+ rspec-expectations (~> 2.11.0)
18
+ rspec-mocks (~> 2.11.0)
19
+ rspec-core (2.11.1)
20
+ rspec-expectations (2.11.3)
21
+ diff-lcs (~> 1.1.3)
22
+ rspec-mocks (2.11.3)
23
+
24
+ PLATFORMS
25
+ ruby
26
+
27
+ DEPENDENCIES
28
+ blinky!
29
+ rake (~> 10.0.2)
30
+ rspec (~> 2.11.0)
data/README.rdoc CHANGED
@@ -51,36 +51,42 @@ Not sure which light is which?
51
51
  === Operating Systems
52
52
  * OSX
53
53
  * Linux
54
- * Windows (Theoretically)
55
-
56
- 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.
54
+ * Windows
57
55
 
58
56
  == How Do I install blinky?
59
57
 
60
- === 1) Install support for lib-usb-0.1 (http://www.libusb.org)
58
+ === 1) Install support for lib-usb-1.0 (http://www.libusb.org)
61
59
 
62
60
  ==== OSX and Linux
63
61
 
64
- Install lib-usb-1.0 and the lib-usb-compat-0.1 layer with your favourite package manager.
62
+ Install lib-usb-1.0 with your favourite package manager.
65
63
 
66
- For example, on OSX
64
+ For example, on OSX:
67
65
 
68
- brew install libusb-compat
66
+ brew install libusb
67
+
68
+ on Debian or Ubuntu:
69
+
70
+ $ sudo apt-get install libusb-1.0-0-dev
71
+
72
+ and so on
69
73
 
70
74
  ==== Windows
71
-
72
- install lib-usb-win32. See http://www.libusb.org/wiki/libusb-win32
73
-
74
- (Despite the name, this apparently supports both win-32 and win-64)
75
75
 
76
+ Windows can be a bit fiddly. The following is how I got a Delcomm II light to work on a Windows 7 laptop.
77
+ Further experience reports/better instructions would be gratefully received.
78
+
79
+ * installed Zadig (http://github.com/pbatard/libwdi/wiki#wiki-Downloads)
80
+ * plugged in the USB light
81
+ * at this point windows 'helpfully' installed an incorrect 'USB Input device' driver
82
+ * opened Zadig and selected 'Options -> List All Devices'
83
+ * Selected 'USB Input Device' in the Zadig drop-down
84
+ * Clicked on 'Replace Driver' and confirmed in the popup dialog
85
+
76
86
  === 2) Install the blinky gem
77
87
 
78
88
  gem install blinky
79
-
80
- NOTE: on OSX will probably need to provide your machine architecture. For example:
81
-
82
- ARCHFLAGS="-arch x86_64" gem install blinky
83
-
89
+
84
90
  === 3) Test your installation
85
91
 
86
92
  Plug in your light and then do this:
data/Rakefile CHANGED
@@ -1,42 +1,7 @@
1
1
  require 'rubygems'
2
2
  require 'rake'
3
+ require "bundler/gem_tasks"
3
4
 
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
5
+ require 'rspec/core/rake_task'
6
+ RSpec::Core::RakeTask.new(:spec)
7
+ task :default => :spec
data/blinky.gemspec CHANGED
@@ -1,70 +1,24 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
1
  # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'blinky/version'
5
5
 
6
- Gem::Specification.new do |s|
7
- s.name = %q{blinky}
8
- s.version = "0.0.3"
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "blinky"
8
+ gem.version = Blinky::VERSION
9
+ gem.summary = %q{helps you see the light}
10
+ gem.authors = ["Perryn Fowler"]
11
+ gem.email = ["perryn.fowler@gmail.com"]
12
+ gem.description = %q{plug and play support for USB build status indicators}
13
+ gem.homepage = "http://github.com/perryn/blinky"
9
14
 
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-06-15}
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
- "LICENSE",
22
- "README.rdoc",
23
- "Rakefile",
24
- "VERSION",
25
- "blinky.gemspec",
26
- "lib/blinky.rb",
27
- "lib/blinky/light.rb",
28
- "lib/blinky/light_factory.rb",
29
- "lib/blinky/no_supported_devices_found.rb",
30
- "lib/ci_server_plugins/test_server_plugin.rb",
31
- "lib/device_recipes/delcom_engineering/visual_indicator_gen_one.rb",
32
- "lib/device_recipes/delcom_engineering/visual_indicator_gen_two.rb",
33
- "lib/plugins.rb",
34
- "lib/recipes.rb",
35
- "notes.txt",
36
- "spec/acceptance_spec.rb",
37
- "spec/blinky_spec.rb",
38
- "spec/ci_server_plugins/test_server_plugin_spec.rb",
39
- "spec/fixtures/ci_server_plugins/mock_ci_server.rb",
40
- "spec/fixtures/device_recipes/aenima_engineering/model_462.rb",
41
- "spec/fixtures/device_recipes/aenima_engineering/model_eulogy.rb",
42
- "spec/fixtures/device_recipes/fragile_engineering/wretched.rb",
43
- "spec/fixtures/plugins.rb",
44
- "spec/fixtures/recipes.rb",
45
- "spec/light_factory_spec.rb",
46
- "spec/light_spec.rb",
47
- "spec/spec_helper.rb"
48
- ]
49
- s.homepage = %q{http://github.com/perryn/blinky}
50
- s.require_paths = ["lib"]
51
- s.rubygems_version = %q{1.3.7}
52
- s.summary = %q{helps you see the light}
53
-
54
- if s.respond_to? :specification_version then
55
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
56
- s.specification_version = 3
57
-
58
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
59
- s.add_runtime_dependency(%q<ruby-usb>, [">= 0.2.1"])
60
- s.add_development_dependency(%q<rspec>, [">= 0"])
61
- else
62
- s.add_dependency(%q<ruby-usb>, [">= 0.2.1"])
63
- s.add_dependency(%q<rspec>, [">= 0"])
64
- end
65
- else
66
- s.add_dependency(%q<ruby-usb>, [">= 0.2.1"])
67
- s.add_dependency(%q<rspec>, [">= 0"])
68
- end
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency "libusb", "~> 0.2.2"
21
+
22
+ gem.add_development_dependency "rspec", "~> 2.11.0"
23
+ gem.add_development_dependency "rake", "~> 10.0.2"
69
24
  end
70
-
data/lib/blinky.rb CHANGED
@@ -1,24 +1,24 @@
1
1
  $:.unshift(File.dirname(__FILE__))
2
2
 
3
- require 'usb'
3
+ require 'libusb/compat'
4
4
  require 'blinky/no_supported_devices_found'
5
5
  require 'blinky/light'
6
6
  require 'blinky/light_factory'
7
7
 
8
8
  module Blinky
9
-
9
+
10
10
  def self.new
11
11
  Blinky.new
12
12
  end
13
-
13
+
14
14
  class Blinky
15
-
15
+
16
16
  def initialize(path = File.dirname(__FILE__))
17
-
17
+
18
18
  Dir["#{path}/device_recipes/**/*.rb"].each { |f| require(f) }
19
19
  @recipes = Hash.new({})
20
20
  instance_eval(File.read("#{path}/recipes.rb"))
21
-
21
+
22
22
  Dir["#{path}/ci_server_plugins/**/*.rb"].each { |f| require(f) }
23
23
  @plugins = []
24
24
  instance_eval(File.read("#{path}/plugins.rb"))
@@ -29,7 +29,7 @@ module Blinky
29
29
  def lights
30
30
  @lights
31
31
  end
32
-
32
+
33
33
  def light
34
34
  @lights.first
35
35
  end
@@ -41,11 +41,11 @@ module Blinky
41
41
  @recipes[details[:usb_vendor_id]][details[:usb_product_id]] = recipe_module
42
42
  end
43
43
  end
44
-
44
+
45
45
  def plugin plugin_module
46
46
  @plugins << plugin_module
47
47
  end
48
-
48
+
49
49
  end
50
-
50
+
51
51
  end
data/lib/blinky/light.rb CHANGED
@@ -1,14 +1,14 @@
1
1
  module Blinky
2
2
  class Light
3
-
3
+
4
4
  def initialize device_handle, recipe, plugins
5
- @handle = device_handle
6
- self.extend(recipe)
7
- plugins.each do |plugin|
8
- self.extend(plugin)
9
- end
5
+ @handle = device_handle
6
+ self.extend(recipe)
7
+ plugins.each do |plugin|
8
+ self.extend(plugin)
9
+ end
10
10
  end
11
-
11
+
12
12
  def where_are_you?
13
13
  5.times do
14
14
  failure!
@@ -18,6 +18,6 @@ module Blinky
18
18
  end
19
19
  off!
20
20
  end
21
-
21
+
22
22
  end
23
23
  end
@@ -1,6 +1,6 @@
1
1
  module Blinky
2
2
  class LightFactory
3
-
3
+
4
4
  def self.detect_lights plugins, recipes
5
5
  lights = []
6
6
  found_devices = []
@@ -8,12 +8,12 @@ module Blinky
8
8
  found_devices << device
9
9
  matching_recipe = recipes[device.idVendor][device.idProduct]
10
10
  if matching_recipe
11
- lights << Light.new(device.usb_open, matching_recipe, plugins)
11
+ lights << Light.new(device.open, matching_recipe, plugins)
12
12
  end
13
13
  end
14
14
  raise NoSupportedDevicesFound.new found_devices if lights.empty?
15
15
  lights
16
16
  end
17
-
17
+
18
18
  end
19
19
  end
@@ -5,13 +5,13 @@ module Blinky
5
5
  def initialize found_devices
6
6
  @found_devices = found_devices
7
7
  end
8
-
8
+
9
9
  #TODO - this doesn't work with ribusb - there is no nice inspect method
10
10
  def to_s
11
11
  "Blinky was unable to find a supported device \n" +
12
12
  "The devices I did find were:\n" +
13
13
  "#{@found_devices.pretty_inspect}\n"
14
14
  end
15
-
15
+
16
16
  end
17
17
  end
@@ -0,0 +1,3 @@
1
+ module Blinky
2
+ VERSION = "0.0.4"
3
+ end
@@ -5,35 +5,35 @@ module Blinky
5
5
  building!
6
6
  sleep(2)
7
7
  puts "-"
8
-
8
+
9
9
  puts "BUILD FAILED!"
10
10
  failure!
11
11
  sleep(2)
12
12
  puts "-"
13
-
13
+
14
14
  puts "BUILDING!\n"
15
15
  building!
16
16
  sleep(2)
17
17
  puts "-"
18
-
18
+
19
19
  puts "WARNING!\n"
20
20
  warning!
21
21
  sleep(2)
22
22
  puts "-"
23
-
23
+
24
24
  puts "BUILDING!\n"
25
25
  building!
26
26
  sleep(2)
27
27
  puts "-"
28
-
28
+
29
29
  puts "BUILD PASSED!\n"
30
30
  success!
31
31
  sleep(2)
32
32
  puts "-"
33
-
33
+
34
34
  puts "TEST OVER\n"
35
35
  off!
36
-
36
+
37
37
  end
38
38
  end
39
39
  end
@@ -2,27 +2,27 @@ module Blinky
2
2
  module DelcomEngineering
3
3
  module VisualIndicator
4
4
  module GenerationI
5
-
5
+
6
6
  def success!
7
7
  set_colour(0xFF && ~0x01)
8
8
  end
9
-
9
+
10
10
  def failure!
11
11
  set_colour(0xFF && ~0x02)
12
12
  end
13
-
13
+
14
14
  def building!
15
15
  set_colour(0xFF && ~0x04)
16
16
  end
17
-
17
+
18
18
  def warning!
19
19
  set_colour(0xFF && ~0x03)
20
20
  end
21
-
21
+
22
22
  def off!
23
23
  set_colour(0xFF)
24
24
  end
25
-
25
+
26
26
  private
27
27
  def set_colour colour
28
28
  begin