Skip to content

Instantly share code, notes, and snippets.

@awead
Created January 14, 2015 19:47
Show Gist options
  • Select an option

  • Save awead/f8411090bd28d14ead09 to your computer and use it in GitHub Desktop.

Select an option

Save awead/f8411090bd28d14ead09 to your computer and use it in GitHub Desktop.
Using RDF::Reader with ntriples datastream
[16, 25] in /Users/awead/Projects/Github/projecthydra-labs/fedora-migrate/lib/fedora_migrate/rdf_datastream_mover.rb
16: save
17: end
18:
19: def migrate_rdf_triples
20: byebug
=> 21: target.resource << RDF::Reader.for(:ntriples).new(source.content)
22: end
23:
24: private
25:
(byebug) puts source.content
<info:fedora/sufia:xp68km39w> <http://purl.org/dc/terms/title> "Sample Migration Object A" .
<info:fedora/sufia:xp68km39w> <http://purl.org/dc/terms/creator> "Adam Wead" .
nil
(byebug) target.inspect
"#<ExampleModel::RDFProperties id: nil, title: [], creator: []>"
(byebug) target.resource.class
ExampleModel::RDFProperties::GeneratedResourceSchema
(byebug) target.resource << RDF::Reader.for(:ntriples).new(source.content)
#<ExampleModel::RDFProperties::GeneratedResourceSchema:0x3ff8198ada80(default)>
(byebug) target.inspect
"#<ExampleModel::RDFProperties id: nil, title: [], creator: []>"
(byebug) RDF::Reader.for(:ntriples).new(source.content)
#<RDF::NTriples::Reader:0x007ff032b1c978 @options={:validate=>false, :canonicalize=>false, :intern=>true, :prefixes=>{}}, @input=#<StringIO:0x007ff032b1c8b0>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment