Sha256: 4b08db72c38e816186aa75a521999ebc6d9dbd13fef940bc8aa15f187449a92c

Contents?: true

Size: 933 Bytes

Versions: 83

Compression:

Stored size: 933 Bytes

Contents

module Ddr
  module Actions
    class FixityCheck

      # Return result of fixity check - wrapped by a notifier
      def self.execute(object)
        ActiveSupport::Notifications.instrument(Ddr::Notifications::FIXITY_CHECK) do |payload|
          payload[:result] = _execute(object)
        end
      end

      # Return result of fixity check
      def self._execute(object)
        Result.new(pid: object.pid).tap do |r|
          object.datastreams_to_validate.each do |dsid, ds|
            r.success &&= ds.dsChecksumValid
            r.results[dsid] = ds.profile
          end
        end
      end

      class Result
        attr_accessor :pid, :success, :results, :checked_at

        def initialize(args={})
          @pid = args[:pid]
          @success = args[:success] || true
          @results = args[:results] || {}
          @checked_at = args[:checked_at] || Time.now.utc
        end
      end

    end
  end
end

Version data entries

83 entries across 83 versions & 1 rubygems

Version Path
ddr-models-2.1.0.rc1 lib/ddr/actions/fixity_check.rb
ddr-models-2.0.1 lib/ddr/actions/fixity_check.rb
ddr-models-2.0.0 lib/ddr/actions/fixity_check.rb
ddr-models-2.0.0.rc6 lib/ddr/actions/fixity_check.rb
ddr-models-2.0.0.rc5 lib/ddr/actions/fixity_check.rb
ddr-models-2.0.0.rc4 lib/ddr/actions/fixity_check.rb
ddr-models-2.0.0.rc3 lib/ddr/actions/fixity_check.rb
ddr-models-2.0.0.rc2 lib/ddr/actions/fixity_check.rb
ddr-models-1.17.1 lib/ddr/actions/fixity_check.rb
ddr-models-2.0.0.rc1 lib/ddr/actions/fixity_check.rb
ddr-models-2.0.0.pre.5 lib/ddr/actions/fixity_check.rb
ddr-models-1.17.0 lib/ddr/actions/fixity_check.rb
ddr-models-2.0.0.pre.4 lib/ddr/actions/fixity_check.rb
ddr-models-2.0.0.pre.3 lib/ddr/actions/fixity_check.rb
ddr-models-1.16.2 lib/ddr/actions/fixity_check.rb
ddr-models-2.0.0.pre.2 lib/ddr/actions/fixity_check.rb
ddr-models-2.0.0.pre.1 lib/ddr/actions/fixity_check.rb
ddr-models-1.16.1 lib/ddr/actions/fixity_check.rb
ddr-models-1.16.0 lib/ddr/actions/fixity_check.rb
ddr-models-1.15.0 lib/ddr/actions/fixity_check.rb