Class: Exegesis::Server

Inherits:
Object
  • Object
show all
Includes:
Http
Defined in:
lib/exegesis/server.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Http

#delete, #escape_id, #format_url, #get, #post, #put

Constructor Details

#initialize(address = 'http://localhost:5984') ⇒ Server

Creates a new instance of Exegesis::Server. Defaults to localhost:5984 and verifies the existance of the database.



9
10
11
12
# File 'lib/exegesis/server.rb', line 9

def initialize address='http://localhost:5984'
  @uri = address
  @version = get(@uri)['version']
end

Instance Attribute Details

#uriObject

Returns the value of attribute uri.



5
6
7
# File 'lib/exegesis/server.rb', line 5

def uri
  @uri
end

#versionObject

Returns the value of attribute version.



5
6
7
# File 'lib/exegesis/server.rb', line 5

def version
  @version
end

Instance Method Details

#create_database(name) ⇒ Object

creates a database with the given name on the server



20
21
22
# File 'lib/exegesis/server.rb', line 20

def create_database name
  put "#{@uri}/#{name}"
end

#databasesObject

returns an array of all the databases on the server



15
16
17
# File 'lib/exegesis/server.rb', line 15

def databases
  get "#{@uri}/_all_dbs"
end

#inspectObject



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

def inspect
  "#<Exegesis::Server:#{object_id} uri=#{@uri}>"
end