couch_potato-extensions 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/couch_potato/extensions.rb +3 -2
- data/lib/couch_potato/extensions/attachments.rb +16 -0
- data/spec/attachments_spec.rb +31 -0
- data/spec/spec_helper.rb +2 -1
- metadata +45 -17
@@ -2,9 +2,10 @@ require File.expand_path(File.dirname(__FILE__) + "/extensions/persistence")
|
|
2
2
|
require File.expand_path(File.dirname(__FILE__) + "/extensions/encryption")
|
3
3
|
require File.expand_path(File.dirname(__FILE__) + "/extensions/encrypted_property")
|
4
4
|
require File.expand_path(File.dirname(__FILE__) + "/extensions/encrypted_view_spec")
|
5
|
+
require File.expand_path(File.dirname(__FILE__) + "/extensions/attachments")
|
5
6
|
|
6
7
|
module CouchPotato
|
7
8
|
module Extensions
|
8
|
-
VERSION = '0.0.
|
9
|
+
VERSION = '0.0.7'
|
9
10
|
end
|
10
|
-
end
|
11
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module CouchPotato
|
2
|
+
module Extensions
|
3
|
+
module Attachments
|
4
|
+
def attachment(name)
|
5
|
+
if not new?
|
6
|
+
begin
|
7
|
+
CouchPotato.database.send(:database).fetch_attachment(id, name)
|
8
|
+
rescue RestClient::ResourceNotFound
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
CouchPotato::Persistence.send(:include, CouchPotato::Extensions::Attachments)
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe CouchPotato::Extensions::Attachments do
|
4
|
+
class Attachment
|
5
|
+
include CouchPotato::Persistence
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should add an accessor for attachments" do
|
9
|
+
Attachment.new.respond_to?(:attachment).should == true
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should fetch the attachment when available" do
|
13
|
+
attachment = Attachment.new
|
14
|
+
attachment._attachments['pdf'] = {'data' => 'invoice', 'content_type' => 'application/pdf'}
|
15
|
+
CouchPotato.database.save(attachment)
|
16
|
+
attachment.attachment('pdf').should == 'invoice'
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should not raise an error when the record is not persisted yet" do
|
20
|
+
attachment = Attachment.new
|
21
|
+
lambda {
|
22
|
+
attachment.attachment('pdf').should == nil
|
23
|
+
}.should_not raise_error
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should return nil when the attachment is not available" do
|
27
|
+
attachment = Attachment.new
|
28
|
+
CouchPotato.database.save(attachment)
|
29
|
+
attachment.attachment('pdf').should == nil
|
30
|
+
end
|
31
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -14,4 +14,5 @@ recreate_db
|
|
14
14
|
require 'couch_potato/extensions/encryption'
|
15
15
|
require 'couch_potato/extensions/encrypted_property'
|
16
16
|
require 'couch_potato/extensions/persistence'
|
17
|
-
require 'couch_potato/extensions/encrypted_view_spec'
|
17
|
+
require 'couch_potato/extensions/encrypted_view_spec'
|
18
|
+
require 'couch_potato/extensions/attachments'
|
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: couch_potato-extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 17
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 7
|
10
|
+
version: 0.0.7
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- Mathias Meyer
|
@@ -9,39 +15,53 @@ autorequire:
|
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
17
|
|
12
|
-
date: 2010-
|
18
|
+
date: 2010-07-15 00:00:00 +02:00
|
13
19
|
default_executable:
|
14
20
|
dependencies:
|
15
21
|
- !ruby/object:Gem::Dependency
|
16
22
|
name: couch_potato
|
17
|
-
|
18
|
-
|
19
|
-
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
20
26
|
requirements:
|
21
27
|
- - ">="
|
22
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
23
32
|
version: "0"
|
24
|
-
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
25
35
|
- !ruby/object:Gem::Dependency
|
26
36
|
name: ezcrypto
|
27
|
-
|
28
|
-
|
29
|
-
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
30
40
|
requirements:
|
31
41
|
- - ">="
|
32
42
|
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
44
|
+
segments:
|
45
|
+
- 0
|
33
46
|
version: "0"
|
34
|
-
|
47
|
+
type: :runtime
|
48
|
+
version_requirements: *id002
|
35
49
|
- !ruby/object:Gem::Dependency
|
36
50
|
name: rspec
|
37
|
-
|
38
|
-
|
39
|
-
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
40
54
|
requirements:
|
41
55
|
- - ~>
|
42
56
|
- !ruby/object:Gem::Version
|
57
|
+
hash: 13
|
58
|
+
segments:
|
59
|
+
- 1
|
60
|
+
- 2
|
61
|
+
- 9
|
43
62
|
version: 1.2.9
|
44
|
-
|
63
|
+
type: :development
|
64
|
+
version_requirements: *id003
|
45
65
|
description: See summary, it says it all, trust me.
|
46
66
|
email: meyer@paperplanes.de
|
47
67
|
executables: []
|
@@ -52,11 +72,13 @@ extra_rdoc_files:
|
|
52
72
|
- README.md
|
53
73
|
files:
|
54
74
|
- Rakefile
|
75
|
+
- lib/couch_potato/extensions/attachments.rb
|
55
76
|
- lib/couch_potato/extensions/encrypted_property.rb
|
56
77
|
- lib/couch_potato/extensions/encrypted_view_spec.rb
|
57
78
|
- lib/couch_potato/extensions/encryption.rb
|
58
79
|
- lib/couch_potato/extensions/persistence.rb
|
59
80
|
- lib/couch_potato/extensions.rb
|
81
|
+
- spec/attachments_spec.rb
|
60
82
|
- spec/encrypted_property_spec.rb
|
61
83
|
- spec/encrypted_view_spec.rb
|
62
84
|
- spec/spec_helper.rb
|
@@ -71,21 +93,27 @@ rdoc_options:
|
|
71
93
|
require_paths:
|
72
94
|
- lib
|
73
95
|
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
none: false
|
74
97
|
requirements:
|
75
98
|
- - ">="
|
76
99
|
- !ruby/object:Gem::Version
|
100
|
+
hash: 3
|
101
|
+
segments:
|
102
|
+
- 0
|
77
103
|
version: "0"
|
78
|
-
version:
|
79
104
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
80
106
|
requirements:
|
81
107
|
- - ">="
|
82
108
|
- !ruby/object:Gem::Version
|
109
|
+
hash: 3
|
110
|
+
segments:
|
111
|
+
- 0
|
83
112
|
version: "0"
|
84
|
-
version:
|
85
113
|
requirements: []
|
86
114
|
|
87
115
|
rubyforge_project:
|
88
|
-
rubygems_version: 1.3.
|
116
|
+
rubygems_version: 1.3.7
|
89
117
|
signing_key:
|
90
118
|
specification_version: 3
|
91
119
|
summary: Some extensions for CouchPotato, because more awesome is always a good thing.
|