all specs pass with the new layout
This commit is contained in:
parent
211331f4a6
commit
711fdc1ca6
2 changed files with 24 additions and 21 deletions
|
@ -17,13 +17,35 @@ module CouchRest
|
|||
autoload :Streamer, 'couchrest/helper/streamer'
|
||||
|
||||
# The CouchRest module methods handle the basic JSON serialization
|
||||
# and deserialization, as well as query parameters.
|
||||
# and deserialization, as well as query parameters. The module also includes
|
||||
# some helpers for tasks like instantiating a new Database or Server instance.
|
||||
class << self
|
||||
|
||||
|
||||
# todo, make this parse the url and instantiate a Server or Database instance
|
||||
# depending on the specificity.
|
||||
def new(*opts)
|
||||
Server.new(*opts)
|
||||
end
|
||||
|
||||
# ensure that a database exists
|
||||
# creates it if it isn't already there
|
||||
# returns it after it's been created
|
||||
def database! url
|
||||
uri = URI.parse url
|
||||
path = uri.path
|
||||
uri.path = ''
|
||||
cr = CouchRest.new(uri.to_s)
|
||||
cr.database!(path)
|
||||
end
|
||||
|
||||
def database url
|
||||
uri = URI.parse url
|
||||
path = uri.path
|
||||
uri.path = ''
|
||||
cr = CouchRest.new(uri.to_s)
|
||||
cr.database(path)
|
||||
end
|
||||
|
||||
def put uri, doc = nil
|
||||
payload = doc.to_json if doc
|
||||
JSON.parse(RestClient.put(uri, payload))
|
||||
|
|
|
@ -6,25 +6,6 @@ module CouchRest
|
|||
@uuid_batch_count = uuid_batch_count
|
||||
end
|
||||
|
||||
# ensure that a database exists
|
||||
# creates it if it isn't already there
|
||||
# returns it after it's been created
|
||||
def self.database! url
|
||||
uri = URI.parse url
|
||||
path = uri.path
|
||||
uri.path = ''
|
||||
cr = CouchRest.new(uri.to_s)
|
||||
cr.database!(path)
|
||||
end
|
||||
|
||||
def self.database url
|
||||
uri = URI.parse url
|
||||
path = uri.path
|
||||
uri.path = ''
|
||||
cr = CouchRest.new(uri.to_s)
|
||||
cr.database(path)
|
||||
end
|
||||
|
||||
# list all databases on the server
|
||||
def databases
|
||||
CouchRest.get "#{@uri}/_all_dbs"
|
||||
|
|
Loading…
Reference in a new issue