rufus-jig 0.1.11 → 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.txt +4 -0
- data/lib/rufus/jig/couch.rb +16 -9
- data/lib/rufus/jig/version.rb +1 -1
- data/rufus-jig.gemspec +2 -2
- data/test/ct_1_couchdb.rb +14 -0
- metadata +2 -2
data/CHANGELOG.txt
CHANGED
data/lib/rufus/jig/couch.rb
CHANGED
@@ -84,27 +84,34 @@ module Rufus::Jig
|
|
84
84
|
|
85
85
|
def delete (doc_or_path, rev=nil)
|
86
86
|
|
87
|
-
|
88
|
-
|
89
|
-
|
87
|
+
doc, path, rev = if rev
|
88
|
+
[ { '_id' => doc_or_path, '_rev' => rev }, doc_or_path ]
|
89
|
+
elsif doc_or_path.is_a?(String)
|
90
|
+
[ nil, doc_or_path ]
|
91
|
+
else
|
92
|
+
[ doc_or_path, doc_or_path['_id'] ]
|
93
|
+
end
|
90
94
|
|
91
|
-
|
95
|
+
path = adjust(path)
|
92
96
|
|
93
|
-
|
97
|
+
r = if doc
|
94
98
|
|
95
99
|
raise(
|
96
100
|
ArgumentError.new("cannot delete document without _rev")
|
97
|
-
) unless
|
101
|
+
) unless doc['_rev']
|
102
|
+
|
103
|
+
rpath = Rufus::Jig::Path.add_params(path, :rev => doc['_rev'])
|
98
104
|
|
99
|
-
|
100
|
-
|
105
|
+
@http.delete(rpath)
|
106
|
+
|
107
|
+
else
|
101
108
|
|
102
109
|
@http.delete(path)
|
103
110
|
end
|
104
111
|
|
105
112
|
if r == true # conflict
|
106
113
|
|
107
|
-
doc = @http.get(
|
114
|
+
doc = @http.get(path)
|
108
115
|
doc ? doc : true
|
109
116
|
# returns the doc if present or true if the doc is gone
|
110
117
|
|
data/lib/rufus/jig/version.rb
CHANGED
data/rufus-jig.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rufus-jig}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.12"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["John Mettraux", "Kenneth Kalmer"]
|
12
|
-
s.date = %q{2010-01-
|
12
|
+
s.date = %q{2010-01-13}
|
13
13
|
s.description = %q{
|
14
14
|
Json Interwebs Get.
|
15
15
|
|
data/test/ct_1_couchdb.rb
CHANGED
@@ -154,5 +154,19 @@ class CtCouchDbTest < Test::Unit::TestCase
|
|
154
154
|
doc = @c.get('coffee1')
|
155
155
|
assert_equal 304, @c.http.last_response.status
|
156
156
|
end
|
157
|
+
|
158
|
+
def test_delete_path
|
159
|
+
|
160
|
+
r = @c.delete('coffee1')
|
161
|
+
|
162
|
+
assert_equal(@c.get('coffee1'), r)
|
163
|
+
end
|
164
|
+
|
165
|
+
def test_delete_path_missing
|
166
|
+
|
167
|
+
r = @c.delete('missing')
|
168
|
+
|
169
|
+
assert_equal(true, r)
|
170
|
+
end
|
157
171
|
end
|
158
172
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rufus-jig
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Mettraux
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2010-01-
|
13
|
+
date: 2010-01-13 00:00:00 +09:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|