obsws 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/obsws/event.rb +4 -4
- data/lib/obsws/mixin.rb +4 -3
- data/lib/obsws/util.rb +10 -9
- data/lib/obsws/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 112d9ab40ebc9219946426e476beaf6c489803049382d16feca972e7e14428d1
|
4
|
+
data.tar.gz: 561994b90c57837f4f5a496b22ba017fcb0fd4e4dfd946b7e62cdb91441f7253
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da20d79e6e27d739ad0df64505e5ca0ed5e770505589f9fe89f05f8b326fec6df3a7aaaf290cf2d841cd5145475f219feadeb79c8e0f633f76f66b2336361777
|
7
|
+
data.tar.gz: '09d3781a1e45dd3631a5e0b300fb998cd03798e53bc51e1888850603ab55e1d8f6d3850315452e20178eebe60e11fb0f7d4a2a250cd0cc6eff4709d22eed623e'
|
data/lib/obsws/event.rb
CHANGED
@@ -28,8 +28,8 @@ module OBSWS
|
|
28
28
|
ALL = LOW_VOLUME | HIGH_VOLUME
|
29
29
|
end
|
30
30
|
|
31
|
-
module
|
32
|
-
|
31
|
+
module Director
|
32
|
+
using Util::CoreExtensions
|
33
33
|
|
34
34
|
def observers
|
35
35
|
@observers ||= {}
|
@@ -50,13 +50,13 @@ module OBSWS
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def fire(event, data)
|
53
|
-
observers[
|
53
|
+
observers[event.snakecase.to_sym]&.each { |block| data.empty? ? block.call : block.call(data) }
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
57
|
class Client
|
58
58
|
include Logging
|
59
|
-
include
|
59
|
+
include Events::Director
|
60
60
|
include Mixin::TearDown
|
61
61
|
include Mixin::OPCodes
|
62
62
|
|
data/lib/obsws/mixin.rb
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
module OBSWS
|
2
2
|
module Mixin
|
3
3
|
module Meta
|
4
|
-
|
4
|
+
using Util::CoreExtensions
|
5
5
|
|
6
6
|
def make_field_methods(*params)
|
7
7
|
params.each do |param|
|
8
|
-
define_singleton_method(
|
8
|
+
define_singleton_method(param.to_s.snakecase) { @resp[param] }
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
class MetaObject
|
14
|
+
using Util::CoreExtensions
|
14
15
|
include Mixin::Meta
|
15
16
|
|
16
17
|
def initialize(resp, fields)
|
@@ -21,7 +22,7 @@ module OBSWS
|
|
21
22
|
|
22
23
|
def empty? = @fields.empty?
|
23
24
|
|
24
|
-
def attrs = @fields.map { |f|
|
25
|
+
def attrs = @fields.map { |f| f.to_s.snakecase }
|
25
26
|
end
|
26
27
|
|
27
28
|
# Represents a request response object
|
data/lib/obsws/util.rb
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
module OBSWS
|
2
2
|
module Util
|
3
|
-
module
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
module CoreExtensions
|
4
|
+
refine String do
|
5
|
+
def camelcase
|
6
|
+
split("_").map(&:capitalize).join
|
7
|
+
end
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
def snakecase
|
10
|
+
gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
11
|
+
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
|
12
|
+
.downcase
|
13
|
+
end
|
13
14
|
end
|
14
15
|
end
|
15
16
|
end
|
data/lib/obsws/version.rb
CHANGED