Class: CouchDB::Server
- Inherits:
-
Object
- Object
- CouchDB::Server
- Defined in:
- lib/couchdb/server.rb
Overview
The Server class provides methods to retrieve information and statistics of a CouchDB server.
Instance Attribute Summary collapse
- #host ⇒ Object
-
#password ⇒ Object
Returns the value of attribute password.
-
#password_salt ⇒ Object
Returns the value of attribute password_salt.
- #port ⇒ Object
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #authentication_options ⇒ Object
- #database_names ⇒ Object
- #information ⇒ Object
-
#initialize(host = nil, port = nil, username = nil, password = nil) ⇒ Server
constructor
A new instance of Server.
- #statistics ⇒ Object
- #url ⇒ Object
- #user_database ⇒ Object
- #uuids(count = 1) ⇒ Object
Constructor Details
#initialize(host = nil, port = nil, username = nil, password = nil) ⇒ Server
Returns a new instance of Server.
15 16 17 |
# File 'lib/couchdb/server.rb', line 15 def initialize(host = nil, port = nil, username = nil, password = nil) @host, @port, @username, @password = host, port, username, password end |
Instance Attribute Details
#host ⇒ Object
19 20 21 |
# File 'lib/couchdb/server.rb', line 19 def host @host || "localhost" end |
#password ⇒ Object
Returns the value of attribute password.
11 12 13 |
# File 'lib/couchdb/server.rb', line 11 def password @password end |
#password_salt ⇒ Object
Returns the value of attribute password_salt.
13 14 15 |
# File 'lib/couchdb/server.rb', line 13 def password_salt @password_salt end |
#port ⇒ Object
23 24 25 |
# File 'lib/couchdb/server.rb', line 23 def port @port || 5984 end |
#username ⇒ Object
Returns the value of attribute username.
10 11 12 |
# File 'lib/couchdb/server.rb', line 10 def username @username end |
Instance Method Details
#==(other) ⇒ Object
27 28 29 |
# File 'lib/couchdb/server.rb', line 27 def ==(other) other.is_a?(self.class) && self.host == other.host && self.port == other.port end |
#authentication_options ⇒ Object
56 57 58 |
# File 'lib/couchdb/server.rb', line 56 def self.username && self.password ? { :auth_type => :basic, :username => self.username, :password => self.password } : { } end |
#database_names ⇒ Object
39 40 41 |
# File 'lib/couchdb/server.rb', line 39 def database_names Transport::JSON.request :get, url + "/_all_dbs", end |
#information ⇒ Object
31 32 33 |
# File 'lib/couchdb/server.rb', line 31 def information Transport::JSON.request :get, url + "/", end |
#statistics ⇒ Object
35 36 37 |
# File 'lib/couchdb/server.rb', line 35 def statistics Transport::JSON.request :get, url + "/_stats", end |
#url ⇒ Object
52 53 54 |
# File 'lib/couchdb/server.rb', line 52 def url "http://#{self.host}:#{self.port}" end |
#user_database ⇒ Object
48 49 50 |
# File 'lib/couchdb/server.rb', line 48 def user_database @user_database ||= UserDatabase.new self end |
#uuids(count = 1) ⇒ Object
43 44 45 46 |
# File 'lib/couchdb/server.rb', line 43 def uuids(count = 1) response = Transport::JSON.request :get, url + "/_uuids", .merge(:parameters => { :count => count }) response["uuids"] end |