marcelotto / spread2rdf

DSL-based converter for spreadsheets to RDF
http://rubygems.org/gems/spread2rdf
MIT License
4 stars 2 forks source link

URL encoding in custom logic block #8

Open GitHubber1 opened 10 years ago

GitHubber1 commented 10 years ago

Hello Marcel,

so far I use own logic blocks to generate URL encoded URIs. As maybe some other people will find this helpful I decided to post it here so that you can include this snippet in an example mapping file if you wish.

column  :anycolumn, statement: :none do
          encoded_value = URI::encode(value)
          encoded_URI = RDF::URI.new("#{YOURNAMESPACE}#{encoded_value}")
          statement(subject, YOURNAMESPACE.example, encoded_URI )
end

Cheers, Andy

marcelotto commented 10 years ago

You're right, this might be so common, I'd like to make this the default, so that the following will do the same as your custom logic block:

column :anycolumn, predicate: YOURNAMESPACE.example, 
                   object: { uri: { namespace: YOURNAMESPACE } }

Currently, this performs a custom URI normalization, which was used in the context of the project Spread2RDF was developed for, but a standard URI encoding, would be a better method for the standard case. However, first I would like to find a better way to switch the normalization method used by URI construction with a specified namespace.