hydra-core 5.2.0 → 5.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/generators/hydra/head_generator.rb +0 -3
- data/lib/hydra-head/version.rb +1 -1
- data/lib/hydra/controller/upload_behavior.rb +1 -14
- data/lib/hydra/model_methods.rb +22 -14
- data/lib/hydra/models/file_asset.rb +0 -1
- data/spec/helpers/upload_behavior_spec.rb +3 -9
- data/spec/lib/model_methods_spec.rb +13 -1
- data/spec/models/file_asset_spec.rb +25 -0
- data/spec/support/Gemfile +2 -2
- metadata +9 -5
- data/lib/generators/hydra/templates/config/solr_mappings.yml +0 -22
@@ -45,9 +45,6 @@ class HeadGenerator < Rails::Generators::Base
|
|
45
45
|
copy_file "config/role_map_production.yml", "config/role_map_production.yml"
|
46
46
|
copy_file "config/role_map_test.yml", "config/role_map_test.yml"
|
47
47
|
|
48
|
-
# Solr Mappings
|
49
|
-
copy_file "config/solr_mappings.yml", "config/solr_mappings.yml"
|
50
|
-
|
51
48
|
# Fedora & Solr YAML files
|
52
49
|
begin
|
53
50
|
invoke('active_fedora:config')
|
data/lib/hydra-head/version.rb
CHANGED
@@ -32,11 +32,7 @@ module Hydra::Controller::UploadBehavior
|
|
32
32
|
# deprecating 2 argument constructor because it depends on a HTTP request. If we pass the file name we can use for non-web too.
|
33
33
|
Deprecation.warn(Hydra::Controller::UploadBehavior, "add_posted_blob_to_asset with a 2 argument constructor is deprecated. Pass a filename (e.g. \"file.original_name\") as the third argument. 2 argument constructor will be removed in hydra-core 6" ) if file_name.nil?
|
34
34
|
file_name ||= file.original_filename
|
35
|
-
|
36
|
-
dsid = datastream_id #Only call this once so that it could be a sequence
|
37
|
-
options[:dsid] = dsid if dsid
|
38
|
-
asset.add_file_datastream(file, options)
|
39
|
-
asset.set_title_and_label( file_name, :only_if_blank=>true )
|
35
|
+
asset.add_file(file, datastream_id, file_name)
|
40
36
|
end
|
41
37
|
|
42
38
|
#Override this if you want to specify the datastream_id (dsID) for the created blob
|
@@ -58,13 +54,4 @@ module Hydra::Controller::UploadBehavior
|
|
58
54
|
deprecation_deprecate :associate_file_asset_with_container
|
59
55
|
|
60
56
|
|
61
|
-
private
|
62
|
-
# Return the mimeType for a given file name
|
63
|
-
# @param [String] file_name The filename to use to get the mimeType
|
64
|
-
# @return [String] mimeType for filename passed in. Default: application/octet-stream if mimeType cannot be determined
|
65
|
-
def mime_type file_name
|
66
|
-
mime_types = MIME::Types.of(file_name)
|
67
|
-
mime_type = mime_types.empty? ? "application/octet-stream" : mime_types.first.content_type
|
68
|
-
end
|
69
|
-
|
70
57
|
end
|
data/lib/hydra/model_methods.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# will move to lib/hydra/model/model_behavior.rb (with appropriate namespace changes) in release 5.x
|
2
2
|
module Hydra::ModelMethods
|
3
3
|
extend ActiveSupport::Concern
|
4
|
+
extend Deprecation
|
4
5
|
|
5
6
|
included do
|
6
7
|
unless self.class == Module
|
@@ -26,6 +27,21 @@ module Hydra::ModelMethods
|
|
26
27
|
return true
|
27
28
|
end
|
28
29
|
|
30
|
+
# Puts the contents of file (posted blob) into a datastream and sets the title and label
|
31
|
+
# Sets asset label and title to filename if they're empty
|
32
|
+
#
|
33
|
+
# @param [#read] file the IO object that is the blob
|
34
|
+
# @param [String] file the IO object that is the blob
|
35
|
+
def add_file(file, dsid, file_name)
|
36
|
+
mime_types = MIME::Types.of(file_name)
|
37
|
+
mime_type = mime_types.empty? ? "application/octet-stream" : mime_types.first.content_type
|
38
|
+
options = {:label=>file_name, :mimeType=>mime_type}
|
39
|
+
options[:dsid] = dsid if dsid
|
40
|
+
add_file_datastream(file, options)
|
41
|
+
set_title_and_label( file_name, :only_if_blank=>true )
|
42
|
+
end
|
43
|
+
|
44
|
+
|
29
45
|
#
|
30
46
|
# Set the collection type (e.g. hydrangea_article) for the asset
|
31
47
|
#
|
@@ -35,6 +51,7 @@ module Hydra::ModelMethods
|
|
35
51
|
prop_ds.collection_values = collection
|
36
52
|
end
|
37
53
|
end
|
54
|
+
deprecation_deprecate :set_collection_type
|
38
55
|
|
39
56
|
# Set the title and label on the current object
|
40
57
|
#
|
@@ -70,20 +87,6 @@ module Hydra::ModelMethods
|
|
70
87
|
end
|
71
88
|
end
|
72
89
|
|
73
|
-
# Call insert_contributor on the descMetadata datastream
|
74
|
-
def insert_contributor(type, opts={})
|
75
|
-
ds = self.datastreams["descMetadata"]
|
76
|
-
node, index = ds.insert_contributor(type,opts)
|
77
|
-
return node, index
|
78
|
-
end
|
79
|
-
|
80
|
-
# Call remove_contributor on the descMetadata datastream
|
81
|
-
def remove_contributor(type, index)
|
82
|
-
ds = self.datastreams["descMetadata"]
|
83
|
-
result = ds.remove_contributor(type,index)
|
84
|
-
return result
|
85
|
-
end
|
86
|
-
|
87
90
|
# Call to remove file objects
|
88
91
|
def destroy_child_assets
|
89
92
|
destroyable_child_assets.each.inject([]) do |destroyed,fo|
|
@@ -93,6 +96,8 @@ module Hydra::ModelMethods
|
|
93
96
|
end
|
94
97
|
|
95
98
|
end
|
99
|
+
deprecation_deprecate :destroy_child_assets
|
100
|
+
|
96
101
|
|
97
102
|
def destroyable_child_assets
|
98
103
|
return [] unless self.parts
|
@@ -104,9 +109,12 @@ module Hydra::ModelMethods
|
|
104
109
|
file_assets
|
105
110
|
end
|
106
111
|
end
|
112
|
+
deprecation_deprecate :destroyable_child_assets
|
107
113
|
|
108
114
|
def file_asset_count
|
109
115
|
### TODO switch to AF::Base.count
|
110
116
|
parts.length
|
111
117
|
end
|
118
|
+
deprecation_deprecate :file_asset_count
|
119
|
+
|
112
120
|
end
|
@@ -14,9 +14,7 @@ describe Hydra::Controller::UploadBehavior do
|
|
14
14
|
mock_fa = mock("file asset")
|
15
15
|
mock_file.should_receive(:original_filename).and_return(file_name)
|
16
16
|
helper.stub(:datastream_id).and_return('bar')
|
17
|
-
mock_fa.should_receive(:
|
18
|
-
mock_fa.should_receive(:set_title_and_label).with( file_name, :only_if_blank=>true )
|
19
|
-
helper.should_receive(:mime_type).with(file_name).and_return("mymimetype")
|
17
|
+
mock_fa.should_receive(:add_file).with(mock_file, 'bar', file_name)
|
20
18
|
helper.add_posted_blob_to_asset(mock_fa,mock_file) # this is the deprecated 2 argument method
|
21
19
|
end
|
22
20
|
|
@@ -26,9 +24,7 @@ describe Hydra::Controller::UploadBehavior do
|
|
26
24
|
helper.stub(:params).and_return( :Filedata=>[mock_file], :Filename=>file_name, "container_id"=>"hydrangea:2973" )
|
27
25
|
mock_fa = mock("file asset")
|
28
26
|
mock_file.should_receive(:original_filename).and_return(file_name)
|
29
|
-
mock_fa.should_receive(:
|
30
|
-
mock_fa.stub(:set_title_and_label)
|
31
|
-
helper.should_receive(:mime_type).with(file_name).and_return("mymimetype")
|
27
|
+
mock_fa.should_receive(:add_file).with(mock_file, 'content', file_name)
|
32
28
|
helper.add_posted_blob_to_asset(mock_fa,mock_file)
|
33
29
|
end
|
34
30
|
it "should support submissions from single-file uploader, defaulting to dsId of content" do
|
@@ -37,9 +33,7 @@ describe Hydra::Controller::UploadBehavior do
|
|
37
33
|
helper.stub(:params).and_return( :Filedata=>[mock_file], :container_id=>"hydrangea:2973" )
|
38
34
|
mock_file.should_receive(:original_filename).and_return(file_name)
|
39
35
|
mock_fa = mock("file asset")
|
40
|
-
|
41
|
-
mock_fa.should_receive(:add_file_datastream).with(mock_file, :label=>file_name, :mimeType=>"mymimetype", :dsid => 'content')
|
42
|
-
mock_fa.stub(:set_title_and_label)
|
36
|
+
mock_fa.should_receive(:add_file).with(mock_file, 'content', file_name)
|
43
37
|
helper.add_posted_blob_to_asset(mock_fa,mock_file)
|
44
38
|
end
|
45
39
|
end
|
@@ -10,8 +10,9 @@ describe Hydra::ModelMethods do
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
+
subject {TestModel.new }
|
14
|
+
|
13
15
|
describe "apply_depositor_metadata" do
|
14
|
-
subject {TestModel.new }
|
15
16
|
it "should add edit access" do
|
16
17
|
subject.apply_depositor_metadata('naomi')
|
17
18
|
subject.rightsMetadata.individuals.should == {'naomi' => 'edit'}
|
@@ -31,4 +32,15 @@ describe Hydra::ModelMethods do
|
|
31
32
|
subject.properties.depositor.should == ['monty']
|
32
33
|
end
|
33
34
|
end
|
35
|
+
|
36
|
+
describe 'add_file' do
|
37
|
+
it "should set the dsid, mimetype and content" do
|
38
|
+
file_name = "my_file.foo"
|
39
|
+
mock_file = "File contents"
|
40
|
+
subject.should_receive(:add_file_datastream).with(mock_file, :label=>file_name, :mimeType=>"mymimetype", :dsid=>'bar')
|
41
|
+
subject.should_receive(:set_title_and_label).with( file_name, :only_if_blank=>true )
|
42
|
+
MIME::Types.should_receive(:of).with(file_name).and_return([stub(:content_type=>"mymimetype")])
|
43
|
+
subject.add_file(mock_file, 'bar', file_name)
|
44
|
+
end
|
45
|
+
end
|
34
46
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe FileAsset do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
@file_asset = FileAsset.new
|
7
|
+
@file_asset.stub(:create_date).and_return("2008-07-02T05:09:42.015Z")
|
8
|
+
@file_asset.stub(:modified_date).and_return("2008-09-29T21:21:52.892Z")
|
9
|
+
end
|
10
|
+
|
11
|
+
it "Should be a kind of ActiveFedora::Base" do
|
12
|
+
@file_asset.should be_kind_of(ActiveFedora::Base)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should include Hydra Model Methods" do
|
16
|
+
@file_asset.class.included_modules.should include(Hydra::ModelMethods)
|
17
|
+
@file_asset.should respond_to(:apply_depositor_metadata)
|
18
|
+
end
|
19
|
+
|
20
|
+
describe 'label' do
|
21
|
+
asset = FileAsset.new
|
22
|
+
asset.label = 'image.jp2'
|
23
|
+
asset.label.should == 'image.jp2'
|
24
|
+
end
|
25
|
+
end
|
data/spec/support/Gemfile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
gem 'rails', '3.2.
|
3
|
+
gem 'rails', '3.2.11'
|
4
4
|
|
5
5
|
gem 'sqlite3'
|
6
6
|
|
@@ -9,4 +9,4 @@ gem 'blacklight'
|
|
9
9
|
gem 'hydra-access-controls', :path=>'../../../hydra-access-controls'
|
10
10
|
gem 'hydra-core', :path=>'../../', :require=>'hydra-core'
|
11
11
|
gem 'rspec-rails'
|
12
|
-
gem 'factory_girl_rails'
|
12
|
+
gem 'factory_girl_rails'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hydra-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-01-
|
13
|
+
date: 2013-01-18 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -179,7 +179,7 @@ dependencies:
|
|
179
179
|
requirements:
|
180
180
|
- - '='
|
181
181
|
- !ruby/object:Gem::Version
|
182
|
-
version: 5.
|
182
|
+
version: 5.3.0
|
183
183
|
type: :runtime
|
184
184
|
prerelease: false
|
185
185
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -187,7 +187,7 @@ dependencies:
|
|
187
187
|
requirements:
|
188
188
|
- - '='
|
189
189
|
- !ruby/object:Gem::Version
|
190
|
-
version: 5.
|
190
|
+
version: 5.3.0
|
191
191
|
- !ruby/object:Gem::Dependency
|
192
192
|
name: sqlite3
|
193
193
|
requirement: !ruby/object:Gem::Requirement
|
@@ -335,7 +335,6 @@ files:
|
|
335
335
|
- lib/generators/hydra/templates/config/role_map_production.yml
|
336
336
|
- lib/generators/hydra/templates/config/role_map_test.yml
|
337
337
|
- lib/generators/hydra/templates/config/solr.yml
|
338
|
-
- lib/generators/hydra/templates/config/solr_mappings.yml
|
339
338
|
- lib/generators/hydra/templates/fedora_conf/conf/development/fedora.fcfg
|
340
339
|
- lib/generators/hydra/templates/fedora_conf/conf/test/fedora.fcfg
|
341
340
|
- lib/generators/hydra/templates/solr_conf/conf/schema.xml
|
@@ -373,6 +372,7 @@ files:
|
|
373
372
|
- spec/lib/model_methods_spec.rb
|
374
373
|
- spec/lib/repository_controller_behavior_spec.rb
|
375
374
|
- spec/lib/solr_document_extension_spec.rb
|
375
|
+
- spec/models/file_asset_spec.rb
|
376
376
|
- spec/models/mods_asset_spec.rb
|
377
377
|
- spec/models/solr_document_spec.rb
|
378
378
|
- spec/models/user_spec.rb
|
@@ -413,6 +413,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
413
413
|
- - ! '>='
|
414
414
|
- !ruby/object:Gem::Version
|
415
415
|
version: '0'
|
416
|
+
segments:
|
417
|
+
- 0
|
418
|
+
hash: -4384136025588094224
|
416
419
|
requirements: []
|
417
420
|
rubyforge_project:
|
418
421
|
rubygems_version: 1.8.24
|
@@ -432,6 +435,7 @@ test_files:
|
|
432
435
|
- spec/lib/model_methods_spec.rb
|
433
436
|
- spec/lib/repository_controller_behavior_spec.rb
|
434
437
|
- spec/lib/solr_document_extension_spec.rb
|
438
|
+
- spec/models/file_asset_spec.rb
|
435
439
|
- spec/models/mods_asset_spec.rb
|
436
440
|
- spec/models/solr_document_spec.rb
|
437
441
|
- spec/models/user_spec.rb
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# Define additional properties for OM terms to communicate with Solrizer
|
2
|
-
# (Solrizer's use of dynamic fields to turn OM terms into Solr fields)
|
3
|
-
# example: t.my_term(:index_as=>[:searchable, :displayable])
|
4
|
-
# implies that the Solr document will have fields my_term_t and my_term_display
|
5
|
-
# if there is a value for the OM term :my_term in an object.
|
6
|
-
id: id
|
7
|
-
default: searchable
|
8
|
-
searchable:
|
9
|
-
default: _t
|
10
|
-
date: _dt
|
11
|
-
string: _t
|
12
|
-
text: _t
|
13
|
-
symbol: _s
|
14
|
-
integer: _i
|
15
|
-
long: _l
|
16
|
-
boolean: _b
|
17
|
-
float: _f
|
18
|
-
double: _d
|
19
|
-
displayable: _display
|
20
|
-
facetable: _facet
|
21
|
-
sortable: _sort
|
22
|
-
unstemmed_searchable: _unstem_search
|