Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override to_enum and enum_for on RDF module? #314

Closed
cdchapman opened this issue Aug 15, 2016 · 4 comments
Closed

Override to_enum and enum_for on RDF module? #314

cdchapman opened this issue Aug 15, 2016 · 4 comments

Comments

@cdchapman
Copy link

cdchapman commented Aug 15, 2016

Currently when finding the RDF vocabulary a plain enumerator is returned from the to_enum/enum_for instead of an RDF::Enumerable::Enumerator:

pry> RDF::Vocabulary.find("http://www.w3.org/1999/02/22-rdf-syntax-ns#").to_enum
=> #<Enumerator: ...> #instead of <RDF::Enumerable::Enumerator: ...>

Might it make sense to override the root to_enum and enum_for methods in the RDF module and delegate to RDF::RDFV? The method_missing (in commit 16b995d) approach isn't delegating since these methods are not really missing 😉.

@no-reply
Copy link
Member

no-reply commented Aug 16, 2016

Are we expecting an RDF::Enumerable::Enumerator, here? That class is Queryable, responds to #each_statement, etc... while I expect Vocabulary instances to enumerate their terms.

What behavior are you looking for?

@cdchapman
Copy link
Author

I was doing some light querying over the ruby vocabularies that I have generated, and I expected that the rdf: vocabulary would behave in a way similar to the other vocabularies, i.e. provide an enumerator that I could use to load into a Dataset.

@no-reply
Copy link
Member

Ah, yes, I see what you mean.

RDF seems to behave pretty oddly across the board, as a vocab. E.g.:

 RDF::Vocabulary.find("http://www.w3.org/1999/02/22-rdf-syntax-ns#").each { |term| puts term }
=> #<Enumerator: ...>

 RDF::Vocabulary.find("http://www.w3.org/1999/02/22-rdf-syntax-ns#").each.to_a
=> [#<RDF::Vocabulary::Term:0x2ae8de101e44 URI:http://www.w3.org/1999/02/22-rdf-syntax-ns#Alt>,
 #<RDF::Vocabulary::Term:0x2ae8de1017f0 URI:http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag>,
 #<RDF::Vocabulary::Term:0x2ae8de10128c URI:http://www.w3.org/1999/02/22-rdf-syntax-ns#List>,
 #<RDF::Vocabulary::Term:0x2ae8de100d28 URI:http://www.w3.org/1999/02/22-rdf-syntax-ns#Property>,
 #<RDF::Vocabulary::Term:0x2ae8de100738 URI:http://www.w3.org/1999/02/22-rdf-syntax-ns#Seq>,
 #<RDF::Vocabulary::Term:0x2ae8de1001d4 URI:http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement>,
 #<RDF::Vocabulary::Term:0x2ae8de0ffc48 URI:http://www.w3.org/1999/02/22-rdf-syntax-ns#first>,
 #<RDF::Vocabulary::Term:0x2ae8de0ff6e4 URI:http://www.w3.org/1999/02/22-rdf-syntax-ns#object>,
 #<RDF::Vocabulary::Term:0x2ae8de0ff0f4 URI:http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate>,
 #<RDF::Vocabulary::Term:0x2ae8de0feb90 URI:http://www.w3.org/1999/02/22-rdf-syntax-ns#rest>,
 #<RDF::Vocabulary::Term:0x2ae8de0fe5a0 URI:http://www.w3.org/1999/02/22-rdf-syntax-ns#subject>,
 #<RDF::Vocabulary::Term:0x2ae8de0fe03c URI:http://www.w3.org/1999/02/22-rdf-syntax-ns#type>,
 #<RDF::Vocabulary::Term:0x2ae8de0fdab0 URI:http://www.w3.org/1999/02/22-rdf-syntax-ns#value>,
 #<RDF::Vocabulary::Term:0x2ae8de0fd54c URI:http://www.w3.org/1999/02/22-rdf-syntax-ns#HTML>,
 #<RDF::Vocabulary::Term:0x2ae8de0fcf5c URI:http://www.w3.org/1999/02/22-rdf-syntax-ns#PlainLiteral>,
 #<RDF::Vocabulary::Term:0x2ae8de0fc9f8 URI:http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral>,
 #<RDF::Vocabulary::Term:0x2ae8de0fc458 URI:http://www.w3.org/1999/02/22-rdf-syntax-ns#langString>,
 #<RDF::Vocabulary::Term:0x2ae8de0f9e4c URI:http://www.w3.org/1999/02/22-rdf-syntax-ns#>,
 #<RDF::Vocabulary::Term:0x2ae8de0f9884 URI:http://www.w3.org/1999/02/22-rdf-syntax-ns#Description>,
 #<RDF::Vocabulary::Term:0x2ae8de0f9320 URI:http://www.w3.org/1999/02/22-rdf-syntax-ns#ID>,
 #<RDF::Vocabulary::Term:0x2ae8de0f8d30 URI:http://www.w3.org/1999/02/22-rdf-syntax-ns#about>,
 #<RDF::Vocabulary::Term:0x2ae8de0f87cc URI:http://www.w3.org/1999/02/22-rdf-syntax-ns#datatype>,
 #<RDF::Vocabulary::Term:0x2ae8de0f8268 URI:http://www.w3.org/1999/02/22-rdf-syntax-ns#li>,
 #<RDF::Vocabulary::Term:0x2ae8de0f7c50 URI:http://www.w3.org/1999/02/22-rdf-syntax-ns#nil>,
 #<RDF::Vocabulary::Term:0x2ae8de0f7660 URI:http://www.w3.org/1999/02/22-rdf-syntax-ns#nodeID>,
 #<RDF::Vocabulary::Term:0x2ae8de0f70fc URI:http://www.w3.org/1999/02/22-rdf-syntax-ns#parseType>,
 #<RDF::Vocabulary::Term:0x2ae8de0f6b0c URI:http://www.w3.org/1999/02/22-rdf-syntax-ns#resource>]

@gkellogg
Copy link
Member

You might try RDF::RDFV.to_enum. But, setting this for RDF would probably not conflict with anything AFAIK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants