Class: Docscribe::Server::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/docscribe/server.rb

Overview

Client for communicating with a running Docscribe daemon.

Instance Method Summary collapse

Constructor Details

#initialize(socket_path = nil, config_path: nil) ⇒ void

Parameters:

  • socket_path (String?) (defaults to: nil)

    custom socket path (defaults to server default)

  • config_path (String?) (defaults to: nil)

    optional config path for socket lookup



259
260
261
# File 'lib/docscribe/server.rb', line 259

def initialize(socket_path = nil, config_path: nil)
  @socket_path = socket_path || Server.socket_path(config_path)
end

Instance Method Details

#check(file:, strategy: :safe, **rest) ⇒ Hash<String, Object>?

Send a check request to the server.

Parameters:

  • file (String)

    path to file to check

  • strategy (Symbol) (defaults to: :safe)

    rewrite strategy (:safe, :aggressive)

  • rest (Object)

Returns:

  • (Hash<String, Object>?)

    response hash or nil if server unreachable



269
270
271
# File 'lib/docscribe/server.rb', line 269

def check(file:, strategy: :safe, **rest)
  request('check', file: file, strategy: strategy, **rest)
end

#fix(file:, strategy: :safe, **rest) ⇒ Hash<String, Object>?

Send a fix request to the server.

Parameters:

  • file (String)

    path to file to fix

  • strategy (Symbol) (defaults to: :safe)

    rewrite strategy (:safe, :aggressive)

  • rest (Object)

Returns:

  • (Hash<String, Object>?)

    response hash or nil if server unreachable



279
280
281
# File 'lib/docscribe/server.rb', line 279

def fix(file:, strategy: :safe, **rest)
  request('fix', file: file, strategy: strategy, **rest)
end

#pingHash<String, Object>?

Ping the server and get version/pid/uptime info.

Returns:

  • (Hash<String, Object>?)

    response hash or nil if server unreachable



293
294
295
# File 'lib/docscribe/server.rb', line 293

def ping
  request('ping')
end

#shutdownHash<String, Object>?

Send a shutdown request to the server.

Returns:

  • (Hash<String, Object>?)

    response hash or nil if server unreachable



286
287
288
# File 'lib/docscribe/server.rb', line 286

def shutdown
  request('shutdown')
end