class BlueprintAgreement::DrakovService

Attributes

pid[RW]

Public Class Methods

new(config = BlueprintAgreement.configuration) click to toggle source
# File lib/blueprint_agreement/api_services/drakov_service.rb, line 5
def initialize(config = BlueprintAgreement.configuration)
  @config = config
  @port = @config.port
  @allow_headers = @config.allow_headers
  @hostname = @config.hostname
  @root_path = @config.server_path
end

Public Instance Methods

host() click to toggle source
# File lib/blueprint_agreement/api_services/drakov_service.rb, line 23
def host
  "#{hostname}:#{port}"
end
install() click to toggle source
# File lib/blueprint_agreement/api_services/drakov_service.rb, line 31
def install
  print "installing drakov.."
  pid = Process.spawn "npm install -g drakov"
  Process.wait pid
  print "Drakov installed 🍺  "
end
installed?() click to toggle source
# File lib/blueprint_agreement/api_services/drakov_service.rb, line 27
def installed?
  `which drakov`.length > 0
end
start(path) click to toggle source
# File lib/blueprint_agreement/api_services/drakov_service.rb, line 13
def start(path)
  @pid = spawn "drakov -f #{root_path}/#{path} -p #{port} #{allow_headers}".strip, options
  @config.active_service = { pid: @pid, path: path }
end
stop() click to toggle source
# File lib/blueprint_agreement/api_services/drakov_service.rb, line 18
def stop
  Process.kill 'TERM', @config.active_service[:pid]
  @config.active_service = nil
end

Private Instance Methods

options() click to toggle source
# File lib/blueprint_agreement/api_services/drakov_service.rb, line 39
def options
  return {} if ENV["AGREEMENT_LOUD"]

  { out: '/dev/null' }
end