Class: SysLibDetector::WebServiceCommunicator

Inherits:
Object
  • Object
show all
Defined in:
lib/sys_lib_detector/web_service_communicator.rb

Overview

Handler for the communication with the web-service for retrieving the required system libraries

Constant Summary collapse

SERVICE_URL =

Url for the web-service libraries retrieval endpoint

"https://sys-libraries.herokuapp.com/libraries"

Instance Method Summary collapse

Constructor Details

#initializeWebServiceCommunicator

Initializing the handler object, with a check for internet connectivity



12
13
14
15
16
17
# File 'lib/sys_lib_detector/web_service_communicator.rb', line 12

def initialize
	# checking internet connectivity
	raise Exception::NoInternetConnection if ping != :pong

	@url = SERVICE_URL
end

Instance Method Details

#retrieve_sys_libraries(gems_names, os_name) ⇒ Json

Retrieving the required system libraries by sending a get request to the web-service with the gems’ names and running operating system

Parameters:

  • gems_names (Array)

    The current project’s gems’ names

  • os_name (String)

    The operating system’s name as a symbol (:linux, :osx, :windows)

Returns:

  • (Json)

    The web-services’s response, in format { gem_1: [a,b,c], gem_2: [x,y,z] }



25
26
27
28
29
30
31
# File 'lib/sys_lib_detector/web_service_communicator.rb', line 25

def retrieve_sys_libraries(gems_names, os_name)
	params = {
		gems: gems_names,
		os: os_name
	}
	response = JSON.parse(RestClient.get(@url, {params: params}))
end