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 'spec_helper' | |
describe Krikri::HarvestJob do | |
let(:activity) { create(:krikri_activity) } | |
describe '#perform' do | |
before do | |
allow_any_instance_of(Harvester).to receive(:run).and_return(true) | |
end | |
it 'retrieves an activity from the database and runs it' do |
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
Krikri::Mapper.define(:harvard) do | |
provider :class => DPLA::MAP::Agent do | |
name 'Harvard' | |
# uri # how to handle provider URIs? | |
end | |
isShownAt :class => DPLA::MAP::WebResource do | |
uri(record do |rec| | |
rec['dc:identifier'].map(&:value).select do |v| |
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 |
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
# 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
{ | |
"@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
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
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\":[], |