couch_docs 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +5 -0
- data/couch_docs.gemspec +1 -0
- data/lib/couch_docs/command_line.rb +9 -0
- data/lib/couch_docs/document_directory.rb +4 -7
- data/lib/couch_docs/store.rb +2 -1
- data/lib/couch_docs/version.rb +1 -1
- data/spec/couch_docs/store_spec.rb +10 -0
- metadata +19 -4
data/History.txt
CHANGED
data/couch_docs.gemspec
CHANGED
@@ -24,4 +24,5 @@ Gem::Specification.new do |s|
|
|
24
24
|
s.add_runtime_dependency(%q<rest-client>, ["~> 1.6.0"])
|
25
25
|
s.add_runtime_dependency(%q<json>, ["~> 1.4.0"])
|
26
26
|
s.add_runtime_dependency(%q<directory_watcher>, ["~> 1.3.0"])
|
27
|
+
s.add_runtime_dependency(%q<mime-types>, ["~> 1.16"])
|
27
28
|
end
|
@@ -147,6 +147,15 @@ module CouchDocs
|
|
147
147
|
update.path)
|
148
148
|
end
|
149
149
|
end
|
150
|
+
rescue RestClient::ResourceNotFound => e
|
151
|
+
$stderr.puts "\n"
|
152
|
+
$stderr.puts e.message
|
153
|
+
$stderr.puts "Does the database exist? Try using the -R option."
|
154
|
+
$stderr.puts "\n"
|
155
|
+
rescue Exception => e
|
156
|
+
$stderr.puts "\n"
|
157
|
+
$stderr.puts e.message
|
158
|
+
$stderr.puts e.backtrace
|
150
159
|
end
|
151
160
|
|
152
161
|
def initial_add?(args)
|
@@ -36,7 +36,7 @@ module CouchDocs
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def file_as_attachment(file)
|
39
|
-
type = mime_type(
|
39
|
+
type = mime_type(file)
|
40
40
|
data = File.read(file)
|
41
41
|
|
42
42
|
attachment = {
|
@@ -69,12 +69,9 @@ module CouchDocs
|
|
69
69
|
end
|
70
70
|
|
71
71
|
private
|
72
|
-
def mime_type(
|
73
|
-
(
|
74
|
-
|
75
|
-
".jpg" => "image/jpeg",
|
76
|
-
".png" => "image/png"
|
77
|
-
})[extension]
|
72
|
+
def mime_type(file)
|
73
|
+
type = MIME::Types.type_for(file).first.to_s
|
74
|
+
(type && type != '') ? type : nil
|
78
75
|
end
|
79
76
|
end
|
80
77
|
end
|
data/lib/couch_docs/store.rb
CHANGED
@@ -55,7 +55,8 @@ module CouchDocs
|
|
55
55
|
def self.delete(path)
|
56
56
|
# retrieve existing to obtain the revision
|
57
57
|
old = self.get(path)
|
58
|
-
|
58
|
+
url = old['_rev'] ? path + "?rev=#{old['_rev']}" : path
|
59
|
+
RestClient.delete(url)
|
59
60
|
end
|
60
61
|
|
61
62
|
def self.get(path)
|
data/lib/couch_docs/version.rb
CHANGED
@@ -81,6 +81,16 @@ describe CouchDocs::Store do
|
|
81
81
|
CouchDocs::Store.delete("uri")
|
82
82
|
end
|
83
83
|
|
84
|
+
it "deletes without revision if none is present (e.g. database delete)" do
|
85
|
+
CouchDocs::Store.stub!(:get).and_return({ })
|
86
|
+
|
87
|
+
RestClient.
|
88
|
+
should_receive(:delete).
|
89
|
+
with("uri")
|
90
|
+
|
91
|
+
CouchDocs::Store.delete("uri")
|
92
|
+
end
|
93
|
+
|
84
94
|
it "should be able to load each document" do
|
85
95
|
CouchDocs::Store.stub!(:get).
|
86
96
|
with("uri/_all_docs").
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: couch_docs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 1.3.
|
9
|
+
- 1
|
10
|
+
version: 1.3.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Chris Strom
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-01-
|
18
|
+
date: 2011-01-02 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -82,6 +82,21 @@ dependencies:
|
|
82
82
|
version: 1.3.0
|
83
83
|
type: :runtime
|
84
84
|
version_requirements: *id004
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: mime-types
|
87
|
+
prerelease: false
|
88
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
hash: 47
|
94
|
+
segments:
|
95
|
+
- 1
|
96
|
+
- 16
|
97
|
+
version: "1.16"
|
98
|
+
type: :runtime
|
99
|
+
version_requirements: *id005
|
85
100
|
description: Manage CouchDB views and documents.
|
86
101
|
email:
|
87
102
|
- chris@eeecooks.com
|