Sha256: 4b747d6a8105d744b739ab6b6165bacca47a55680c9ae92dfe1ce4f10f4d0095
Contents?: true
Size: 1.45 KB
Versions: 5
Compression:
Stored size: 1.45 KB
Contents
module ActiveFedora class VersionsGraph < ::RDF::Graph def all opts={} versions = fedora_versions unless opts[:include_auto_save] versions.reject! { |version| version.label.match("auto") } end versions.sort_by { |version| DateTime.parse(version.created) } rescue ArgumentError, NoMethodError raise ActiveFedora::VersionLacksCreateDate end def first all.first end def last all.last end def with_label label all.each do |version| return version if version.label == label end end def resources query(predicate: ::RDF::Vocab::Fcrepo4.hasVersion) end private class ResourceVersion attr_accessor :uri, :label, :created end def version_from_resource statement version = ResourceVersion.new version.uri = statement.object.to_s.gsub(/\/fcr:metadata$/,"") version.label = label_query(statement) version.created = created_query(statement) return version end def label_query statement query(subject: statement.object).query(predicate: ::RDF::Vocab::Fcrepo4.hasVersionLabel).first.object.to_s end def created_query statement query(subject: statement.object).query(predicate: ::RDF::Vocab::Fcrepo4.created).first.object.to_s end def fedora_versions resources.map { |statement| version_from_resource(statement) } end end end
Version data entries
5 entries across 5 versions & 1 rubygems