This file contains 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
subject.query_client.ask.whether([:s, :p, :o]).to_s | |
# => "ASK WHERE { ?s ?p ?o . }" | |
subject.query_client.ask.whether([:s, :p, :o]).true? | |
# => true | |
subject.query_client.ask.whether([:s, RDF::DC.title, 'my item']).to_s | |
# => "ASK WHERE { ?s <http://purl.org/dc/terms/title> \"my item\" . }" | |
subject.query_client.ask.whether([:s, RDF::DC.title, 'my item']).true? |
This file contains 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
require 'mime/type' #=> NameError: uninitialized constant MIME | |
require 'mime' # works fine, but then `Mime` exists and `MIME` does not |
This file contains 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
require 'factory_girl' | |
include FactoryGirl::Syntax::Methods | |
require 'dpla/map/factories' | |
agg = build(:aggregation) | |
agg.to_json | |
# => => "{\"aggregatedCHO\":[{\"alternateTitle\":[\"Stonewall Inn Graffiti\"],\"collection\":[{\"title\":[\"Diana Davies photographs, 1965-1978\"],\"description\":[\"Photographs of Diana Davies; LGBT and HIV/AIDS Activist Collections\"]}],\"contributor\":[{\"label\":[\"Norma Ford\"],\"providedLabel\":[\"Norma Ford\"],\"exactMatch\":[],\"closeMatch\":[]}],\"creator\":[{\"label\":[\"Davies, Diana (1938-)\"],\"providedLabel\":[\"Norma Ford\"],\"exactMatch\":[],\"closeMatch\":[]}],\"date\":[{\"providedLabel\":[\"1969.\"],\"begin\":[\"1969-01-01\"],\"end\":[\"1969-12-31\"]}],\"description\":[\"Window of the Stonewall Bar N.Y. 1969. The other half of the graffiti was erased by the time Diana photographed it.\"],\"extent\":[\"10x12 cm\"],\"format\":[\"Silver Gelatin Print\"],\"genre\":[{\"id\":\"http://vocab.getty.edu/aat/300132472\",\"prefLabel\":[],\"providedLabel\":[],\"exactMatch\":[], |
This file contains 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
puts agg.dump(:jsonld, {standard_prefixes: true}) | |
{ | |
"@context": { | |
"aat": "http://vocab.getty.edu/aat/", | |
"dc": "http://purl.org/dc/terms/", | |
"dc11": "http://purl.org/dc/elements/1.1/", | |
"dcmitype": "http://purl.org/dc/dcmitype/", | |
"dpla": "http://dp.la/about/map/", | |
"edm": "http://www.europeana.eu/schemas/edm/", | |
"iso_639_3": "http://lexvo.org/id/iso639-3/", |
This file contains 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
{ | |
"@context": { | |
"aat": "http://vocab.getty.edu/aat/", | |
"dc": "http://purl.org/dc/terms/", | |
"dc11": "http://purl.org/dc/elements/1.1/", | |
"dcmitype": "http://purl.org/dc/dcmitype/", | |
"dpla": "http://dp.la/about/map/", | |
"edm": "http://www.europeana.eu/schemas/edm/", | |
"iso_639_3": "http://lexvo.org/id/iso639-3/", | |
"ore": "http://www.openarchives.org/ore/terms/", |
This file contains 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
{ | |
"@context": { | |
"aat": "http://vocab.getty.edu/aat/", | |
"dc": "http://purl.org/dc/terms/", | |
"dc11": "http://purl.org/dc/elements/1.1/", | |
"dcmitype": "http://purl.org/dc/dcmitype/", | |
"dpla": "http://dp.la/about/map/", | |
"edm": "http://www.europeana.eu/schemas/edm/", | |
"iso_639_3": "http://lexvo.org/id/iso639-3/", | |
"ore": "http://www.openarchives.org/ore/terms/", |
This file contains 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
# Note: this is all pseudocode to mock up a DSL at this point. | |
# THIS IS A VERY INCOMPLETE EXAMPLE; much work to do for mods. | |
bpl_mods_mapper = Krikri::Mapper.new | |
bpl_mods_mapper.build do | |
input_format :xml # :json, :csv, :tsv others? | |
selector type: :xpath, "//record" | |
# select an XPath relative to `selector` as the default parent for mappings |
This file contains 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 Registry | |
include Singleton | |
include Enumerable | |
attr_reader :mappings | |
delegate :each, :[], :[]=, to: :mappings | |
def initialize | |
@mappings = {} | |
end |
This file contains 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
module Krikri::MappingDSL | |
module ParserMethods | |
extend ActiveSupport::Concern | |
def use_parser(parser_class) | |
@parser = parser_class | |
end | |
def record(*args) | |
raise 'No parser selected; set a parser with #use_parser(class)' unless |