jekyll-rdf 3.1.1.pre.develop.697 → 3.1.1.pre.develop.701

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0df71262a3cb32f351e2cd86b821f497b0d70a6701e24012baaac776fc623523
4
- data.tar.gz: cba35d82cdc9b05a65811495ad481f601279b03d00bf07cf04de77d89184c3a0
3
+ metadata.gz: 37ec15b87ba7bc0fb5aa7a6e32ef22708d6e88ecb098a2b755a0c85108a77e19
4
+ data.tar.gz: f0f21d0e340c2b66dd7ae57645edfdc21c187a66267214cebbf95ba63c9a54b0
5
5
  SHA512:
6
- metadata.gz: d3e3ba14100631011af810209b08788d5962a80b8eae0defce5efd8fcb8aeb8ae580b3ddd91f5bc6079742cf1ebdaa043f28d3766b28d74fb2c8376c6fc7c2f5
7
- data.tar.gz: 17c1f88406f591e4dc3f1bb6c8d3ccc1f5f3e56e0b3a455fafe34d5d99c34b69047e095acaaff8d88741f6a95a5436d785372960a8cfd53719bc23658daaa386
6
+ metadata.gz: 7510df3def5f91ba7e0c03dbe0376a119ed0f625aa8d07bbec15012a4725ce4ef1b8c1259261e47bee8821123c39f5c6572152fa76f038518900eb88f69221a3
7
+ data.tar.gz: 0b38e389cfd959ec21e98e76f8e4a19773349a27058de8db7d9d393575b987f2de1bb290717a2067dab5db9e325acc30e407968839750d80386068e9981a691f
@@ -42,11 +42,6 @@ module Jekyll #:nodoc:
42
42
  #
43
43
  attr_accessor :page
44
44
 
45
- ##
46
- #
47
- #
48
- attr_reader :covered
49
-
50
45
  ##
51
46
  #
52
47
  #
@@ -55,7 +50,7 @@ module Jekyll #:nodoc:
55
50
  ##
56
51
  #
57
52
  #
58
- def initialize(term, site = nil, page = nil, covered = false)
53
+ def initialize(term, site = nil, page = nil)
59
54
  super(term)
60
55
  if(site.is_a?(Jekyll::Site))
61
56
  @site = site
@@ -64,7 +59,6 @@ module Jekyll #:nodoc:
64
59
  @page = page
65
60
  end
66
61
  @subResources = {}
67
- @covered = covered
68
62
  @iri = term.to_s
69
63
  @blank = false
70
64
  begin
@@ -87,6 +81,20 @@ module Jekyll #:nodoc:
87
81
  return (@site.is_a?(Jekyll::Site)||@page.is_a?(Jekyll::Page))
88
82
  end
89
83
 
84
+ ##
85
+ # Returns true if the resource base containes this resource
86
+ #
87
+ def covered
88
+ return @covered unless @covered.nil?
89
+ ask_exist = "ASK WHERE {{#{term.to_ntriples} ?p ?o}UNION{?s #{term.to_ntriples} ?o}UNION{?s ?p #{term.to_ntriples}}} "
90
+ @covered = Jekyll::JekyllRdf::Helper::RdfHelper::sparql.query(ask_exist)
91
+ if(@covered.instance_of? RDF::Literal::Boolean)
92
+ @covered = @covered.true?
93
+ else
94
+ @covered = false || @covered #take care of compatibility with virtuoso
95
+ end
96
+ end
97
+
90
98
  ##
91
99
  # Return a list of Jekyll::JekyllRdf::Drops::RdfStatements whose subject, predicate or object is the RDF resource represented by the receiver
92
100
  #
@@ -90,7 +90,7 @@ module Jekyll
90
90
  def self.build_term_drop(term, site, covered)
91
91
  case term
92
92
  when RDF::URI, RDF::Node
93
- return RdfResource.new(term, site, nil, covered)
93
+ return Jekyll::JekyllRdf::Helper::RdfHelper.resources(term)
94
94
  when RDF::Literal
95
95
  return RdfLiteral.new(term)
96
96
  else
@@ -36,14 +36,7 @@ module Jekyll
36
36
  request_uri = to_string_wrap(rdf_page_to_resource(request_uri))
37
37
  return unless valid_resource?(request_uri) && (!request_uri[0..1].eql? "_:")
38
38
  request_uri = rdf_resolve_prefix(request_uri)
39
- ask_exist = "ASK WHERE {{#{request_uri} ?p ?o}UNION{?s #{request_uri} ?o}UNION{?s ?p #{request_uri}}} "
40
- exists = Jekyll::JekyllRdf::Helper::RdfHelper::sparql.query(ask_exist)
41
- if(exists.instance_of? RDF::Literal::Boolean)
42
- exists = exists.true?
43
- else
44
- exists = false || exists #take care of compatibility with virtuoso
45
- end
46
- Jekyll::JekyllRdf::Drops::RdfResource.new(RDF::URI(request_uri[1..-2]), Jekyll::JekyllRdf::Helper::RdfHelper::site, Jekyll::JekyllRdf::Helper::RdfHelper::page, exists)
39
+ Jekyll::JekyllRdf::Helper::RdfHelper.resources(request_uri[1..-2])
47
40
  end
48
41
  end
49
42
  end
@@ -74,7 +74,7 @@ module Jekyll
74
74
  query = "SELECT ?s WHERE{ ?s #{predicate} #{n_triples} }"
75
75
  result = client.query(query).map do |solution|
76
76
  subject = RDF::URI(solution.s)
77
- Jekyll::JekyllRdf::Drops::RdfResource.new(subject, Jekyll::JekyllRdf::Helper::RdfHelper::site, Jekyll::JekyllRdf::Helper::RdfHelper::page, true)
77
+ Jekyll::JekyllRdf::Helper::RdfHelper.resources(subject)
78
78
  end
79
79
  else
80
80
  query = "SELECT ?o ?dt ?lit ?lang WHERE{ #{n_triples} #{predicate} ?o BIND(datatype(?o) AS ?dt) BIND(isLiteral(?o) AS ?lit) BIND(lang(?o) AS ?lang) #{lang_query} }"
@@ -95,7 +95,7 @@ module Jekyll
95
95
  result = Jekyll::JekyllRdf::Drops::RdfLiteral.new(object)
96
96
  else
97
97
  object = RDF::URI(solution.o)
98
- result = Jekyll::JekyllRdf::Drops::RdfResource.new(object, Jekyll::JekyllRdf::Helper::RdfHelper::site, Jekyll::JekyllRdf::Helper::RdfHelper::page, true)
98
+ result = Jekyll::JekyllRdf::Helper::RdfHelper.resources(object)
99
99
  end
100
100
  return result
101
101
  end
@@ -32,6 +32,9 @@ module Jekyll
32
32
  module RdfHelper
33
33
  @@prefixes = {}
34
34
  @@usePage = false
35
+ @@resources = {}
36
+ @@site = nil
37
+ @@page = nil
35
38
 
36
39
  def self.sparql= sparql
37
40
  @@sparql = sparql
@@ -105,8 +108,32 @@ module Jekyll
105
108
  def self.pathiri
106
109
  @@baseiri
107
110
  end
108
- end
109
111
 
110
- end
111
- end
112
- end
112
+ ##
113
+ # Constructs and returns a Jekyll::JekyllRdf::Drops::RdfResource. If the
114
+ # uri refers to an already created resource, this method wont create a
115
+ # new resource.
116
+ #
117
+ def self.resources uri
118
+ resource = @@resources[uri.to_s]
119
+ if resource.nil?
120
+ resource = Jekyll::JekyllRdf::Drops::RdfResource.new(RDF::URI(uri.to_s), @@site, @@page)
121
+ @@resources[uri.to_s] = resource
122
+ end
123
+ return resource
124
+ end
125
+
126
+ ##
127
+ # resets RdfHelper to its initialization values
128
+ #
129
+ def self.reinitialize
130
+ @@prefixes.clear
131
+ @@usePage = false
132
+ @@resources.clear
133
+ @@site = nil
134
+ @@page = nil
135
+ end
136
+ end #RdfHelper
137
+ end #Helper
138
+ end #JekyllRdf
139
+ end #Jekyll
@@ -20,7 +20,7 @@ module Jekyll
20
20
  @pageResources={};
21
21
  @blanknodes=[]
22
22
  resources.each do |uri|
23
- resource = Jekyll::JekyllRdf::Drops::RdfResource.new(uri, nil, nil, true)
23
+ resource = Jekyll::JekyllRdf::Helper::RdfHelper.resources(uri)
24
24
  if(uri.instance_of? RDF::URI)
25
25
  uriString = uri.to_s
26
26
  if((uriString.include? "#") && (uriString.index("#") < (uriString.length - 1))) #sorting in uris with a #
@@ -41,7 +41,7 @@ module Jekyll
41
41
  end
42
42
  # give parents to orphaned resources
43
43
  @pageResources.each_key{|key|
44
- @pageResources[key]['./'] = Jekyll::JekyllRdf::Drops::RdfResource.new(RDF::URI(key)) if @pageResources[key]['./'].nil?
44
+ @pageResources[key]['./'] = Jekyll::JekyllRdf::Helper::RdfHelper.resources(key) if @pageResources[key]['./'].nil?
45
45
  }
46
46
  end
47
47
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-rdf
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.1.pre.develop.697
4
+ version: 3.1.1.pre.develop.701
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elias Saalmann
@@ -18,7 +18,7 @@ authors:
18
18
  autorequire:
19
19
  bindir: bin
20
20
  cert_chain: []
21
- date: 2019-03-05 00:00:00.000000000 Z
21
+ date: 2019-03-12 00:00:00.000000000 Z
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
24
24
  name: net-http-persistent