lib/wss_agent/configure.rb in wss_agent-0.0.17 vs lib/wss_agent/configure.rb in wss_agent-0.0.21
- old
+ new
@@ -1,18 +1,16 @@
module WssAgent
class Configure
+ DEFAULT_CONFIG_FILE = 'default.yml'.freeze
+ CUSTOM_DEFAULT_CONFIG_FILE = 'custom_default.yml'.freeze
+ CURRENT_CONFIG_FILE = 'wss_agent.yml'.freeze
+ API_PATH = '/agent'.freeze
- DEFAULT_CONFIG_FILE = 'default.yml'
- CUSTOM_DEFAULT_CONFIG_FILE = 'custom_default.yml'
- CURRENT_CONFIG_FILE = 'wss_agent.yml'
- API_PATH = '/agent'
-
extend SingleForwardable
def_delegator :current, :[]
class << self
-
def default_path
File.join(File.expand_path('../..', __FILE__), 'config', DEFAULT_CONFIG_FILE)
end
def custom_default_path
@@ -36,12 +34,12 @@
return raise NotFoundConfigFile, "Config file isn't exist. Could you please run 'wss_agent config' before."
end
@current_config = YAML.load(File.read(current_path))
- unless !!@current_config
- return raise InvalidConfigFile, "Problem reading wss_agent.yml, please check the file is a valid YAML"
+ unless !!@current_config
+ return raise InvalidConfigFile, 'Problem reading wss_agent.yml, please check the file is a valid YAML'
end
default.merge(@current_config)
end
@@ -51,11 +49,11 @@
raise ApiUrlNotFound, "Can't find the url, please add your Whitesource url destination in the wss_agent.yml file."
end
URI(@url)
rescue URI::Error
- raise ApiUrlInvalid, "Api url is invalid. Could you please check url in wss_agent.yml"
+ raise ApiUrlInvalid, 'Api url is invalid. Could you please check url in wss_agent.yml'
end
def port
uri.port || 80
end
@@ -63,13 +61,17 @@
def url
@uri = uri
[@uri.scheme, @uri.host].join('://')
end
+ def ssl?
+ uri.scheme == 'https'
+ end
+
def api_path
@uri = uri
@url_path = @uri.path
- @url_path == "" ? API_PATH : @url_path
+ @url_path == '' ? API_PATH : @url_path
end
def token
if current['token'].nil? || (current['token'] == '') || (current['token'] == default['token'])
raise TokenNotFound, "Can't find Token, please add your Whitesource API token in the wss_agent.yml file"