This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
irb(main):034:0> original = "Dude" | |
=> "Dude" | |
irb(main):035:0> serialized = Marshal.dump(original) | |
=> "\x04\bI\"\tDude\x06:\x06ET" | |
irb(main):036:0> File.open(statefile, 'a+b') do |f| | |
irb(main):037:1* f.write serialized | |
irb(main):038:1> end | |
irb(main):039:0> data = nil | |
=> nil | |
irb(main):046:0> File.open(statefile, 'a+b') do |f| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
irb(main):034:0> original = "Dude" | |
=> "Dude" | |
irb(main):035:0> serialized = Marshal.dump(original) | |
=> "\x04\bI\"\tDude\x06:\x06ET" | |
irb(main):036:0> File.open(statefile, 'w+b') do |f| | |
irb(main):037:1* f.write serialized | |
irb(main):038:1> end | |
=> 14 | |
irb(main):039:0> File.open(statefile, 'w+b') do |f| | |
irb(main):040:1* data = f.read |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ActionView::Template::Error: | |
undefined method `each' for nil:NilClass | |
# /Users/justin/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/active-fedora-9.2.1/lib/active_fedora/associations/rdf.rb:8:in `replace' | |
# /Users/justin/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/active-fedora-9.2.1/lib/active_fedora/associations/singular_association.rb:18:in `writer' | |
# /Users/justin/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/active-fedora-9.2.1/lib/active_fedora/associations/builder/association.rb:69:in `block in define_writers' | |
# /Users/justin/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/active-fedora-9.2.1/lib/active_fedora/attributes.rb:25:in `block in attributes=' | |
# /Users/justin/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/active-fedora-9.2.1/lib/active_fedora/attributes.rb:24:in `each' | |
# /Users/justin/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/active-fedora-9.2.1/lib/active_fedora/attributes.rb:24:in `attributes=' | |
# /Users/justin/.rbenv/versions/2.2.2/lib/r |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def find_klass_for_id(id) | |
query = "id\:#{RSolr.solr_escape(id)}" | |
solr_doc = ActiveFedora::SolrService.query(query).first | |
raise ActiveFedora::ObjectNotFoundError("Unable to find '#{id}'") if solr_doc.nil? | |
klass = ActiveFedora::QueryResultBuilder.class_from_solr_document(solr_doc) | |
"#{klass}:#{id}" | |
end | |
n = 5000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Collection < ActiveFedora::Base | |
has_many :contributors, inverse_of: :contributorable, as: 'contributorable' | |
accepts_nested_attributes_for :contributors, allow_destroy: true, reject_if: proc { |attributes| attributes['contributor_name'].first.blank? } | |
end | |
class Contributor < ActiveFedora::Base | |
belongs_to :contributorable, predicate: ::RDF::URI.new('http://collections.durham.ac.uk/ns#contributor_to'), | |
class_name: 'ActiveFedora::Base' | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
../rdf/script/vocab-fetch --module-name RDFVocabularies --class-name PCDMTerms --source https://raw.githubusercontent.com/duraspace/pcdm/master/models.rdf --uri http://pcdm.org/models# | |
# -*- encoding: utf-8 -*- | |
# This file generated automatically using vocab-fetch from https://raw.githubusercontent.com/duraspace/pcdm/master/models.rdf | |
require 'rdf' | |
module RDFVocabularies | |
class PCDMTerms < RDF::StrictVocabulary("http://pcdm.org/models#") | |
HERE _:g70302983955080 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#RDF> . | |
HERE _:g70302983955080 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#RDF> . | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: utf-8 -*- | |
# This file generated automatically using vocab-fetch from https://raw.githubusercontent.com/duraspace/pcdm/master/models.rdf | |
require 'rdf' | |
module RDF | |
class RDFVocabularies::PCDMTerms < RDF::StrictVocabulary("https://raw.githubusercontent.com/duraspace/pcdm/master/models.rdf") | |
HERE _:g70104022140180 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#RDF> . | |
HERE _:g70104022140180 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#RDF> . | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ mkdir newproject | |
$ cd newproject/ | |
$ echo "source 'https://rubygems.org'" > Gemfile | |
$ echo "gem 'hydra', '7.2.0'" >> Gemfile | |
$ cat Gemfile | |
source 'https://rubygems.org' | |
gem 'hydra', '7.2.0' | |
$ bundle install | |
Fetching gem metadata from https://rubygems.org/.......... | |
Fetching version metadata from https://rubygems.org/.. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<mods:originInfo> | |
<mods:dateIssued encoding="w3cdtf" point="start" qualifier="inferred">1900</mods:dateIssued> | |
<mods:dateIssued encoding="w3cdtf" point="end" qualifier="approximate">1959</mods:dateIssued> | |
</mods:originInfo> | |
This can be modeled using EDM TimeSpan, but not EDTF. See https://github.com/europeana/corelib/wiki/EDMObjectTemplatesProviders#edmTimespan |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
query = sparql.select.where([:s, RDF::SKOS.prefLabel, "aerial photographs"]).limit(10) | |
=> #<SPARQL::Client::Query:0x3feaf0152244(SELECT * WHERE { ?s <http://www.w3.org/2004/02/skos/core#prefLabel> "aerial photographs" . } LIMIT 10)> | |
query.each_solution do |solution| | |
puts solution.inspect | |
end | |
=> [] |