Closed njh closed 11 years ago
The issue is easy access to per-format information.
The content_types and file_extensions methods return all registered types for all formats, which is necessary and useful functionality, but not necessarily what you expect from those named methods. Furthermore, that functionality is mostly for the benifit of the RDF::Format.for method and probably less interesting as a public API.
As-is, f.content_type.first will give you the canonical mime type; it is overloaded as both a getter and setter, but not symmetrically as you can only get the mime types and not the extensions. (I added the overload for MY needs, which didn't include extensions!)
But maybe that is wrong and the content_types and file_extensions methods should return only the mime types and extensions for class on which the method is called, as the RDF::Format.for method doesn't actually need an accessor method for its implementation.
That would absolutely be an API breaking change, but if it is the correct change, better to get it over with sooner rather than later.
On a different tack, I greatly appreciate rigorous regulation of adding gratuitous dependencies, but I do wonder about using the mime-types gem here and having RDF::Format simply a binding of readers and writers to mime type objects from that.
Also note that the existence of a Format doesn't imply the existence of a serializer (writer). In my own use, I developed a few one-way formats (eg, importing something non-RDF into RDF, but not attempting round-trip conversion), and rdf-raptor contains a format for Graphvis which has only a writer.
John: Yes, exactly!
Another note; because RDF::Writers are auto-loaded, it isn't possible to enumerate them until they have been loaded.
Currentlly, you can do the following:
f = RDF::Format.for(:ntriples) f.content_type => ["application/n-triples", "text/plain"]
Note that f.content_types
will return all content types, as this is defined in RDF::Format.
I'll add RDF::Format#file_extension, to do the same thing.
You can get available readers or writers through RDF::Format.map(&:reader)
and writers the same way. You can then get information specific to each reader/writer.
Hello,
Please can you make it easier to enumerate the available serialisers. It is currently quite difficult to get the name, extensions and mime-type for each of the serialisers.
It would be great to be able to do this:
nick.