diff --git a/Gemfile.lock b/Gemfile.lock index 5cd7be01..affe4c00 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: https://github.com/ontoportal-lirmm/sparql-client.git - revision: aed51baf4106fd0f3d0e3f9238f0aad9406aa3f0 + revision: 180c818f7715baac64b2699bb452ef5c756f62c5 branch: master specs: sparql-client (1.0.1) @@ -141,8 +141,7 @@ GEM macaddr (~> 1.0) PLATFORMS - ruby - x86_64-darwin-16 + x86_64-darwin-23 x86_64-linux DEPENDENCIES @@ -164,4 +163,4 @@ DEPENDENCIES uuid BUNDLED WITH - 2.4.21 + 2.2.33 diff --git a/lib/goo/mixins/sparql_client.rb b/lib/goo/mixins/sparql_client.rb index dc2b0728..d4d98523 100644 --- a/lib/goo/mixins/sparql_client.rb +++ b/lib/goo/mixins/sparql_client.rb @@ -32,26 +32,25 @@ def validate? end end - class Literal - def to_base - text = [] - text << %("#{escape(value)}") - text << "@#{language}" if has_language? - if has_datatype? - if datatype.respond_to?:to_base - text << "^^#{datatype.to_base}" - else - text << "^^<#{datatype.to_s}>" - end - end - text.join "" - end - end - - class Literal class DateTime < Temporal FORMAT = '%Y-%m-%dT%H:%M:%S'.freeze # the format that is supported by 4store end + + def initialize(value, language: nil, datatype: nil, lexical: nil, validate: false, canonicalize: false, **options) + @object = value.freeze + @string = lexical if lexical + @string = value if !defined?(@string) && value.is_a?(String) + @string = @string.encode(Encoding::UTF_8).freeze if instance_variable_defined?(:@string) + @object = @string if instance_variable_defined?(:@string) && @object.is_a?(String) + @language = language.to_s.downcase.to_sym if language + @datatype = RDF::URI(datatype).freeze if datatype + @datatype ||= self.class.const_get(:DATATYPE) if self.class.const_defined?(:DATATYPE) + @datatype ||= instance_variable_defined?(:@language) && @language ? RDF.langString : RDF::URI("http://www.w3.org/2001/XMLSchema#string") + @original_datatype = datatype + end + + attr_reader :original_datatype end + end #end RDF