blinkenlights 0.0.4 → 0.1.0
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/CHANGES +3 -0
- data/{GPL → COPYING} +0 -0
- data/{README.en → README} +0 -0
- data/Rakefile +65 -52
- data/VERSION +1 -1
- data/blinkenlights.gemspec +22 -0
- data/doc-main.txt +56 -0
- data/examples/loadbar.rb +0 -0
- data/examples/netblinker.rb +0 -0
- data/install.rb +0 -1
- data/lib/blinkenlights.rb +4 -57
- data/lib/blinkenlights/version.rb +8 -0
- data/make_doc.rb +1 -2
- data/tests/test.rb +206 -206
- metadata +53 -43
data/CHANGES
CHANGED
data/{GPL → COPYING}
RENAMED
File without changes
|
data/{README.en → README}
RENAMED
File without changes
|
data/Rakefile
CHANGED
@@ -1,11 +1,25 @@
|
|
1
|
-
|
1
|
+
begin
|
2
|
+
require 'rake/gempackagetask'
|
3
|
+
rescue LoadError
|
4
|
+
end
|
5
|
+
require 'rake/clean'
|
2
6
|
require 'rbconfig'
|
3
|
-
|
4
7
|
include Config
|
5
8
|
|
6
9
|
PKG_NAME = 'blinkenlights'
|
7
10
|
PKG_VERSION = File.read('VERSION').chomp
|
8
|
-
PKG_FILES = FileList[
|
11
|
+
PKG_FILES = FileList['**/*'].exclude(/^(doc|CVS|pkg|coverage)/)
|
12
|
+
CLEAN.include 'coverage', 'doc'
|
13
|
+
|
14
|
+
desc "Run unit tests"
|
15
|
+
task :test do
|
16
|
+
sh %{RUBYOPT="-Ilib $RUBYOPT" testrb tests/*.rb}
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "Testing library with coverage"
|
20
|
+
task :coverage do
|
21
|
+
sh 'rcov -x tests -Ilib tests/*.rb'
|
22
|
+
end
|
9
23
|
|
10
24
|
desc "Installing library"
|
11
25
|
task :install do
|
@@ -17,64 +31,63 @@ task :doc do
|
|
17
31
|
ruby 'make_doc.rb'
|
18
32
|
end
|
19
33
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
spec = Gem::Specification.new do |s|
|
32
|
-
#### Basic information.
|
34
|
+
if defined? Gem
|
35
|
+
spec_src = <<GEM
|
36
|
+
# -*- encoding: utf-8 -*-
|
37
|
+
Gem::Specification.new do |s|
|
38
|
+
s.name = '#{PKG_NAME}'
|
39
|
+
s.version = '#{PKG_VERSION}'
|
40
|
+
s.summary = 'Control the Blinkenlights on your keyboard with Ruby'
|
41
|
+
s.description =
|
42
|
+
'This library allows you to turn the keyboard LEDs on and of with Ruby.'
|
33
43
|
|
34
|
-
s.
|
35
|
-
s.version = PKG_VERSION
|
36
|
-
s.summary = "Control the Blinkenlights on your keyboard from Ruby"
|
37
|
-
s.description = ""
|
44
|
+
s.files = #{PKG_FILES.to_a.sort.inspect}
|
38
45
|
|
39
|
-
|
40
|
-
|
41
|
-
#s.add_dependency('log4r', '> 1.0.4')
|
42
|
-
#s.requirements << ""
|
43
|
-
|
44
|
-
s.files = PKG_FILES
|
45
|
-
|
46
|
-
#### C code extensions.
|
47
|
-
|
48
|
-
#s.extensions << "ext/extconf.rb"
|
49
|
-
|
50
|
-
#### Load-time details: library and application (you will need one or both).
|
51
|
-
|
52
|
-
s.require_path = 'lib' # Use these for libraries.
|
53
|
-
#s.autorequire = 'blinkenlights'
|
54
|
-
|
55
|
-
#s.bindir = "bin" # Use these for applications.
|
56
|
-
#s.executables = ["bla.rb"]
|
57
|
-
#s.default_executable = "bla.rb"
|
58
|
-
|
59
|
-
#### Documentation and testing.
|
46
|
+
s.require_path = 'lib'
|
60
47
|
|
61
48
|
s.has_rdoc = true
|
62
|
-
|
63
|
-
s.
|
49
|
+
s.rdoc_options << '--title' << 'BlinkenLights in Ruby' << '--main' << 'doc-main.txt'
|
50
|
+
s.extra_rdoc_files << 'doc-main.txt'
|
64
51
|
s.test_files << 'tests/test.rb'
|
65
52
|
|
66
|
-
#### Author and project details.
|
67
|
-
|
68
53
|
s.author = "Florian Frank"
|
69
54
|
s.email = "flori@ping.de"
|
70
|
-
s.homepage = "http
|
71
|
-
s.rubyforge_project = "
|
55
|
+
s.homepage = "http://#{PKG_NAME}.rubyforge.org"
|
56
|
+
s.rubyforge_project = "#{PKG_NAME}"
|
57
|
+
end
|
58
|
+
GEM
|
59
|
+
|
60
|
+
desc 'Create a gemspec file'
|
61
|
+
task :gemspec do
|
62
|
+
File.open("#{PKG_NAME}.gemspec", 'w') do |f|
|
63
|
+
f.puts spec_src
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
spec = eval(spec_src)
|
68
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
69
|
+
pkg.need_tar = true
|
70
|
+
pkg.package_files += PKG_FILES
|
71
|
+
end
|
72
72
|
end
|
73
73
|
|
74
|
-
|
75
|
-
|
76
|
-
|
74
|
+
desc m = "Writing version information for #{PKG_VERSION}"
|
75
|
+
task :version do
|
76
|
+
puts m
|
77
|
+
File.open(File.join('lib', PKG_NAME, 'version.rb'), 'w') do |v|
|
78
|
+
v.puts <<EOT
|
79
|
+
class BlinkenLights
|
80
|
+
# BlinkenLights version
|
81
|
+
VERSION = '#{PKG_VERSION}'
|
82
|
+
VERSION_ARRAY = VERSION.split(/\\./).map { |x| x.to_i } # :nodoc:
|
83
|
+
VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
|
84
|
+
VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
|
85
|
+
VERSION_BUILD = VERSION_ARRAY[2] # :nodoc:
|
86
|
+
end
|
87
|
+
EOT
|
88
|
+
end
|
77
89
|
end
|
78
90
|
|
79
|
-
task :
|
80
|
-
|
91
|
+
task :default => [ :version, :gemspec, :test ]
|
92
|
+
|
93
|
+
task :release => [ :clean, :version, :gemspec, :package ]
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
Gem::Specification.new do |s|
|
3
|
+
s.name = 'blinkenlights'
|
4
|
+
s.version = '0.1.0'
|
5
|
+
s.summary = 'Control the Blinkenlights on your keyboard with Ruby'
|
6
|
+
s.description =
|
7
|
+
'This library allows you to turn the keyboard LEDs on and of with Ruby.'
|
8
|
+
|
9
|
+
s.files = ["CHANGES", "COPYING", "README", "Rakefile", "VERSION", "blinkenlights.gemspec", "examples", "examples/loadbar.rb", "examples/netblinker.rb", "install.rb", "lib", "lib/blinkenlights", "lib/blinkenlights.rb", "lib/blinkenlights/version.rb", "make_doc.rb", "tests", "tests/test.rb"]
|
10
|
+
|
11
|
+
s.require_path = 'lib'
|
12
|
+
|
13
|
+
s.has_rdoc = true
|
14
|
+
s.rdoc_options << '--title' << 'BlinkenLights in Ruby' << '--main' << 'doc-main.txt'
|
15
|
+
s.extra_rdoc_files << 'doc-main.txt'
|
16
|
+
s.test_files << 'tests/test.rb'
|
17
|
+
|
18
|
+
s.author = "Florian Frank"
|
19
|
+
s.email = "flori@ping.de"
|
20
|
+
s.homepage = "http://blinkenlights.rubyforge.org"
|
21
|
+
s.rubyforge_project = "blinkenlights"
|
22
|
+
end
|
data/doc-main.txt
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
== BlinkenLights - Controlling the keyboard LEDs from Ruby
|
2
|
+
|
3
|
+
=== Author
|
4
|
+
|
5
|
+
Florian Frank mailto:flori@ping.de
|
6
|
+
|
7
|
+
=== License
|
8
|
+
|
9
|
+
This is free software; you can redistribute it and/or modify it under the
|
10
|
+
terms of the GNU General Public License Version 2 as published by the Free
|
11
|
+
Software Foundation: www.gnu.org/copyleft/gpl.html
|
12
|
+
|
13
|
+
=== Download
|
14
|
+
|
15
|
+
The latest version of <b>blinkenlights</b> can be found at
|
16
|
+
|
17
|
+
* http://rubyforge.org/frs/?group_id=1021
|
18
|
+
|
19
|
+
The homepage of this library is located at
|
20
|
+
|
21
|
+
* http://blinkenlights.rubyforge.org
|
22
|
+
|
23
|
+
=== Description
|
24
|
+
|
25
|
+
This Ruby library is named after an old joke, see
|
26
|
+
http://catb.org/~esr/jargon/html/B/blinkenlights.html
|
27
|
+
|
28
|
+
It enables you to control the LEDs on your keyboard to signal digital numbers
|
29
|
+
between 0 and 7, events like received/transmitted network packets, or just
|
30
|
+
let them blink in visually pleasing patterns.
|
31
|
+
|
32
|
+
*Beware*: If you use BlinkenLights under Windows, not only the leds are
|
33
|
+
switched on/off but also the related keys are pressed/unpressed! This could
|
34
|
+
be quite confusing. ;)
|
35
|
+
|
36
|
+
=== Examples
|
37
|
+
|
38
|
+
The block form opens the TTY, that controls the LEDs, and closes/resets
|
39
|
+
the LEDs it after the block has been processed:
|
40
|
+
require 'blinkenlights'
|
41
|
+
BlinkenLights.open do |bl|
|
42
|
+
bl.off
|
43
|
+
bl.circle
|
44
|
+
end
|
45
|
+
|
46
|
+
It's also possible to manually close the object:
|
47
|
+
require 'blinkenlights'
|
48
|
+
bl = BlinkenLights.new
|
49
|
+
bl.off
|
50
|
+
100.times { bl.random }
|
51
|
+
bl.close
|
52
|
+
|
53
|
+
There are also two short examples examples/netblinker.rb and
|
54
|
+
examples/loadbar.rb in the distribution directory of this library, that show
|
55
|
+
how to let the lights blink if network packets are received/transmitted on
|
56
|
+
your host or to indicate how high the cpu load average is.
|
data/examples/loadbar.rb
CHANGED
File without changes
|
data/examples/netblinker.rb
CHANGED
File without changes
|
data/install.rb
CHANGED
data/lib/blinkenlights.rb
CHANGED
@@ -2,69 +2,15 @@ begin
|
|
2
2
|
require 'Win32API'
|
3
3
|
rescue LoadError
|
4
4
|
end
|
5
|
+
require 'blinkenlights/version'
|
5
6
|
|
6
|
-
#
|
7
|
-
#
|
8
|
-
# == Author
|
9
|
-
#
|
10
|
-
# Florian Frank mailto:flori@ping.de
|
11
|
-
#
|
12
|
-
# == License
|
13
|
-
#
|
14
|
-
# This is free software; you can redistribute it and/or modify it under the
|
15
|
-
# terms of the GNU General Public License Version 2 as published by the Free
|
16
|
-
# Software Foundation: www.gnu.org/copyleft/gpl.html
|
17
|
-
#
|
18
|
-
# == Download
|
19
|
-
#
|
20
|
-
# The latest version of <b>blinkenlights</b> can be found at
|
21
|
-
#
|
22
|
-
# * http://rubyforge.org/frs/?group_id=1021
|
23
|
-
#
|
24
|
-
# The homepage of this library is located at
|
25
|
-
#
|
26
|
-
# * http://blinkenlights.rubyforge.org
|
27
|
-
#
|
28
|
-
# == Description
|
29
|
-
#
|
30
|
-
# This Ruby library is named after an old joke, see
|
31
|
-
# http://catb.org/~esr/jargon/html/B/blinkenlights.html
|
32
|
-
#
|
33
|
-
# It enables you to control the LEDs on your keyboard to signal digital numbers
|
34
|
-
# between 0 and 7, events like received/transmitted network packets, or just
|
35
|
-
# let them blink in visually pleasing patterns.
|
36
|
-
#
|
37
|
-
# *Beware*: If you use BlinkenLights under Windows, not only the leds are
|
38
|
-
# switched on/off but also the related keys are pressed/unpressed! This could
|
39
|
-
# be quite confusing. ;)
|
40
|
-
#
|
41
|
-
# == Examples
|
42
|
-
#
|
43
|
-
# The block form opens the TTY, that controls the LEDs, and closes/resets
|
44
|
-
# the LEDs it after the block has been processed:
|
45
|
-
# require 'blinkenlights'
|
46
|
-
# BlinkenLights.open do |bl|
|
47
|
-
# bl.off
|
48
|
-
# bl.circle
|
49
|
-
# end
|
50
|
-
#
|
51
|
-
# It's also possible to manually close the object:
|
52
|
-
# require 'blinkenlights'
|
53
|
-
# bl = BlinkenLights.new
|
54
|
-
# bl.off
|
55
|
-
# 100.times { bl.random }
|
56
|
-
# bl.close
|
57
|
-
#
|
58
|
-
# There are also two short examples examples/netblinker.rb and
|
59
|
-
# examples/loadbar.rb in the distribution directory of this library, that show
|
60
|
-
# how to let the lights blink if network packets are received/transmitted on
|
61
|
-
# your host or to indicate how high the cpu load average is.
|
7
|
+
# Class that implements the functionality of the BlinkenLights library.
|
62
8
|
class BlinkenLights
|
63
9
|
|
64
10
|
# Module to hold the BlinkenLights constants.
|
65
11
|
module Constants
|
66
12
|
# The default tty. It happens to be the one, I run X on. ;)
|
67
|
-
DEF_TTY = '/dev/
|
13
|
+
DEF_TTY = ENV['BLINKENLIGHTS_TTY'] || '/dev/tty7'
|
68
14
|
|
69
15
|
# DEF_DELAY is the default standard delay in seconds, that is slept
|
70
16
|
# everytime the LED state is changed. If it is too small your keyboard may
|
@@ -187,6 +133,7 @@ class BlinkenLights
|
|
187
133
|
self
|
188
134
|
end
|
189
135
|
|
136
|
+
# Return true if the constants tty has been closed.
|
190
137
|
def closed?
|
191
138
|
@tty.closed?
|
192
139
|
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
class BlinkenLights
|
2
|
+
# BlinkenLights version
|
3
|
+
VERSION = '0.1.0'
|
4
|
+
VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
|
5
|
+
VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
|
6
|
+
VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
|
7
|
+
VERSION_BUILD = VERSION_ARRAY[2] # :nodoc:
|
8
|
+
end
|
data/make_doc.rb
CHANGED
data/tests/test.rb
CHANGED
@@ -1,206 +1,206 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
base = File.basename(Dir.pwd)
|
4
|
-
if base == 'tests' || base =~ /file-tail/
|
5
|
-
Dir.chdir('..') if base == 'tests'
|
6
|
-
$LOAD_PATH.unshift(File.join(Dir.pwd, 'lib'))
|
7
|
-
end
|
8
|
-
|
9
|
-
require 'test/unit'
|
10
|
-
require 'blinkenlights'
|
11
|
-
|
12
|
-
class TC_BlinkenLights < Test::Unit::TestCase
|
13
|
-
def setup
|
14
|
-
@bl = BlinkenLights.new
|
15
|
-
@old_leds = get_leds
|
16
|
-
end
|
17
|
-
|
18
|
-
def get_leds
|
19
|
-
[ @bl.left, @bl.middle, @bl.right ]
|
20
|
-
end
|
21
|
-
|
22
|
-
def teardown
|
23
|
-
@bl.close unless @bl.closed?
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_close
|
27
|
-
assert !@bl.closed?
|
28
|
-
@bl.close
|
29
|
-
assert @bl.closed?
|
30
|
-
assert_raises(IOError) { @bl.flash }
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_block_open
|
34
|
-
bl2 = BlinkenLights.open do |bl|
|
35
|
-
assert !bl.closed?
|
36
|
-
assert bl.flash
|
37
|
-
:foo
|
38
|
-
end
|
39
|
-
assert_equal :foo, bl2
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_no_block_open
|
43
|
-
bl2 = BlinkenLights.open
|
44
|
-
assert_kind_of BlinkenLights, bl2
|
45
|
-
assert bl2.close
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_reset
|
49
|
-
@bl.random
|
50
|
-
@bl.reset
|
51
|
-
assert_equal get_leds, @old_leds
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_off
|
55
|
-
@bl.random
|
56
|
-
@bl.off
|
57
|
-
assert !@bl.left
|
58
|
-
assert !@bl.middle
|
59
|
-
assert !@bl.right
|
60
|
-
end
|
61
|
-
|
62
|
-
def test_on
|
63
|
-
@bl.random
|
64
|
-
@bl.on
|
65
|
-
assert @bl.left
|
66
|
-
assert @bl.middle
|
67
|
-
assert @bl.right
|
68
|
-
end
|
69
|
-
|
70
|
-
def test_on
|
71
|
-
@bl.random
|
72
|
-
@bl.flash
|
73
|
-
assert !@bl.left
|
74
|
-
assert !@bl.middle
|
75
|
-
assert !@bl.right
|
76
|
-
end
|
77
|
-
|
78
|
-
def test_digital
|
79
|
-
@bl.random
|
80
|
-
for i in 0..8
|
81
|
-
@bl.digital = i
|
82
|
-
assert_equal i % 8, @bl.digital
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
def test_left_to_right
|
87
|
-
@bl.random
|
88
|
-
@bl.left_to_right
|
89
|
-
assert !@bl.left
|
90
|
-
assert !@bl.middle
|
91
|
-
assert @bl.right
|
92
|
-
end
|
93
|
-
|
94
|
-
def test_right_to_left
|
95
|
-
@bl.random
|
96
|
-
@bl.right_to_left
|
97
|
-
assert @bl.left
|
98
|
-
assert !@bl.middle
|
99
|
-
assert !@bl.right
|
100
|
-
end
|
101
|
-
|
102
|
-
def test_circle
|
103
|
-
@bl.random
|
104
|
-
@bl.circle
|
105
|
-
assert @bl.left
|
106
|
-
assert !@bl.middle
|
107
|
-
assert !@bl.right
|
108
|
-
end
|
109
|
-
|
110
|
-
def test_reverse_circle
|
111
|
-
@bl.random
|
112
|
-
@bl.reverse_circle
|
113
|
-
assert !@bl.left
|
114
|
-
assert !@bl.middle
|
115
|
-
assert @bl.right
|
116
|
-
end
|
117
|
-
|
118
|
-
def test_converge
|
119
|
-
@bl.random
|
120
|
-
@bl.converge
|
121
|
-
assert !@bl.left
|
122
|
-
assert @bl.middle
|
123
|
-
assert !@bl.right
|
124
|
-
end
|
125
|
-
|
126
|
-
def test_diverge
|
127
|
-
@bl.random
|
128
|
-
@bl.diverge
|
129
|
-
assert @bl.left
|
130
|
-
assert !@bl.middle
|
131
|
-
assert @bl.right
|
132
|
-
end
|
133
|
-
|
134
|
-
def test_left
|
135
|
-
@bl.random
|
136
|
-
@bl.left = false
|
137
|
-
assert !@bl.left
|
138
|
-
@bl.left = true
|
139
|
-
assert @bl.left
|
140
|
-
@bl.toggle_left
|
141
|
-
assert !@bl.left
|
142
|
-
@bl.toggle_left
|
143
|
-
assert @bl.left
|
144
|
-
end
|
145
|
-
|
146
|
-
def test_middle
|
147
|
-
@bl.random
|
148
|
-
@bl.middle = false
|
149
|
-
assert !@bl.middle
|
150
|
-
@bl.middle = true
|
151
|
-
assert @bl.middle
|
152
|
-
@bl.toggle_middle
|
153
|
-
assert !@bl.middle
|
154
|
-
@bl.toggle_middle
|
155
|
-
assert @bl.middle
|
156
|
-
end
|
157
|
-
|
158
|
-
def test_right
|
159
|
-
@bl.random
|
160
|
-
@bl.right = false
|
161
|
-
assert !@bl.right
|
162
|
-
@bl.right = true
|
163
|
-
assert @bl.right
|
164
|
-
@bl.toggle_right
|
165
|
-
assert !@bl.right
|
166
|
-
@bl.toggle_right
|
167
|
-
assert @bl.right
|
168
|
-
end
|
169
|
-
|
170
|
-
def test_num
|
171
|
-
@bl.random
|
172
|
-
@bl.num = false
|
173
|
-
assert !@bl.num
|
174
|
-
@bl.num = true
|
175
|
-
assert @bl.num
|
176
|
-
@bl.toggle_num
|
177
|
-
assert !@bl.num
|
178
|
-
@bl.toggle_num
|
179
|
-
assert @bl.num
|
180
|
-
end
|
181
|
-
|
182
|
-
def test_cap
|
183
|
-
@bl.random
|
184
|
-
@bl.cap = false
|
185
|
-
assert !@bl.cap
|
186
|
-
@bl.cap = true
|
187
|
-
assert @bl.cap
|
188
|
-
@bl.toggle_cap
|
189
|
-
assert !@bl.cap
|
190
|
-
@bl.toggle_cap
|
191
|
-
assert @bl.cap
|
192
|
-
end
|
193
|
-
|
194
|
-
def test_scr
|
195
|
-
@bl.random
|
196
|
-
@bl.scr = false
|
197
|
-
assert !@bl.scr
|
198
|
-
@bl.scr = true
|
199
|
-
assert @bl.scr
|
200
|
-
@bl.toggle_scr
|
201
|
-
assert !@bl.scr
|
202
|
-
@bl.toggle_scr
|
203
|
-
assert @bl.scr
|
204
|
-
end
|
205
|
-
end
|
206
|
-
# vim: set noet sw=2 ts=2:
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
base = File.basename(Dir.pwd)
|
4
|
+
if base == 'tests' || base =~ /file-tail/
|
5
|
+
Dir.chdir('..') if base == 'tests'
|
6
|
+
$LOAD_PATH.unshift(File.join(Dir.pwd, 'lib'))
|
7
|
+
end
|
8
|
+
|
9
|
+
require 'test/unit'
|
10
|
+
require 'blinkenlights'
|
11
|
+
|
12
|
+
class TC_BlinkenLights < Test::Unit::TestCase
|
13
|
+
def setup
|
14
|
+
@bl = BlinkenLights.new
|
15
|
+
@old_leds = get_leds
|
16
|
+
end
|
17
|
+
|
18
|
+
def get_leds
|
19
|
+
[ @bl.left, @bl.middle, @bl.right ]
|
20
|
+
end
|
21
|
+
|
22
|
+
def teardown
|
23
|
+
@bl.close unless @bl.closed?
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_close
|
27
|
+
assert !@bl.closed?
|
28
|
+
@bl.close
|
29
|
+
assert @bl.closed?
|
30
|
+
assert_raises(IOError) { @bl.flash }
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_block_open
|
34
|
+
bl2 = BlinkenLights.open do |bl|
|
35
|
+
assert !bl.closed?
|
36
|
+
assert bl.flash
|
37
|
+
:foo
|
38
|
+
end
|
39
|
+
assert_equal :foo, bl2
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_no_block_open
|
43
|
+
bl2 = BlinkenLights.open
|
44
|
+
assert_kind_of BlinkenLights, bl2
|
45
|
+
assert bl2.close
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_reset
|
49
|
+
@bl.random
|
50
|
+
@bl.reset
|
51
|
+
assert_equal get_leds, @old_leds
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_off
|
55
|
+
@bl.random
|
56
|
+
@bl.off
|
57
|
+
assert !@bl.left
|
58
|
+
assert !@bl.middle
|
59
|
+
assert !@bl.right
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_on
|
63
|
+
@bl.random
|
64
|
+
@bl.on
|
65
|
+
assert @bl.left
|
66
|
+
assert @bl.middle
|
67
|
+
assert @bl.right
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_on
|
71
|
+
@bl.random
|
72
|
+
@bl.flash
|
73
|
+
assert !@bl.left
|
74
|
+
assert !@bl.middle
|
75
|
+
assert !@bl.right
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_digital
|
79
|
+
@bl.random
|
80
|
+
for i in 0..8
|
81
|
+
@bl.digital = i
|
82
|
+
assert_equal i % 8, @bl.digital
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_left_to_right
|
87
|
+
@bl.random
|
88
|
+
@bl.left_to_right
|
89
|
+
assert !@bl.left
|
90
|
+
assert !@bl.middle
|
91
|
+
assert @bl.right
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_right_to_left
|
95
|
+
@bl.random
|
96
|
+
@bl.right_to_left
|
97
|
+
assert @bl.left
|
98
|
+
assert !@bl.middle
|
99
|
+
assert !@bl.right
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_circle
|
103
|
+
@bl.random
|
104
|
+
@bl.circle
|
105
|
+
assert @bl.left
|
106
|
+
assert !@bl.middle
|
107
|
+
assert !@bl.right
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_reverse_circle
|
111
|
+
@bl.random
|
112
|
+
@bl.reverse_circle
|
113
|
+
assert !@bl.left
|
114
|
+
assert !@bl.middle
|
115
|
+
assert @bl.right
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_converge
|
119
|
+
@bl.random
|
120
|
+
@bl.converge
|
121
|
+
assert !@bl.left
|
122
|
+
assert @bl.middle
|
123
|
+
assert !@bl.right
|
124
|
+
end
|
125
|
+
|
126
|
+
def test_diverge
|
127
|
+
@bl.random
|
128
|
+
@bl.diverge
|
129
|
+
assert @bl.left
|
130
|
+
assert !@bl.middle
|
131
|
+
assert @bl.right
|
132
|
+
end
|
133
|
+
|
134
|
+
def test_left
|
135
|
+
@bl.random
|
136
|
+
@bl.left = false
|
137
|
+
assert !@bl.left
|
138
|
+
@bl.left = true
|
139
|
+
assert @bl.left
|
140
|
+
@bl.toggle_left
|
141
|
+
assert !@bl.left
|
142
|
+
@bl.toggle_left
|
143
|
+
assert @bl.left
|
144
|
+
end
|
145
|
+
|
146
|
+
def test_middle
|
147
|
+
@bl.random
|
148
|
+
@bl.middle = false
|
149
|
+
assert !@bl.middle
|
150
|
+
@bl.middle = true
|
151
|
+
assert @bl.middle
|
152
|
+
@bl.toggle_middle
|
153
|
+
assert !@bl.middle
|
154
|
+
@bl.toggle_middle
|
155
|
+
assert @bl.middle
|
156
|
+
end
|
157
|
+
|
158
|
+
def test_right
|
159
|
+
@bl.random
|
160
|
+
@bl.right = false
|
161
|
+
assert !@bl.right
|
162
|
+
@bl.right = true
|
163
|
+
assert @bl.right
|
164
|
+
@bl.toggle_right
|
165
|
+
assert !@bl.right
|
166
|
+
@bl.toggle_right
|
167
|
+
assert @bl.right
|
168
|
+
end
|
169
|
+
|
170
|
+
def test_num
|
171
|
+
@bl.random
|
172
|
+
@bl.num = false
|
173
|
+
assert !@bl.num
|
174
|
+
@bl.num = true
|
175
|
+
assert @bl.num
|
176
|
+
@bl.toggle_num
|
177
|
+
assert !@bl.num
|
178
|
+
@bl.toggle_num
|
179
|
+
assert @bl.num
|
180
|
+
end
|
181
|
+
|
182
|
+
def test_cap
|
183
|
+
@bl.random
|
184
|
+
@bl.cap = false
|
185
|
+
assert !@bl.cap
|
186
|
+
@bl.cap = true
|
187
|
+
assert @bl.cap
|
188
|
+
@bl.toggle_cap
|
189
|
+
assert !@bl.cap
|
190
|
+
@bl.toggle_cap
|
191
|
+
assert @bl.cap
|
192
|
+
end
|
193
|
+
|
194
|
+
def test_scr
|
195
|
+
@bl.random
|
196
|
+
@bl.scr = false
|
197
|
+
assert !@bl.scr
|
198
|
+
@bl.scr = true
|
199
|
+
assert @bl.scr
|
200
|
+
@bl.toggle_scr
|
201
|
+
assert !@bl.scr
|
202
|
+
@bl.toggle_scr
|
203
|
+
assert @bl.scr
|
204
|
+
end
|
205
|
+
end
|
206
|
+
# vim: set noet sw=2 ts=2:
|
metadata
CHANGED
@@ -1,61 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.8.11
|
3
|
-
specification_version: 1
|
4
2
|
name: blinkenlights
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.0
|
7
|
-
date: 2006-04-09 00:00:00 +02:00
|
8
|
-
summary: Control the Blinkenlights on your keyboard from Ruby
|
9
|
-
require_paths:
|
10
|
-
- lib
|
11
|
-
email: flori@ping.de
|
12
|
-
homepage: http://blinkenlights.rubyforge.org
|
13
|
-
rubyforge_project: blinkenlights
|
14
|
-
description: ""
|
15
|
-
autorequire:
|
16
|
-
default_executable:
|
17
|
-
bindir: bin
|
18
|
-
has_rdoc: true
|
19
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">"
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.0.0
|
24
|
-
version:
|
4
|
+
version: 0.1.0
|
25
5
|
platform: ruby
|
26
|
-
signing_key:
|
27
|
-
cert_chain:
|
28
6
|
authors:
|
29
7
|
- Florian Frank
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-07-19 00:00:00 +02:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: This library allows you to turn the keyboard LEDs on and of with Ruby.
|
17
|
+
email: flori@ping.de
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- doc-main.txt
|
30
24
|
files:
|
31
|
-
-
|
32
|
-
-
|
33
|
-
-
|
25
|
+
- CHANGES
|
26
|
+
- COPYING
|
27
|
+
- README
|
34
28
|
- Rakefile
|
35
29
|
- VERSION
|
36
|
-
-
|
37
|
-
- CHANGES
|
38
|
-
- lib
|
39
|
-
- make_doc.rb
|
40
|
-
- README.en
|
41
|
-
- examples/netblinker.rb
|
30
|
+
- blinkenlights.gemspec
|
42
31
|
- examples/loadbar.rb
|
43
|
-
-
|
32
|
+
- examples/netblinker.rb
|
33
|
+
- install.rb
|
44
34
|
- lib/blinkenlights.rb
|
45
|
-
|
35
|
+
- lib/blinkenlights/version.rb
|
36
|
+
- make_doc.rb
|
46
37
|
- tests/test.rb
|
38
|
+
- doc-main.txt
|
39
|
+
has_rdoc: true
|
40
|
+
homepage: http://blinkenlights.rubyforge.org
|
41
|
+
licenses: []
|
42
|
+
|
43
|
+
post_install_message:
|
47
44
|
rdoc_options:
|
48
45
|
- --title
|
49
46
|
- BlinkenLights in Ruby
|
50
47
|
- --main
|
51
|
-
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
48
|
+
- doc-main.txt
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: "0"
|
56
|
+
version:
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: "0"
|
62
|
+
version:
|
58
63
|
requirements: []
|
59
64
|
|
60
|
-
|
61
|
-
|
65
|
+
rubyforge_project: blinkenlights
|
66
|
+
rubygems_version: 1.3.2
|
67
|
+
signing_key:
|
68
|
+
specification_version: 3
|
69
|
+
summary: Control the Blinkenlights on your keyboard with Ruby
|
70
|
+
test_files:
|
71
|
+
- tests/test.rb
|