unimidi 0.2.5-i386-mingw32 → 0.3.0-i386-mingw32
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/lib/unimidi.rb +5 -3
- data/lib/unimidi/congruous_api_adapter.rb +26 -2
- data/test/helper.rb +2 -14
- metadata +4 -4
data/lib/unimidi.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
module UniMIDI
|
8
8
|
|
9
|
-
VERSION = "0.
|
9
|
+
VERSION = "0.3.0"
|
10
10
|
|
11
11
|
end
|
12
12
|
|
@@ -22,8 +22,10 @@ module UniMIDI
|
|
22
22
|
|
23
23
|
def self.command(command, options = {})
|
24
24
|
if [:l, :list, :list_devices].include?(command)
|
25
|
-
|
26
|
-
|
25
|
+
puts "input:"
|
26
|
+
Input.list
|
27
|
+
puts "output:"
|
28
|
+
Output.list
|
27
29
|
else
|
28
30
|
raise "Command #{command.to_s} not found"
|
29
31
|
end
|
@@ -33,7 +33,7 @@ module UniMIDI
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def pretty_name
|
36
|
-
"#{id}
|
36
|
+
"#{id}) #{name}"
|
37
37
|
end
|
38
38
|
|
39
39
|
# close the device
|
@@ -50,6 +50,29 @@ module UniMIDI
|
|
50
50
|
|
51
51
|
module ClassMethods
|
52
52
|
|
53
|
+
def list
|
54
|
+
all.each { |device| puts(device.pretty_name) }
|
55
|
+
end
|
56
|
+
|
57
|
+
# streamlined console prompt that asks the user to select a device
|
58
|
+
def gets
|
59
|
+
device = nil
|
60
|
+
class_name = self.name.split("::").last.downcase
|
61
|
+
grammer = %w{o i}.include?(class_name[0]) ? "n" : ""
|
62
|
+
puts ""
|
63
|
+
puts "Select a#{grammer} #{class_name}..."
|
64
|
+
while device.nil?
|
65
|
+
list
|
66
|
+
print "> "
|
67
|
+
selection = $stdin.gets.chomp
|
68
|
+
if selection != ""
|
69
|
+
selection = Integer(selection) rescue nil
|
70
|
+
device = all.find { |d| d.id == selection }
|
71
|
+
end
|
72
|
+
end
|
73
|
+
device
|
74
|
+
end
|
75
|
+
|
53
76
|
# returns the first device for this class
|
54
77
|
def first(&block)
|
55
78
|
use_device(all.first, &block)
|
@@ -65,7 +88,7 @@ module UniMIDI
|
|
65
88
|
all_by_type.values.flatten
|
66
89
|
end
|
67
90
|
|
68
|
-
# returns the device at <em>index</em>
|
91
|
+
# returns the device at <em>index</em> and opens it
|
69
92
|
def use(index, &block)
|
70
93
|
index = case index
|
71
94
|
when :first then 0
|
@@ -76,6 +99,7 @@ module UniMIDI
|
|
76
99
|
end
|
77
100
|
alias_method :open, :use
|
78
101
|
|
102
|
+
# returns the device at <em>index</em>
|
79
103
|
def [](index)
|
80
104
|
all[index]
|
81
105
|
end
|
data/test/helper.rb
CHANGED
@@ -12,20 +12,8 @@ module TestHelper
|
|
12
12
|
|
13
13
|
def self.select_devices
|
14
14
|
$test_device ||= {}
|
15
|
-
{ :input => UniMIDI::Input
|
16
|
-
|
17
|
-
puts "select an #{type.to_s}..."
|
18
|
-
while $test_device[type].nil?
|
19
|
-
devs.each do |device|
|
20
|
-
puts device.pretty_name
|
21
|
-
end
|
22
|
-
selection = $stdin.gets.chomp
|
23
|
-
if selection != ""
|
24
|
-
selection = selection.to_i
|
25
|
-
$test_device[type] = devs.find { |d| d.id == selection }
|
26
|
-
puts "selected #{selection} for #{type.to_s}" unless $test_device[type]
|
27
|
-
end
|
28
|
-
end
|
15
|
+
{ :input => UniMIDI::Input, :output => UniMIDI::Output }.each do |type, klass|
|
16
|
+
$test_device[type] = klass.gets
|
29
17
|
end
|
30
18
|
end
|
31
19
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unimidi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: i386-mingw32
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-10-04 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: midi-winmm
|
16
|
-
requirement: &
|
16
|
+
requirement: &70340932574420 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70340932574420
|
25
25
|
description: Platform Independent, realtime MIDI input and output for Ruby
|
26
26
|
email:
|
27
27
|
- ari.russo@gmail.com
|