pads 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pads/pad.rb +22 -4
- data/lib/pads/pad_group.rb +2 -0
- data/lib/pads/pad_view.rb +20 -0
- data/lib/pads/provider.rb +2 -0
- data/lib/pads/version.rb +1 -1
- data/lib/pads.rb +10 -2
- metadata +3 -4
- data/Gemfile.lock +0 -66
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 942bd276399a7af1bf8ecb7a833f8bc9cb936051eaf0e3c656a026921dd8b1fe
|
4
|
+
data.tar.gz: 9e50d4235e2f9e419a124d9826f599b41090f1a48b8aeb00824cb2cb7e4ffb59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 329b4c43fac33e81d1fdbc35932212e7c68e37e58d426de0b54460b578bbc0bfa5b37bef99ac39881bd29d72f9b8cab6a5b1a78b2b9024776c440aa515b78678
|
7
|
+
data.tar.gz: 9a246144993e02bfc6bb3155603ae28b4cc1156fc5f16509db2e4ac22acb807612644432e364f0d70bcb78ef7bd887bcfd8e49dbb0dd8acc88939141026d81ca
|
data/lib/pads/pad.rb
CHANGED
@@ -31,10 +31,15 @@ module Pads
|
|
31
31
|
new_view
|
32
32
|
end
|
33
33
|
|
34
|
-
def pop_view
|
35
|
-
|
34
|
+
def pop_view(view = self.view)
|
35
|
+
index = @view_stack.index(view)
|
36
36
|
|
37
|
-
|
37
|
+
raise ArgumentError, 'The given view is not part of the stack' if index.nil?
|
38
|
+
raise ArgumentError, 'You cannot pop the top level view' if view == @view_stack.last
|
39
|
+
|
40
|
+
indexes = 0..index
|
41
|
+
@view_stack[indexes].each &:cancel_beats
|
42
|
+
change_view { @view_stack.slice! indexes }
|
38
43
|
end
|
39
44
|
|
40
45
|
def with_view(new_view = PadView.new)
|
@@ -42,7 +47,7 @@ module Pads
|
|
42
47
|
push_view new_view
|
43
48
|
yield new_view
|
44
49
|
ensure
|
45
|
-
pop_view
|
50
|
+
pop_view new_view
|
46
51
|
end
|
47
52
|
|
48
53
|
def bind_events(source_dispatcher)
|
@@ -63,6 +68,19 @@ module Pads
|
|
63
68
|
|
64
69
|
private
|
65
70
|
|
71
|
+
def method_missing(symbol, *args, &block)
|
72
|
+
view = self.view
|
73
|
+
if view.respond_to? symbol
|
74
|
+
view.__send__ symbol, *args, &block
|
75
|
+
else
|
76
|
+
super
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def respond_to_missing?(symbol, *)
|
81
|
+
view.respond_to?(symbol) or super
|
82
|
+
end
|
83
|
+
|
66
84
|
def change_view
|
67
85
|
view&.delete_observer self
|
68
86
|
yield
|
data/lib/pads/pad_group.rb
CHANGED
data/lib/pads/pad_view.rb
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
require 'pads/observable_pad_state'
|
4
4
|
|
5
|
+
require 'set'
|
6
|
+
|
5
7
|
module Pads
|
6
8
|
# Represents a stackable view of a pad
|
7
9
|
class PadView < ObservablePadState
|
@@ -16,6 +18,7 @@ module Pads
|
|
16
18
|
|
17
19
|
@events = Events::Dispatcher.new
|
18
20
|
@button_handlers = []
|
21
|
+
@beats = Set.new.compare_by_identity
|
19
22
|
|
20
23
|
@events.on :button_clicked do |event|
|
21
24
|
@button_handlers[event.index]&.call
|
@@ -40,5 +43,22 @@ module Pads
|
|
40
43
|
@button_handlers << handler
|
41
44
|
self.buttons += [label]
|
42
45
|
end
|
46
|
+
|
47
|
+
def beat(delay, delay_first: false)
|
48
|
+
Thread.new do
|
49
|
+
thread = Thread.current
|
50
|
+
@beats << thread
|
51
|
+
while @beats.include? thread
|
52
|
+
yield self unless delay_first
|
53
|
+
delay_first = false
|
54
|
+
sleep delay
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def cancel_beats
|
60
|
+
@beats.clear
|
61
|
+
self
|
62
|
+
end
|
43
63
|
end
|
44
64
|
end
|
data/lib/pads/provider.rb
CHANGED
data/lib/pads/version.rb
CHANGED
data/lib/pads.rb
CHANGED
@@ -7,9 +7,17 @@ require 'pads/live_array'
|
|
7
7
|
|
8
8
|
# Provide pads to the Pads macOS app.
|
9
9
|
module Pads
|
10
|
-
def self.
|
10
|
+
def self.run(*args, &block)
|
11
|
+
loop do
|
12
|
+
run! *args, &block
|
13
|
+
rescue Errno::ECONNREFUSED
|
14
|
+
sleep 1
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.run!(*args)
|
11
19
|
provider = Provider.new(*args)
|
12
|
-
yield provider
|
20
|
+
Thread.new { yield provider }
|
13
21
|
provider.wait
|
14
22
|
end
|
15
23
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pads
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Neil E. Pearson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: interop
|
@@ -36,7 +36,6 @@ files:
|
|
36
36
|
- ".ruby-version"
|
37
37
|
- CODE_OF_CONDUCT.md
|
38
38
|
- Gemfile
|
39
|
-
- Gemfile.lock
|
40
39
|
- LICENSE.txt
|
41
40
|
- README.md
|
42
41
|
- Rakefile
|
@@ -87,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
86
|
- !ruby/object:Gem::Version
|
88
87
|
version: '0'
|
89
88
|
requirements: []
|
90
|
-
rubygems_version: 3.
|
89
|
+
rubygems_version: 3.0.9
|
91
90
|
signing_key:
|
92
91
|
specification_version: 4
|
93
92
|
summary: Ruby client for the Pads macOS app
|
data/Gemfile.lock
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
pads (1.0.0)
|
5
|
-
interop (~> 0.3.1)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
ast (2.4.2)
|
11
|
-
diff-lcs (1.5.0)
|
12
|
-
interop (0.3.1)
|
13
|
-
parallel (1.21.0)
|
14
|
-
parser (3.1.1.0)
|
15
|
-
ast (~> 2.4.1)
|
16
|
-
rainbow (3.1.1)
|
17
|
-
rake (13.0.6)
|
18
|
-
regexp_parser (2.2.1)
|
19
|
-
rexml (3.2.5)
|
20
|
-
rspec (3.11.0)
|
21
|
-
rspec-core (~> 3.11.0)
|
22
|
-
rspec-expectations (~> 3.11.0)
|
23
|
-
rspec-mocks (~> 3.11.0)
|
24
|
-
rspec-core (3.11.0)
|
25
|
-
rspec-support (~> 3.11.0)
|
26
|
-
rspec-expectations (3.11.0)
|
27
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
28
|
-
rspec-support (~> 3.11.0)
|
29
|
-
rspec-mocks (3.11.0)
|
30
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
31
|
-
rspec-support (~> 3.11.0)
|
32
|
-
rspec-support (3.11.0)
|
33
|
-
rubocop (1.25.1)
|
34
|
-
parallel (~> 1.10)
|
35
|
-
parser (>= 3.1.0.0)
|
36
|
-
rainbow (>= 2.2.2, < 4.0)
|
37
|
-
regexp_parser (>= 1.8, < 3.0)
|
38
|
-
rexml
|
39
|
-
rubocop-ast (>= 1.15.1, < 2.0)
|
40
|
-
ruby-progressbar (~> 1.7)
|
41
|
-
unicode-display_width (>= 1.4.0, < 3.0)
|
42
|
-
rubocop-ast (1.16.0)
|
43
|
-
parser (>= 3.1.1.0)
|
44
|
-
rubocop-rake (0.6.0)
|
45
|
-
rubocop (~> 1.0)
|
46
|
-
rubocop-rspec (2.9.0)
|
47
|
-
rubocop (~> 1.19)
|
48
|
-
ruby-progressbar (1.11.0)
|
49
|
-
unicode-display_width (2.1.0)
|
50
|
-
|
51
|
-
PLATFORMS
|
52
|
-
x86_64-darwin-19
|
53
|
-
x86_64-darwin-20
|
54
|
-
x86_64-darwin-21
|
55
|
-
x86_64-linux
|
56
|
-
|
57
|
-
DEPENDENCIES
|
58
|
-
pads!
|
59
|
-
rake (~> 13.0)
|
60
|
-
rspec (~> 3.0)
|
61
|
-
rubocop (~> 1.21)
|
62
|
-
rubocop-rake
|
63
|
-
rubocop-rspec
|
64
|
-
|
65
|
-
BUNDLED WITH
|
66
|
-
2.3.5
|