Re: Spira: adding gratitious separators to URIs

I just pushed spira 0.0.9, gem install and enjoy.  This one has the
supported way to do this, Spira::Resource.project.  This method is
exactly like Spira::Resource.for, except that no processing will be
done on the given identifier--you could now replace .for if you wanted
to, or use another method entirely.  .for uses it internally.  So your
simple concatenation for base_uri would be something like this
(untested):

class X
  def self.my_for(identifier, attributes = {}, &block)
    subject = RDF::URI(self.base_uri.to_s + identifier.to_s)
    self.project(subject, attributes, &block)
  end
end

No input validation is done on this identifier, so it gives you enough
power to hurt yourself.

Let me know if you have any trouble.

Ben



On Thu, Sep 30, 2010 at 12:01 AM, Christoph Badura <bad@bsd.de> wrote:
> On Tue, Sep 28, 2010 at 10:10:38PM -0500, Ben Lavender wrote:
>> Yes, something can be done about that.  For now, you could do
>> something like this, since giving a URI to Resource.for will pass it
>> through unchanged (code untested):
>
> Thanks a bunch!  That helped in several ways.
>
>> In addition, we have long RDF.rb discussions about how to add a 'smart
>> separator' that would understand this sort of thing implicitly, which
>> Spira will use.
>
> I was wondering why you did the automagic separator stuff in the first place.
>
> --chris
>
>

Received on Wednesday, 20 October 2010 14:22:45 UTC