obsws 0.4.0 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c275787361111b1b84f2f5023d5d24e45b174540a8e687aaaae2fa647b89eecc
4
- data.tar.gz: 738122bc2be93730ef117240c467ec261ab6918c406dea273eefc134d5f74362
3
+ metadata.gz: 9ccc4e19da8ea0f009572ea75a5f47b414c7d4e5d50955ae856eb4063081ca70
4
+ data.tar.gz: 2a5ec2b70667d2b80483a46c898920ed9a97d937478e45ff5f643b8e28919a18
5
5
  SHA512:
6
- metadata.gz: 121d5bf831969d5bd92244efb4c6ae94fdea7e6a47b16c9b7bbee80626e6739664433bb04e3225aef2eaa759127ee074841e05b430331c3bd987762c8623f15c
7
- data.tar.gz: e67e598037d689469263721e2408eacebd6469e32a5b55e50f43876efe33d5b3b581e99ec2d804ed28549079f6b4855c76e8508e65e46d504bca12e75e32fff9
6
+ metadata.gz: '0875434a8e3c58d82fbc0deb3be4478ab495000b37ee6282d321e32963d623dcc241c62a0257ef009ab6981ef134138e6e72ab76a1f552d46a3b928f1acc21d4'
7
+ data.tar.gz: 3b944c1a4ac416f12a0f5d821d73979ac4f344fa2ae186f04a0d00998bc5adf9fcf744e874d4b52f273232aec174a2da134a94f5bcd24d522d25e2b778c7bd9f
data/lib/obsws/base.rb CHANGED
@@ -21,8 +21,7 @@ module OBSWS
21
21
  port = kwargs[:port] || 4455
22
22
  @password = kwargs[:password] || ""
23
23
  @subs = kwargs[:subs] || 0
24
- setup_driver(host, port)
25
- start_driver
24
+ setup_driver(host, port) and start_driver
26
25
  WaitUtil.wait_for_condition(
27
26
  "successful identification",
28
27
  delay_sec: 0.01,
data/lib/obsws/event.rb CHANGED
@@ -42,15 +42,16 @@ module OBSWS
42
42
  end
43
43
 
44
44
  def add_observer(observer)
45
- observer = [observer] if !observer.respond_to? :each
45
+ observer = [observer] unless observer.respond_to? :each
46
46
  observer.each { |o| observers << o unless observers.include? o }
47
47
  end
48
48
 
49
49
  def remove_observer(observer)
50
- observers.delete(observer)
50
+ observer = [observer] unless observer.respond_to? :each
51
+ observers.reject! { |o| observer.include? o }
51
52
  end
52
53
 
53
- def notify_observers(event, data)
54
+ private def notify_observers(event, data)
54
55
  observers.each do |o|
55
56
  if o.is_a? Method
56
57
  if o.name.to_s == "on_#{snakecase(event)}"
@@ -62,6 +63,7 @@ module OBSWS
62
63
  end
63
64
  end
64
65
 
66
+ alias_method :callbacks, :observers
65
67
  alias_method :register, :add_observer
66
68
  alias_method :deregister, :remove_observer
67
69
  end
data/lib/obsws/logger.rb CHANGED
@@ -3,7 +3,7 @@ require "logger"
3
3
  module OBSWS
4
4
  module Logging
5
5
  def logger
6
- @logger = Logger.new($stdout, level: ENV.fetch("OBSWS_LOG_LEVEL", "WARN"))
6
+ @logger ||= Logger.new($stdout, level: ENV.fetch("OBSWS_LOG_LEVEL", "WARN"))
7
7
  @logger.progname = instance_of?(::Module) ? name : self.class.name
8
8
  @logger
9
9
  end
data/lib/obsws/mixin.rb CHANGED
@@ -26,11 +26,11 @@ module OBSWS
26
26
  def attrs = @fields.map { |f| snakecase(f.to_s) }
27
27
  end
28
28
 
29
- class Response < MetaObject
30
- end
29
+ class Response < MetaObject; end
30
+ # Represents a request response object
31
31
 
32
- class Data < MetaObject
33
- end
32
+ class Data < MetaObject; end
33
+ # Represents an event data object
34
34
 
35
35
  module TearDown
36
36
  def stop_driver
data/lib/obsws/req.rb CHANGED
@@ -47,12 +47,12 @@ module OBSWS
47
47
  delay_sec: 0.001,
48
48
  timeout_sec: 3
49
49
  ) { @response[:requestId] == id }
50
- if !@response[:requestStatus][:result]
50
+ unless @response[:requestStatus][:result]
51
51
  error = [
52
52
  "Request #{@response[:requestType]} returned code #{@response[:requestStatus][:code]}"
53
53
  ]
54
54
  if @response[:requestStatus].key?(:comment)
55
- error += ["With message: #{@response[:requestStatus][:comment]}"]
55
+ error << ["With message: #{@response[:requestStatus][:comment]}"]
56
56
  end
57
57
  raise OBSWSError.new(error.join("\n"))
58
58
  end
data/lib/obsws/version.rb CHANGED
@@ -11,7 +11,7 @@ module OBSWS
11
11
  end
12
12
 
13
13
  def patch
14
- 0
14
+ 2
15
15
  end
16
16
 
17
17
  def to_a
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: obsws
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - onyx_online
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-27 00:00:00.000000000 Z
11
+ date: 2023-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: websocket-driver