lib/wss_agent/configure.rb in wss_agent-0.0.15 vs lib/wss_agent/configure.rb in wss_agent-0.0.16
- old
+ new
@@ -30,22 +30,31 @@
def current_path
Bundler.root.join(CURRENT_CONFIG_FILE).to_s
end
def current
- if defined?(Bundler) && File.exist?(current_path)
- default.merge(YAML.load(File.read(current_path)))
- else
- default
+ unless File.exist?(current_path)
+ 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"
+ end
+
+ default.merge(@current_config)
end
def uri
@url = current['url']
if @url.nil? || @url == ''
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"
end
def port
uri.port || 80
end