Class: Docscribe::Server::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/docscribe/server/client.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



12
13
14
# File 'lib/docscribe/server/client.rb', line 12

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)

    extra JSON-RPC params (e.g. cli_overrides)

Returns:

  • (Hash<String, Object>?)

    response hash or nil if server unreachable



22
23
24
# File 'lib/docscribe/server/client.rb', line 22

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)

    extra JSON-RPC params (e.g. cli_overrides)

Returns:

  • (Hash<String, Object>?)

    response hash or nil if server unreachable



32
33
34
# File 'lib/docscribe/server/client.rb', line 32

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



55
56
57
# File 'lib/docscribe/server/client.rb', line 55

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



39
40
41
# File 'lib/docscribe/server/client.rb', line 39

def shutdown
  request('shutdown')
end

#update_types(dir: '.', **rest) ⇒ Hash<String, Object>?

Send an update_types request to the server.

Parameters:

  • dir (String) (defaults to: '.')

    directory to update (defaults to '.')

  • rest (Object)

    extra JSON-RPC params (e.g. cli_overrides)

Returns:

  • (Hash<String, Object>?)

    response hash or nil if server unreachable



48
49
50
# File 'lib/docscribe/server/client.rb', line 48

def update_types(dir: '.', **rest)
  request('update_types', dir: dir, **rest)
end