lib/roku_builder/util.rb in roku_builder-3.13.0 vs lib/roku_builder/util.rb in roku_builder-4.0.0
- old
+ new
@@ -1,36 +1,27 @@
# ********** Copyright Viacom, Inc. Apache 2.0 **********
-
module RokuBuilder
- # Super class for device utilities
+ # Super class for modules
# This class defines a common initializer and allows subclasses
# to define their own secondary initializer
class Util
# Common initializer of device utils
- # @param ip [String] IP address of roku device
- # @param user [String] Username for roku device
- # @param password [String] Password for roku device
- def initialize(ip:, user:, password:, init_params: nil)
+ # @param config [Config] Configuration object for the app
+ def initialize(config: )
@logger = Logger.instance
- @device_config = {
- ip: ip,
- user: user,
- password: password
- }
- @roku_ip_address = ip
- @dev_username = user
- @dev_password = password
+ @config = config
+ @roku_ip_address = @config.device_config[:ip]
+ @dev_username = @config.device_config[:user]
+ @dev_password = @config.device_config[:password]
@url = "http://#{@roku_ip_address}"
- if init_params
- init(**init_params)
- else
- init
- end
+ init
end
+ private
+
# Second initializer to be overwriten
def init
#Override in subclass
end
@@ -54,23 +45,8 @@
f.request :digest, @dev_username, @dev_password
f.request :multipart
f.request :url_encoded
f.adapter Faraday.default_adapter
end
- end
-
- # Parses a string into and options hash
- # @param options [String] string of options in the format "a:b, c:d"
- # @return [Hash] Options hash generated
- def self.options_parse(options:)
- parsed = {}
- opts = options.split(/,\s*/)
- opts.each do |opt|
- opt = opt.split(":")
- key = opt.shift.to_sym
- value = opt.join(":")
- parsed[key] = value
- end
- parsed
end
end
end