curation_concerns-models 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/actors/curation_concerns/base_actor.rb +1 -5
- data/app/jobs/active_fedora_id_based_job.rb +1 -1
- data/app/models/concerns/curation_concerns/collection_behavior.rb +1 -15
- data/app/models/concerns/curation_concerns/file_set/derivatives.rb +12 -1
- data/app/models/concerns/curation_concerns/human_readable_type.rb +1 -5
- data/app/models/concerns/curation_concerns/work_behavior.rb +0 -4
- data/app/services/curation_concerns/derivative_path.rb +21 -4
- data/app/services/curation_concerns/file_set_audit_service.rb +1 -1
- data/app/services/curation_concerns/lock_manager.rb +2 -5
- data/curation_concerns-models.gemspec +1 -1
- data/lib/curation_concerns/models/utils.rb +2 -2
- data/lib/curation_concerns/models/version.rb +1 -1
- data/lib/generators/curation_concerns/models/abstract_migration_generator.rb +5 -5
- data/lib/generators/curation_concerns/models/clamav_generator.rb +2 -2
- data/lib/generators/curation_concerns/models/install_generator.rb +2 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ee33d07e558f4b7b09fdfc143622e41c840deb7
|
4
|
+
data.tar.gz: b369d41f6e0e124d635812208b2b0c922d4626c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8fd340a961cbcc0930b8344acd29d6aaad67ebe307db9bc3993e167ac72c4a81325ac10ab5c42ed8fb3399238eb7504cfd61df923857c854f79d9f313ca2302
|
7
|
+
data.tar.gz: 0841f2b19fc34d54970627258bb62ff4d8ab0c1f8fc3181209a9f80f3f8b106b788b96c698f511fb885cfd080dee01d97fea95641a27a1708ee67a102a8bef49
|
@@ -70,11 +70,7 @@ module CurationConcerns
|
|
70
70
|
# => { 'title' => ['first', 'second'] }
|
71
71
|
def remove_blank_attributes!
|
72
72
|
multivalued_form_attributes.each_with_object(attributes) do |(k, v), h|
|
73
|
-
|
74
|
-
h[k] = v.select(&:present?)
|
75
|
-
else
|
76
|
-
h[k] = v
|
77
|
-
end
|
73
|
+
h[k] = v.instance_of?(Array) ? v.select(&:present?) : v
|
78
74
|
end
|
79
75
|
end
|
80
76
|
|
@@ -13,20 +13,10 @@ module CurationConcerns
|
|
13
13
|
validates :title, presence: true
|
14
14
|
end
|
15
15
|
|
16
|
-
def add_member(collectible)
|
17
|
-
return unless can_add_to_members?(collectible)
|
18
|
-
members << collectible
|
19
|
-
save
|
20
|
-
end
|
21
|
-
|
22
16
|
def to_s
|
23
17
|
title.present? ? title : 'No Title'
|
24
18
|
end
|
25
19
|
|
26
|
-
def can_be_member_of_collection?(collection)
|
27
|
-
collection != self
|
28
|
-
end
|
29
|
-
|
30
20
|
module ClassMethods
|
31
21
|
def indexer
|
32
22
|
CurationConcerns::CollectionIndexer
|
@@ -61,16 +51,12 @@ module CurationConcerns
|
|
61
51
|
# Field name to look up when locating the size of each file in Solr.
|
62
52
|
# Override for your own installation if using something different
|
63
53
|
def file_size_field
|
64
|
-
Solrizer.solr_name(:file_size, FileSetIndexer::STORED_INTEGER)
|
54
|
+
Solrizer.solr_name(:file_size, CurationConcerns::FileSetIndexer::STORED_INTEGER)
|
65
55
|
end
|
66
56
|
|
67
57
|
# Solr field name collections and works use to index member ids
|
68
58
|
def member_ids_field
|
69
59
|
Solrizer.solr_name('member_ids', :symbol)
|
70
60
|
end
|
71
|
-
|
72
|
-
def can_add_to_members?(collectible)
|
73
|
-
collectible.try(:can_be_member_of_collection?, self)
|
74
|
-
end
|
75
61
|
end
|
76
62
|
end
|
@@ -7,6 +7,7 @@ module CurationConcerns
|
|
7
7
|
Hydra::Derivatives.source_file_service = CurationConcerns::LocalFileService
|
8
8
|
Hydra::Derivatives.output_file_service = CurationConcerns::PersistDerivatives
|
9
9
|
Hydra::Derivatives::FullTextExtract.output_file_service = CurationConcerns::PersistDirectlyContainedOutputFileService
|
10
|
+
after_destroy :cleanup_derivatives
|
10
11
|
end
|
11
12
|
|
12
13
|
# This completely overrides the version in Hydra::Works so that we
|
@@ -46,9 +47,19 @@ module CurationConcerns
|
|
46
47
|
# The destination_name parameter has to match up with the file parameter
|
47
48
|
# passed to the DownloadsController
|
48
49
|
def derivative_url(destination_name)
|
49
|
-
path =
|
50
|
+
path = derivative_path_factory.derivative_path_for_reference(self, destination_name)
|
50
51
|
URI("file://#{path}").to_s
|
51
52
|
end
|
53
|
+
|
54
|
+
def cleanup_derivatives
|
55
|
+
derivative_path_factory.derivatives_for_reference(self).each do |path|
|
56
|
+
FileUtils.rm_f(path)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def derivative_path_factory
|
61
|
+
DerivativePath
|
62
|
+
end
|
52
63
|
end
|
53
64
|
end
|
54
65
|
end
|
@@ -3,14 +3,10 @@ module CurationConcerns
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
included do
|
6
|
-
class_attribute :
|
6
|
+
class_attribute :human_readable_type
|
7
7
|
self.human_readable_type = name.demodulize.titleize
|
8
8
|
end
|
9
9
|
|
10
|
-
def human_readable_type
|
11
|
-
self.class.human_readable_type
|
12
|
-
end
|
13
|
-
|
14
10
|
def to_solr(solr_doc = {})
|
15
11
|
super(solr_doc).tap do |doc|
|
16
12
|
doc[Solrizer.solr_name('human_readable_type', :facetable)] = human_readable_type
|
@@ -7,16 +7,33 @@ module CurationConcerns
|
|
7
7
|
derivative_path(object, extension_for(destination_name), destination_name)
|
8
8
|
end
|
9
9
|
|
10
|
+
# @return [Array<String>] Array of paths to derivatives for this object.
|
11
|
+
def derivatives_for_reference(object)
|
12
|
+
Dir.glob(root_path(object).join("*")).select do |path|
|
13
|
+
path.start_with?(path_prefix(object).to_s)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
10
17
|
private
|
11
18
|
|
19
|
+
# @param [#id] object Object whose ID is used to generate root path
|
20
|
+
# @return [String] Returns the root path where derivatives will be generated into.
|
21
|
+
def root_path(object)
|
22
|
+
Pathname.new(derivative_path(object, "", "")).dirname
|
23
|
+
end
|
24
|
+
|
25
|
+
# @return <Pathname> Full prefix of the path for object.
|
26
|
+
def path_prefix(object)
|
27
|
+
Pathname.new(CurationConcerns.config.derivatives_path).join(pair_path(object.id))
|
28
|
+
end
|
29
|
+
|
12
30
|
def derivative_path(object, extension, destination_name)
|
13
31
|
file_name = destination_name + extension
|
14
|
-
|
32
|
+
"#{path_prefix(object)}-#{file_name}"
|
15
33
|
end
|
16
34
|
|
17
|
-
def pair_path(id
|
18
|
-
|
19
|
-
"#{pair}-#{file_name}"
|
35
|
+
def pair_path(id)
|
36
|
+
id.split('').each_slice(2).map(&:join).join('/')
|
20
37
|
end
|
21
38
|
|
22
39
|
def extension_for(destination_name)
|
@@ -19,7 +19,7 @@ module CurationConcerns
|
|
19
19
|
# Use this when a file_set is loaded from solr instead of fedora
|
20
20
|
def logged_audit_status
|
21
21
|
audit_results = ChecksumAuditLog.logs_for(file_set.id, "original_file")
|
22
|
-
|
22
|
+
.collect { |result| result["pass"] }
|
23
23
|
|
24
24
|
if audit_results.length > 0
|
25
25
|
stat_to_string(audit_results.reduce(true) { |sum, value| sum && value })
|
@@ -17,11 +17,8 @@ module CurationConcerns
|
|
17
17
|
def lock(key)
|
18
18
|
returned_from_block = nil
|
19
19
|
client.lock(key, @ttl) do |locked|
|
20
|
-
|
21
|
-
|
22
|
-
else
|
23
|
-
raise UnableToAcquireLockError
|
24
|
-
end
|
20
|
+
raise UnableToAcquireLockError unless locked
|
21
|
+
returned_from_block = yield
|
25
22
|
end
|
26
23
|
returned_from_block
|
27
24
|
end
|
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
22
|
spec.add_dependency 'active_attr'
|
23
|
-
spec.add_dependency 'hydra-collections', '~>
|
23
|
+
spec.add_dependency 'hydra-collections', '~> 7.0'
|
24
24
|
spec.add_dependency 'hydra-head', '~> 9.3'
|
25
25
|
spec.add_dependency 'hydra-works', '~> 0.6'
|
26
26
|
spec.add_dependency 'active_fedora-noid', '~> 1.0'
|
@@ -7,12 +7,12 @@ module CurationConcerns
|
|
7
7
|
end
|
8
8
|
|
9
9
|
module ClassMethods
|
10
|
-
def retry_unless(number_of_tries, condition, &
|
10
|
+
def retry_unless(number_of_tries, condition, &_block)
|
11
11
|
fail ArgumentError, 'First argument must be an enumerator' unless number_of_tries.is_a? Enumerator
|
12
12
|
fail ArgumentError, 'Second argument must be a lambda' unless condition.respond_to? :call
|
13
13
|
fail ArgumentError, 'Must pass a block of code to retry' unless block_given?
|
14
14
|
number_of_tries.each do
|
15
|
-
result =
|
15
|
+
result = yield
|
16
16
|
return result unless condition.call
|
17
17
|
end
|
18
18
|
fail 'retry_unless could not complete successfully. Try upping the # of tries?'
|
@@ -12,11 +12,11 @@ class CurationConcerns::Models::AbstractMigrationGenerator < Rails::Generators::
|
|
12
12
|
@prev_migration_nr += 1
|
13
13
|
else
|
14
14
|
last_migration = Dir[File.join(path, '*.rb')].sort.last
|
15
|
-
if last_migration
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
@prev_migration_nr = if last_migration
|
16
|
+
last_migration.sub(File.join(path, '/'), '').to_i + 1
|
17
|
+
else
|
18
|
+
Time.now.utc.strftime('%Y%m%d%H%M%S').to_i
|
19
|
+
end
|
20
20
|
end
|
21
21
|
@prev_migration_nr.to_s
|
22
22
|
end
|
@@ -4,10 +4,10 @@ require 'rails/generators'
|
|
4
4
|
class CurationConcerns::Models::ClamavGenerator < Rails::Generators::Base
|
5
5
|
source_root File.expand_path('../templates', __FILE__)
|
6
6
|
|
7
|
-
desc '
|
7
|
+
desc '
|
8
8
|
This generator makes the following changes to your application:
|
9
9
|
1. Generates clamav initializer
|
10
|
-
|
10
|
+
'
|
11
11
|
|
12
12
|
def banner
|
13
13
|
say_status('info', 'Generating clamav initializers', :blue)
|
@@ -3,12 +3,12 @@ require_relative 'abstract_migration_generator'
|
|
3
3
|
class CurationConcerns::Models::InstallGenerator < CurationConcerns::Models::AbstractMigrationGenerator
|
4
4
|
source_root File.expand_path('../templates', __FILE__)
|
5
5
|
argument :model_name, type: :string, default: 'user'
|
6
|
-
desc '
|
6
|
+
desc '
|
7
7
|
This generator makes the following changes to your application:
|
8
8
|
1. Creates several database migrations if they do not exist in /db/migrate
|
9
9
|
2. Creates the curation_concerns.rb configuration file and several others
|
10
10
|
3. Creates the file_set.rb and collection.rb models
|
11
|
-
|
11
|
+
'
|
12
12
|
def banner
|
13
13
|
say_status('warning', 'GENERATING CURATION_CONCERNS MODELS', :yellow)
|
14
14
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: curation_concerns-models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Coyne
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_attr
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: '7.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: '7.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: hydra-head
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|