paperclip-fedora 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/paperclip-fedora/version.rb +1 -1
- data/lib/paperclip-fedora.rb +29 -4
- metadata +7 -7
data/lib/paperclip-fedora.rb
CHANGED
@@ -20,6 +20,9 @@ module Paperclip
|
|
20
20
|
@custom_namespace = @options[:fedora_pid]
|
21
21
|
|
22
22
|
@server_url = "http\://#{@host}\:#{@port}/#{@context}"
|
23
|
+
@object_id = instance.uuid || @custom_pid || path()
|
24
|
+
@path = @object_id
|
25
|
+
@url = "#{@server_url}/objects/#{@path}/datastreams/:style/content"
|
23
26
|
|
24
27
|
Paperclip.interpolates(:basename_clean) do |attachment, style|
|
25
28
|
s = File.basename(attachment.original_filename, File.extname(attachment.original_filename))
|
@@ -49,14 +52,22 @@ module Paperclip
|
|
49
52
|
end
|
50
53
|
|
51
54
|
def flush_writes
|
55
|
+
@object_id = instance.uuid || @custom_pid || path()
|
56
|
+
@path = @object_id
|
57
|
+
@url = "#{@server_url}/objects/#{@path}/datastreams/:style/content"
|
58
|
+
ps = fedora_object.datastreams['paperclip_styles']
|
59
|
+
style_list = ps.content
|
52
60
|
@queued_for_write.each do |style, file|
|
61
|
+
style_list = "#{style_list.strip} #{style.to_s}"
|
53
62
|
ds = fedora_object.datastreams[style.to_s]
|
54
63
|
ds.controlGroup = 'M'
|
55
64
|
ds.file = file
|
56
|
-
ds.dsLabel = "#{File.extname(file)} file"
|
65
|
+
ds.dsLabel = "Paperclip: #{File.extname(file)} file"
|
57
66
|
ds.save
|
58
67
|
log("Added #{style} datastream to #{@object_id}")
|
59
68
|
end
|
69
|
+
ps.content = style_list.strip
|
70
|
+
ps.save
|
60
71
|
@queued_for_write = {}
|
61
72
|
end
|
62
73
|
|
@@ -64,8 +75,15 @@ module Paperclip
|
|
64
75
|
@queued_for_delete.uniq!
|
65
76
|
@queued_for_delete.each do |path|
|
66
77
|
object = fedora.find(path)
|
67
|
-
|
68
|
-
|
78
|
+
pso = object.datastreams['paperclip_styles']
|
79
|
+
ps = pso.content
|
80
|
+
ps.split(' ').each do |style|
|
81
|
+
ds = object.datastreams[style]
|
82
|
+
ds.delete
|
83
|
+
log("Deleted #{path} - #{style} stream")
|
84
|
+
end
|
85
|
+
pso.content = " "
|
86
|
+
pso.save
|
69
87
|
end
|
70
88
|
@queued_for_delete = []
|
71
89
|
end
|
@@ -82,6 +100,14 @@ module Paperclip
|
|
82
100
|
object = fedora.find(@object_id)
|
83
101
|
object.label = @object_id
|
84
102
|
saved_object = object.save
|
103
|
+
paperclip_styles = object.datastreams['paperclip_styles']
|
104
|
+
if paperclip_styles.new?
|
105
|
+
paperclip_styles.controlGroup = 'M'
|
106
|
+
paperclip_styles.dsLabel = "Paperclip styles - Used for deletion tracking"
|
107
|
+
paperclip_styles.content = " "
|
108
|
+
paperclip_styles.mimeType = "text/plain"
|
109
|
+
paperclip_styles.save
|
110
|
+
end
|
85
111
|
saved_object
|
86
112
|
end
|
87
113
|
|
@@ -116,7 +142,6 @@ module Paperclip
|
|
116
142
|
raise ArgumentError, "Configuration settings are not a path, file, or hash."
|
117
143
|
end
|
118
144
|
end
|
119
|
-
|
120
145
|
end
|
121
146
|
end
|
122
147
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paperclip-fedora
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-09-28 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: paperclip
|
16
|
-
requirement: &
|
16
|
+
requirement: &2164384320 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2164384320
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rubydora
|
27
|
-
requirement: &
|
27
|
+
requirement: &2164382960 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2164382960
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rake
|
38
|
-
requirement: &
|
38
|
+
requirement: &2164381720 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2164381720
|
47
47
|
description: Adds Fedora Commons storage support for the Paperclip gem.
|
48
48
|
email:
|
49
49
|
- jaredsartin@gmail.com
|