Class: Server

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/syslibgem/server.rb

Overview

This class handel the server requests

Class Method Summary collapse

Class Method Details

.create(gem, deps) ⇒ Object

$URI = ‘localhost:3000



12
13
14
15
16
17
18
19
20
# File 'lib/syslibgem/server.rb', line 12

def self.create(gem, deps)
  json = { gem_name: gem, os_name: find_os, deps: deps }
  HTTParty.post(
    $URI + '/api/v1/deps',
    body: json.to_json,
    headers:  { 'Content-Type' => 'application/json',
                'Accept' => 'application/json' }
  )
end

.find_osObject



27
28
29
30
31
32
33
34
35
# File 'lib/syslibgem/server.rb', line 27

def self.find_os
  if OS.mac?
    'mac'
  elsif OS.linux?
    'lunix'
  else
    'unknown'
  end
end

.load(gems) ⇒ Object



22
23
24
25
# File 'lib/syslibgem/server.rb', line 22

def self.load(gems)
  json = { gems: gems, os_name: find_os }
  HTTParty.get($URI + '/api/v1/deps', query: json)
end