mtrudel / pragmatic_context Goto Github PK
View Code? Open in Web Editor NEWA library to declaratively add JSON-LD support to your ActiveModel objects
License: MIT License
A library to declaratively add JSON-LD support to your ActiveModel objects
License: MIT License
First off, I wanted to let you know that I'm working on ensuring compatibility between pragmatic_context and the newly minted active-triples gem. I have a branch in place with appropriate tests. Any feedback is welcome.
I'm dealing with a namespace conflict on #context between RDF::Graph and PragmaticContext::Contextualizable. They use it, of course, in very different ways and the effect is that including Contextualizable breaks my models. This may not be an issue you are interested in dealing with on your end, but I figured It couldn't hurt to make you aware of the conflict.
It's not dependent on instance attributes, and it's awkward to instantiate a model in order to produce a context document -- e.g. to serve at a URL, so that API responses can use the Link header instead of embedding the context.
This will help cleanly support @mjsuhonos' use case, namely:
{
"@id" : "http://some.uri/a_book",
"@type" : "http://schema.org/Book",
"@context" : {
"mods" : "http://www.loc.gov/mods/rdf/v1#"
},
"mods:title" : "Of Mice and Men"
}
I suspect that the DSL for this would look like:
class Resource
field :mods, :type => Hash
contextualize :mods, :as => "http://www.loc.gov/mods/rdf/v1#', :compact => true
end
Lists of objects are serialized as they appear, even when the objects within them are Contextualiziable.
I have a proposed failing test in a branch:
https://github.com/no-reply/pragmatic_context/compare/feature;lists
We have a need to serialize consistently, as leaving it to the user is error prone and not the simplest thing for many cases.
Define an as_jsonld
method in a separate mixin that builds an object consisting of contextualized terms, and properly compacts hashes where indicated.
Also, ensure that it properly walks embedded documents
Add a section to the documentation to describe the use case
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.