lib/ruote/couch/database.rb in ruote-couch-2.1.9 vs lib/ruote/couch/database.rb in ruote-couch-2.1.10
- old
+ new
@@ -35,13 +35,16 @@
#
class Database
attr_reader :type
- def initialize (host, port, type, name, re_put_ok=true)
+ attr_reader :couch
- opts = { :re_put_ok => re_put_ok }
+ def initialize (host, port, type, name)
+
+ #opts = { :re_put_ok => re_put_ok }
+ opts = {}
#opts[:timeout] = TODO
@couch = Rufus::Jig::Couch.new(host, port, name, opts)
@couch.put('.') unless @couch.get('.')
@@ -67,11 +70,17 @@
@couch.get(key, opts)
end
def delete (doc)
- @couch.delete(doc)
+ r = @couch.delete(doc)
+
+ #p [ :del, doc['_id'], Thread.current.object_id.to_s[-3..-1], r.nil? ]
+ Thread.pass
+ # without this, test/functional/ct_0 fails after 1 to 10 runs...
+
+ r
end
def get_many (key, opts)
rs = @couch.get("_all_docs?include_docs=true#{query_options(opts)}")
@@ -82,17 +91,19 @@
# naive...
rs.select { |doc| ! doc['_id'].match(/^\_design\//) }
end
+ DESIGN_DOC_REGEX = /^\_design\//
+
# Returns a sorted list of the ids of all the docs in this database.
#
def ids
rs = @couch.get('_all_docs')
- rs['rows'].collect { |r| r['id'] }
+ rs['rows'].collect { |r| r['id'] }.reject { |i| i.match(DESIGN_DOC_REGEX) }
end
def dump
s = "=== #{@type} ===\n"
@@ -278,13 +289,12 @@
"_design/ruote/_view/by_field?include_docs=true#{query_options(opts)}",
cr)
hwis = hwis.select { |hwi| hwi['fei']['wfid'] == wfid } if wfid
- hwis = hwis.select { |hwi|
- Ruote::StorageParticipant.matches?(hwi, pname, criteria) }
-
- hwis.collect { |hwi| Ruote::Workitem.new(hwi) }
+ hwis.select { |hwi|
+ Ruote::StorageParticipant.matches?(hwi, pname, criteria)
+ }
end
# Returns the design document that goes with this class of database
#
def self.design_doc