ddr-models 3.0.0.beta.12 → 3.0.0.beta.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4f083a735027958d5b91d4c88489f3fb4aa89c5d
4
- data.tar.gz: 0a23cbc2083fa5981c83b51bd1fbf886a4b98e40
3
+ metadata.gz: bd624d042a8843b603251a3e2335de11250c7cc7
4
+ data.tar.gz: 475629a158b74fcf445d2e75bc6a02df8df0eaab
5
5
  SHA512:
6
- metadata.gz: a140e0f42c7ccfceee28286980a357be7673b942b04d61ac032d8c6dd0c2f4d267318ea81f79830dce77c404c72ed2f9972efc99ae0eafe6481d10df59075454
7
- data.tar.gz: c93e6bb6856409f9ef4fdd728839fc84f41b62073df089792b8b566895aec1b4aa61b0ccd82158538ee3310891a6176a37c78919a623a78de7dbc5dabdf4e778
6
+ metadata.gz: b9b86d95736d6d52758b5c9102fba56ec686a2e6c7d2e03904d52917009b002b4e6e533c51df410d6ef6ed2922fb38c36ffe7bcdacbeb607c6f6140e26818e10
7
+ data.tar.gz: 9bc4aab3edea2950ae8115ba3948eb976cb368b2dccb513eace66fb59bc8798e4963e0aea3560a0ec093354485c7a91c9688fefc3f6d9262ded9be1874f71e70
@@ -12,7 +12,7 @@ module Ddr
12
12
  def self.call(*args)
13
13
  super do |payload|
14
14
  results = payload.delete(:results)
15
- payload[:outcome] = results.values.all? ? SUCCESS : FAILURE
15
+ payload[:outcome] = results.success? ? SUCCESS : FAILURE
16
16
  payload[:detail] = "Fixity check results:\n\n#{results}"
17
17
  end
18
18
  end
@@ -39,6 +39,7 @@ module Ddr
39
39
  autoload :FileCharacterization
40
40
  autoload :FileManagement
41
41
  autoload :FindingAid
42
+ autoload :FixityCheckResults
42
43
  autoload :Governable
43
44
  autoload :HasAdminMetadata
44
45
  autoload :HasAttachments
@@ -139,10 +139,12 @@ module Ddr::Models
139
139
  end
140
140
 
141
141
  def check_fixity
142
- results = attached_files_having_content.each_with_object({}) do |(file_id, file), memo|
143
- memo[file_id] = !!file.check_fixity
142
+ FixityCheckResults.new.tap do |results|
143
+ attached_files_having_content.each_with_object(results) do |(file_id, file), memo|
144
+ results[file_id] = !!file.check_fixity
145
+ end
146
+ notify_event(:fixity_check, results: results)
144
147
  end
145
- notify_event(:fixity_check, results: results)
146
148
  end
147
149
  alias_method :fixity_check, :check_fixity
148
150
  deprecation_deprecate :fixity_check
@@ -0,0 +1,15 @@
1
+ require 'delegate'
2
+
3
+ module Ddr::Models
4
+ class FixityCheckResults < SimpleDelegator
5
+
6
+ def initialize
7
+ super Hash.new
8
+ end
9
+
10
+ def success?
11
+ values.all?
12
+ end
13
+
14
+ end
15
+ end
@@ -7,7 +7,7 @@ module Ddr::Models
7
7
 
8
8
  included do
9
9
  def self.property_term(term)
10
- property_terms[term]
10
+ property_terms[term.to_sym]
11
11
  end
12
12
  end
13
13
 
@@ -1,5 +1,5 @@
1
1
  module Ddr
2
2
  module Models
3
- VERSION = "3.0.0.beta.12"
3
+ VERSION = "3.0.0.beta.13"
4
4
  end
5
5
  end
@@ -8,6 +8,7 @@ module Ddr::Models
8
8
  describe ".property_term" do
9
9
  it "should return the correct property term" do
10
10
  expect(described_class.property_term(:local_id)).to eq(:local_id)
11
+ expect(described_class.property_term('local_id')).to eq(:local_id)
11
12
  end
12
13
  end
13
14
 
@@ -18,6 +18,7 @@ module Ddr::Models
18
18
  describe ".property_term" do
19
19
  it "should return the correct property term" do
20
20
  expect(described_class.property_term(:subject)).to eq(:dc_subject)
21
+ expect(described_class.property_term('subject')).to eq(:dc_subject)
21
22
  end
22
23
  end
23
24
  describe "using the set_values and add_value methods" do
@@ -5,8 +5,25 @@ RSpec.shared_examples "a fixity checkable object" do
5
5
  subject.thumbnail.content = '1234567890'
6
6
  subject.save(validate: false)
7
7
  end
8
- it "can check fixity" do
8
+ specify {
9
9
  expect { subject.check_fixity }.to change(subject.fixity_checks, :count).from(0).to(1)
10
+ }
11
+ describe "results" do
12
+ let(:results) { subject.check_fixity }
13
+ specify {
14
+ expect(results).to be_success
15
+ }
16
+ specify {
17
+ expect(results[:thumbnail]).to be true
18
+ }
19
+ describe "failure" do
20
+ before {
21
+ allow(subject.thumbnail).to receive(:check_fixity) { false }
22
+ }
23
+ specify {
24
+ expect(results).not_to be_success
25
+ }
26
+ end
10
27
  end
11
28
  end
12
29
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ddr-models
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.beta.12
4
+ version: 3.0.0.beta.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Coble
@@ -537,6 +537,7 @@ files:
537
537
  - lib/ddr/models/files/fits_xml_file.rb
538
538
  - lib/ddr/models/files/structural_metadata_file.rb
539
539
  - lib/ddr/models/finding_aid.rb
540
+ - lib/ddr/models/fixity_check_results.rb
540
541
  - lib/ddr/models/governable.rb
541
542
  - lib/ddr/models/has_admin_metadata.rb
542
543
  - lib/ddr/models/has_attachments.rb