Class: SysLibDetector::Cli

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

Overview

The command-line interface class, responsible for the commands of running the gem’s funcionalities, using Thor’s gem

Instance Method Summary collapse

Instance Method Details

#install_sys_libsObject

Installing the required system libraries for the project’s local gems via sending the retrieval request to the web-service, and then installing the system libraries included in the response



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/sys_lib_detector/cli.rb', line 47

def install_sys_libs
  gems = get_gems
  os = get_os_name

  begin
    web_service_handler = get_web_service_handler

    response = web_service_handler.retrieve_sys_libraries(gems, os)
    response = clean_response(response)

    libraries = get_libraries(response)

    Displayer::display_header(response, gems)

    # if count == 0 message is already handled in the diplay header
    if(libraries.count > 0)
      installer = SysLibDetector::Installer.new
      installer.install(libraries)
    end

  rescue Exception::NoInternetConnection
    abort "Please check your internet connectivity"
  rescue => e
    abort e.message
  end
end

#list_all_gemsObject

Listing the local gems existing in the porject



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

def list_all_gems
  gems = get_gems
  if gems.empty?
    puts "You don't have any gems installed"
  else
    puts gems
  end
end

#list_sys_libsObject

Retrieving the required system libraries for the project’s local gems via sending the retrieval request to the web-service, and then displaying it in a friendly way using the Displayer class



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/sys_lib_detector/cli.rb', line 24

def list_sys_libs
  gems = get_gems
  os = get_os_name

  begin
    web_service_handler = get_web_service_handler

    response = web_service_handler.retrieve_sys_libraries(gems, os)
    response = clean_response(response)

    Displayer::diplay_list_sys_libs(response, gems)

  rescue Exception::NoInternetConnection
    abort "Please check your internet connectivity"
  rescue => e
    abort e.message
  end
end