class Rsyslibs::Dependencies

Public Class Methods

install_syslibs() click to toggle source
# File lib/rsyslibs.rb, line 38
def install_syslibs
  syslibs = JSON.parse(system_dependencies)
  return 'No libraries found.' if syslibs.empty?

  os_name = Rsyslibs::OperatingSystemInfo.os_name
  case os_name
  when 'MacOS' then syslibs.each { |lib| `brew install #{lib['name']}` }
  when 'Linux' then syslibs.each { |lib| `apt-get install #{lib['name']}` }
  else "I don't know how to install these libraries on this operating system :("
  end
end
print_friendly_syslibs() click to toggle source
project_dependencies() click to toggle source
# File lib/rsyslibs.rb, line 18
def project_dependencies
  Bundler.definition.dependencies.map(&:name)
end
system_dependencies() click to toggle source
# File lib/rsyslibs.rb, line 10
def system_dependencies
  payload = {
    project_dependencies: project_dependencies,
    os_info: os_info
  }.to_json
  parse_response(api(:post, '/lookup_syslibs', payload))
end

Private Class Methods

api(method, path, payload, headers = { content_type: :json, accpet: :json }) click to toggle source
# File lib/rsyslibs.rb, line 64
def api(method, path, payload, headers = { content_type: :json, accpet: :json })
  Rsyslibs::Request.api(method, path, payload, headers)
end
os_info() click to toggle source
# File lib/rsyslibs.rb, line 60
def os_info
  Rsyslibs::OperatingSystemInfo.os_info
end
parse_response(response) click to toggle source
# File lib/rsyslibs.rb, line 52
def parse_response(response)
  if response.code == 200
    response.body
  else
    'Failed to fetch system libraries from remote server. Please try again.'
  end
end