paperclip-fedora 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -30,8 +30,7 @@ other that you specify), as well as the original upload.
30
30
 
31
31
  ## Todo
32
32
 
33
- The object and datastream labels are currently static and not too pretty. Plans to
34
- make the object label the original filename and the datastreams follow a similar pattern.
33
+ More features?
35
34
 
36
35
  ## Copyright & Acknowledgements
37
36
 
@@ -14,8 +14,18 @@ module Paperclip
14
14
  end
15
15
 
16
16
  @fedora_config = parse_config(@options[:fedora_config])
17
- @url = @fedora_config[:host] + "/objects/upload\::id/datastreams/:style/content"
18
- @path = "upload\::id"
17
+ @path = ":basename_clean\::id"
18
+ @url = @fedora_config[:host] + "/objects/#{@path}/datastreams/:style/content"
19
+
20
+ Paperclip.interpolates(:basename_clean) do |attachment, style|
21
+ s = File.basename(attachment.original_filename, File.extname(attachment.original_filename))
22
+ s.downcase!
23
+ s.gsub!(/'/, '')
24
+ s.gsub!(/[^A-Za-z0-9:\-]+/, ' ')
25
+ s.strip!
26
+ s.gsub!(/\ +/, '-')
27
+ s
28
+ end unless Paperclip::Interpolations.respond_to? :basename_clean
19
29
  end
20
30
  end
21
31
 
@@ -39,7 +49,7 @@ module Paperclip
39
49
  ds = fedora_object.datastreams[style.to_s]
40
50
  ds.controlGroup = 'M'
41
51
  ds.file = file
42
- ds.dsLabel = "TempFile"
52
+ ds.dsLabel = "#{File.extname(file)} file"
43
53
  ds.save
44
54
  log("Added #{style} datastream to #{@object_id}")
45
55
  end
@@ -61,7 +71,7 @@ module Paperclip
61
71
  @@repo
62
72
  end
63
73
 
64
- def create_object
74
+ def fedora_object
65
75
  @object_id = path()
66
76
  object = fedora.find(@object_id)
67
77
  object.label = @object_id
@@ -69,10 +79,6 @@ module Paperclip
69
79
  saved_object
70
80
  end
71
81
 
72
- def fedora_object
73
- @fedora_object ||= create_object
74
- end
75
-
76
82
  def parse_config config
77
83
  config = find_credentials(config).stringify_keys
78
84
  (config[Rails.env] || config).symbolize_keys
@@ -1,5 +1,5 @@
1
1
  module Paperclip
2
2
  module Fedora
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.1"
4
4
  end
5
5
  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.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-14 00:00:00.000000000Z
12
+ date: 2011-09-15 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: paperclip
16
- requirement: &2152442460 !ruby/object:Gem::Requirement
16
+ requirement: &2152368380 !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: *2152442460
24
+ version_requirements: *2152368380
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rubydora
27
- requirement: &2152441900 !ruby/object:Gem::Requirement
27
+ requirement: &2152367740 !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: *2152441900
35
+ version_requirements: *2152367740
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &2152441060 !ruby/object:Gem::Requirement
38
+ requirement: &2152366820 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - =
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: 0.9.2
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2152441060
46
+ version_requirements: *2152366820
47
47
  description: Adds Fedora Commons storage support for the Paperclip gem.
48
48
  email:
49
49
  - jaredsartin@gmail.com