Module: WingedCouch::Native::Server

Extended by:
Server
Included in:
Server
Defined in:
lib/winged_couch/native/server.rb

Overview

Module for performing base operations over server

Instance Method Summary collapse

Instance Method Details

#active_tasksObject

Returns data about active tasks


44
45
46
# File 'lib/winged_couch/native/server.rb', line 44

def active_tasks
  get path.join("_active_tasks")
end

#all_dbsObject

Returns all dbs data


34
35
36
# File 'lib/winged_couch/native/server.rb', line 34

def all_dbs
  get path.join("_all_dbs")
end

#enable_corsObject

Enables cross-origin requests


125
126
127
128
129
130
131
132
133
134
# File 'lib/winged_couch/native/server.rb', line 125

def enable_cors
  config_path = path.join('_config')
  httpd_config_path = config_path.join('https')
  cors_config_path = config_path.join('cors')
  RestClient.put httpd_config_path.join('enable_cors'), '"true"'
  RestClient.put cors_config_path.join('origins'), '"*"'
  RestClient.put cors_config_path.join('credentials'), '"true"'
  RestClient.put cors_config_path.join('methods'), '"GET, PUT, POST, HEAD, DELETE"'
  RestClient.put cors_config_path.join('headers'), '"accept, authorization, content-type, origin, referer"'
end

#infoObject

Returns base information about CouchDB server


24
25
26
# File 'lib/winged_couch/native/server.rb', line 24

def info
  get path
end

#log(data = {}) ⇒ Object

Returns the tail of the server's log file, requires server admin privileges.

Parameters:

  • data (Hash) (defaults to: {})

Options Hash (data):

  • :bytes (Fixnum)

    How many bytes to return from the tail of the log file(optional, default 1000)

  • :offset (Fixnum)

    How many bytes to offset the returned tail of the log file (optional, default 0)

Returns:

  • String multiline log string

See Also:


116
117
118
119
120
121
# File 'lib/winged_couch/native/server.rb', line 116

def log(data = {})
  bytes  = data.fetch(:bytes, 1000)
  offset = data.fetch(:offset, 0)
  url = path.join("_log").to_s
  RestClient.get url, bytes: bytes, offset: offset
end

#replicate(data) ⇒ Object

Creates replication according to passed data

Parameters:

  • data (Hash)

Options Hash (data):

  • :source (String)

    Identifies the database to copy revisions from. Requered field.

  • :target (String)

    Identifies the database to copy revisions to. Requered field.

  • :cancel (true, false)

    Include this property with a value of true to cancel an existing replication between the specified source and target

  • :continuous (true, false)

    CouchDB can persist continuous replications over a server restart

  • :create_target (true, false)

    A value of true tells the replicator to create the target database if it doesn't exist yet

  • :doc_ids (Array<String>)

    Array of document IDs; if given, only these documents will be replicated

  • :filter (String)

    Name of a filter function that can choose which revisions get replicated

  • :proxy (String)

    Proxy server URL.

  • :query_params (Hash)

    Object containing properties that are passed to the filter function

Returns:

  • Hash response from CouchDB

See Also:


75
76
77
# File 'lib/winged_couch/native/server.rb', line 75

def replicate(data)
  post path.join("replicate"), data
end

#restartObject

Restarts the server, requires admin privileges


93
94
95
# File 'lib/winged_couch/native/server.rb', line 93

def restart
  post path.join("_restart")
end

#statsObject

Returns server statistics

Returns:

  • Hash


101
102
103
# File 'lib/winged_couch/native/server.rb', line 101

def stats
  get path.join("_stats")
end

#uuids(count = 1) ⇒ Hash

Returns list of used generated UUIDs

Parameters:

  • count (Fixnum) (defaults to: 1)

    How many UUIDs to generate (optional, default 1)

Returns:

  • (Hash)

See Also:


87
88
89
# File 'lib/winged_couch/native/server.rb', line 87

def uuids(count = 1)
  get path.join("_uuids"), count: count
end