Class: CouchDB::Server
- Inherits:
-
Object
- Object
- CouchDB::Server
- Defined in:
- lib/couchdb/server.rb
Overview
The Server class provides methods to retrieve informations and statistics of a CouchDB server.
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #database_names ⇒ Object
- #information ⇒ Object
-
#initialize(host = "localhost", port = 5984) ⇒ Server
constructor
A new instance of Server.
- #statistics ⇒ Object
- #url ⇒ Object
- #uuids(count = 1) ⇒ Object
Constructor Details
#initialize(host = "localhost", port = 5984) ⇒ Server
Returns a new instance of Server.
11 12 13 |
# File 'lib/couchdb/server.rb', line 11 def initialize(host = "localhost", port = 5984) @host, @port = host, port end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
8 9 10 |
# File 'lib/couchdb/server.rb', line 8 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
9 10 11 |
# File 'lib/couchdb/server.rb', line 9 def port @port end |
Instance Method Details
#==(other) ⇒ Object
15 16 17 |
# File 'lib/couchdb/server.rb', line 15 def ==(other) other.is_a?(self.class) && @host == other.host && @port == other.port end |
#database_names ⇒ Object
27 28 29 |
# File 'lib/couchdb/server.rb', line 27 def database_names Transport::JSON.request :get, url + "/_all_dbs", :expected_status_code => 200 end |
#information ⇒ Object
19 20 21 |
# File 'lib/couchdb/server.rb', line 19 def information Transport::JSON.request :get, url + "/", :expected_status_code => 200 end |
#statistics ⇒ Object
23 24 25 |
# File 'lib/couchdb/server.rb', line 23 def statistics Transport::JSON.request :get, url + "/_stats", :expected_status_code => 200 end |
#url ⇒ Object
36 37 38 |
# File 'lib/couchdb/server.rb', line 36 def url "http://#{@host}:#{@port}" end |
#uuids(count = 1) ⇒ Object
31 32 33 34 |
# File 'lib/couchdb/server.rb', line 31 def uuids(count = 1) response = Transport::JSON.request :get, url + "/_uuids", :expected_status_code => 200, :parameters => { :count => count } response["uuids"] end |