jekyll-rdf 2.1.0.alpha.pre.171 → 2.1.0.alpha.pre.186

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
  SHA1:
3
- metadata.gz: bf67f6f007e203e27966536bdded0e5c552acbda
4
- data.tar.gz: 192c1276717719dea8f449d58113a7e05606c731
3
+ metadata.gz: 05c71bb1e8c3429261cc2f0751ce88548d7c3163
4
+ data.tar.gz: 02fef96d8ea857b7ee5363a53bfa814c0a36ae9f
5
5
  SHA512:
6
- metadata.gz: fe5f7f9cc3881a868dae0a8db88afe0df263d6b0def386921459685e59aa9bd2eecb4375a5015a90b66b4969e99cfdbc2fe87fa636f1003238f1485b2f2a939a
7
- data.tar.gz: 2917ae2a2b7852e676e484d0b1c353684296186e9e6c5443551ff99d4e2fcd414369d25a8e1451120dc8ac51227de16880d92d7bb3094780772f2d1838f7d5e7
6
+ metadata.gz: deb188f104ce4f767c84c65eea1d3a6485a7785356e67cf6ca5350f4e603e9b9685ba65555e0e23e47eaf87be902698524f37dd2b1dd39eed0995670083bbf82
7
+ data.tar.gz: 3dbaa044e5d3a5ebaf43b194cf483e031fd467038a5e25162fa6103975a4ac8e21801f68665ba2c58f724d09b80baa653b96d03d8ca0d3b271ad48aa31b01b38
@@ -64,7 +64,7 @@ module Jekyll #:nodoc:
64
64
  end
65
65
  end
66
66
 
67
- def addNecessities(site, page)
67
+ def add_necessities(site, page)
68
68
  if(site.is_a?(Jekyll::Site))
69
69
  @site ||= site
70
70
  end
@@ -113,8 +113,8 @@ module Jekyll #:nodoc:
113
113
  @filename ||= generate_file_name(domain_name, baseurl)
114
114
  end
115
115
 
116
- def directClasses
117
- @directClasses ||= begin
116
+ def direct_classes
117
+ @direct_classes ||= begin
118
118
  classes=[]
119
119
  selection = statements_as(:subject).select{ |s| s.predicate.term.to_s=="http://www.w3.org/1999/02/22-rdf-syntax-ns#type" }
120
120
  unless selection.empty?
@@ -148,30 +148,30 @@ module Jekyll #:nodoc:
148
148
  #
149
149
  def statements_as(role)
150
150
  if(!term.to_s[0..1].eql? "_:")
151
- inputURI = "<#{term.to_s}>"
151
+ input_uri = "<#{term.to_s}>"
152
152
  elsif(:predicate.eql? role)
153
153
  return []
154
154
  else
155
- inputURI = term.to_s
155
+ input_uri = term.to_s
156
156
  end
157
157
 
158
158
  case role
159
159
  when :subject
160
- query = "SELECT ?p ?o ?dt ?lit ?lang WHERE{ #{inputURI} ?p ?o BIND(datatype(?o) AS ?dt) BIND(isLiteral(?o) AS ?lit) BIND(lang(?o) AS ?lang)}"
160
+ query = "SELECT ?p ?o ?dt ?lit ?lang WHERE{ #{input_uri} ?p ?o BIND(datatype(?o) AS ?dt) BIND(isLiteral(?o) AS ?lit) BIND(lang(?o) AS ?lang)}"
161
161
  sparql.query(query).map do |solution|
162
- check = checkSolution(solution)
163
- createStatement(term.to_s, solution.p, solution.o, solution.lit, check[:lang], check[:dataType])
162
+ check = check_solution(solution)
163
+ create_statement(term.to_s, solution.p, solution.o, solution.lit, check[:lang], check[:data_type])
164
164
  end
165
165
  when :predicate
166
- query = "SELECT ?s ?o ?dt ?lit ?lang WHERE{ ?s #{inputURI} ?o BIND(datatype(?o) AS ?dt) BIND(isLiteral(?o) AS ?lit) BIND(lang(?o) AS ?lang)}"
166
+ query = "SELECT ?s ?o ?dt ?lit ?lang WHERE{ ?s #{input_uri} ?o BIND(datatype(?o) AS ?dt) BIND(isLiteral(?o) AS ?lit) BIND(lang(?o) AS ?lang)}"
167
167
  sparql.query(query).map do |solution|
168
- check = checkSolution(solution)
169
- createStatement(solution.s, term.to_s, solution.o, solution.lit, check[:lang], check[:dataType])
168
+ check = check_solution(solution)
169
+ create_statement(solution.s, term.to_s, solution.o, solution.lit, check[:lang], check[:data_type])
170
170
  end
171
171
  when :object
172
- query = "SELECT ?s ?p WHERE{ ?s ?p #{inputURI}}"
172
+ query = "SELECT ?s ?p WHERE{ ?s ?p #{input_uri}}"
173
173
  sparql.query(query).map do |solution|
174
- createStatement( solution.s, solution.p, term.to_s)
174
+ create_statement( solution.s, solution.p, term.to_s)
175
175
  end
176
176
  else
177
177
  Jekyll.logger.error "Not existing role found in #{term.to_s}"
@@ -181,25 +181,25 @@ module Jekyll #:nodoc:
181
181
 
182
182
  #checks if a query solution contains a language or type tag and returns those in a hash
183
183
  private
184
- def checkSolution(solution)
185
- result = {:lang => nil, :dataType => nil}
184
+ def check_solution(solution)
185
+ result = {:lang => nil, :data_type => nil}
186
186
  if((solution.bound?(:lang)) && (!solution.lang.to_s.eql?("")))
187
187
  result[:lang] = solution.lang.to_s.to_sym
188
188
  end
189
189
  if(solution.bound? :dt)
190
- result[:dataType] = solution.dt
190
+ result[:data_type] = solution.dt
191
191
  end
192
192
  return result
193
193
  end
194
194
 
195
195
  private
196
- def createStatement(subjectString, predicateString, objectString, isLit = nil, lang = nil, dataType = nil)
197
- subject = RDF::URI(subjectString)
198
- predicate = RDF::URI(predicateString)
199
- if(!isLit.nil?&&isLit.true?)
200
- object = RDF::Literal(objectString, language: lang, datatype: RDF::URI(dataType))
196
+ def create_statement(subject_string, predicate_string, object_string, is_lit = nil, lang = nil, data_type = nil)
197
+ subject = RDF::URI(subject_string)
198
+ predicate = RDF::URI(predicate_string)
199
+ if(!is_lit.nil?&&is_lit.true?)
200
+ object = RDF::Literal(object_string, language: lang, datatype: RDF::URI(data_type))
201
201
  else
202
- object = RDF::URI(objectString)
202
+ object = RDF::URI(object_string)
203
203
  end
204
204
  return RdfStatement.new(RDF::Statement( subject, predicate, object), @sparql, @site)
205
205
  end
@@ -47,11 +47,11 @@ module Jekyll #:nodoc:
47
47
  @alternativeTemplates = []
48
48
  end
49
49
 
50
- def multipleTemplates?
50
+ def multiple_templates?
51
51
  !@alternativeTemplates.empty?
52
52
  end
53
53
 
54
- def findDirectSubClasses
54
+ def find_direct_subclasses
55
55
  if(!@term.to_s[0..1].eql? "_:")
56
56
  term_uri = "<#{@term.to_s}>"
57
57
  else
@@ -62,26 +62,26 @@ module Jekyll #:nodoc:
62
62
  return selection
63
63
  end
64
64
 
65
- def addSubClass(resource)
65
+ def add_subclass(resource)
66
66
  @subClasses << resource
67
67
  end
68
68
 
69
- def propagateTemplate(template, lock)
69
+ def propagate_template(template, lock)
70
70
  if(@lock>lock||@lock==-1)
71
71
  @lock=lock
72
72
  @template=template
73
73
  @alternativeTemplates.clear()
74
- subClasses.each{|sub| sub.propagateTemplate(template ,lock+1)}
74
+ subClasses.each{|sub| sub.propagate_template(template ,lock+1)}
75
75
  elsif(@lock==lock)
76
76
  @alternativeTemplates.push(template)
77
- subClasses.each{|sub| sub.propagateTemplate(template ,lock+1)}
77
+ subClasses.each{|sub| sub.propagate_template(template ,lock+1)}
78
78
  end
79
79
  end
80
80
 
81
- def traverseHierarchyValue(predecessorHierarchyValue)
81
+ def traverse_hierarchy_value(predecessorHierarchyValue)
82
82
  if(@subClassHierarchyValue + 1 >= predecessorHierarchyValue) #avoid loops
83
83
  @subClassHierarchyValue += 1
84
- subClasses.each{|sub| sub.traverseHierarchyValue(@subClassHierarchyValue)}
84
+ subClasses.each{|sub| sub.traverse_hierarchy_value(@subClassHierarchyValue)}
85
85
  end
86
86
  end
87
87
  end
@@ -55,7 +55,7 @@ module Jekyll
55
55
  ##
56
56
  # Funktion stub with no funktionality. Its purpose is to keep RdfResource compatible.
57
57
  #
58
- def addNecessities (site, page)
58
+ def add_necessities (site, page)
59
59
  return self
60
60
  end
61
61
 
@@ -41,7 +41,7 @@ module Jekyll
41
41
  if((!solution.r.to_s.eql? "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil") && (finalizedContainer.add? solution.r))
42
42
  nextSequence.push solution.r.to_s
43
43
  end
44
- results.push Jekyll::Drops::RdfTerm.build_term_drop(solution.f, input.sparql, input.site).addNecessities(input.site, input.page)
44
+ results.push Jekyll::Drops::RdfTerm.build_term_drop(solution.f, input.sparql, input.site).add_necessities(input.site, input.page)
45
45
  if(nodeSequence.empty?)
46
46
  nodeSequence = nextSequence
47
47
  nextSequence = []
@@ -27,23 +27,23 @@ module Jekyll
27
27
  module RdfContainer
28
28
  include Jekyll::RdfPrefixResolver
29
29
  def rdf_container(input, type = nil)
30
- sparqlClient = input.sparql
31
- if(!(validContainer?(input, sparqlClient, type)))
30
+ sparql_client = input.sparql
31
+ if(!(valid_container?(input, sparql_client, type)))
32
32
  Jekyll.logger.error "<#{input.iri}> is not recognized as a container"
33
33
  return []
34
34
  end
35
35
  query = "SELECT ?p ?o WHERE{ <#{input.iri}> ?p ?o }"
36
- solutions = sparqlClient.query(query).each_with_object([]) {|solution, array|
36
+ solutions = sparql_client.query(query).each_with_object([]) {|solution, array|
37
37
  if((solution.p.to_s[0..43].eql? "http://www.w3.org/1999/02/22-rdf-syntax-ns#_") && (solution.p.to_s[44..-1] !~ /\D/))
38
- array << Jekyll::Drops::RdfTerm.build_term_drop(solution.o, input.sparql, input.site).addNecessities(input.site, input.page)
38
+ array << Jekyll::Drops::RdfTerm.build_term_drop(solution.o, input.sparql, input.site).add_necessities(input.site, input.page)
39
39
  end
40
40
  }
41
41
  return solutions
42
42
  end
43
- def validContainer?(input, sparqlClient, type = nil)
44
- askQuery1 = "ASK WHERE {VALUES ?o {<http://www.w3.org/1999/02/22-rdf-syntax-ns#Seq> <http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag> <http://www.w3.org/1999/02/22-rdf-syntax-ns#Alt>} <#{input.iri}> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?o}"
45
- askQuery2 = "ASK WHERE {<#{input.iri}> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?o. ?o <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Container>}"
46
- return (sparqlClient.query(askQuery1).true?) || (sparqlClient.query(askQuery2).true?)
43
+ def valid_container?(input, sparql_client, type = nil)
44
+ ask_query_1 = "ASK WHERE {VALUES ?o {<http://www.w3.org/1999/02/22-rdf-syntax-ns#Seq> <http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag> <http://www.w3.org/1999/02/22-rdf-syntax-ns#Alt>} <#{input.iri}> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?o}"
45
+ ask_query_2 = "ASK WHERE {<#{input.iri}> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?o. ?o <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Container>}"
46
+ return (sparql_client.query(ask_query_1).true?) || (sparql_client.query(ask_query_2).true?)
47
47
  end
48
48
  end
49
49
  end
@@ -46,7 +46,7 @@ module Jekyll
46
46
  begin
47
47
  result = input.sparql.query(query).map do |solution|
48
48
  hsh = solution.to_h
49
- hsh.update(hsh){ |k,v| Jekyll::Drops::RdfTerm.build_term_drop(v, input.sparql, input.site).addNecessities(input.site, input.page)}
49
+ hsh.update(hsh){ |k,v| Jekyll::Drops::RdfTerm.build_term_drop(v, input.sparql, input.site).add_necessities(input.site, input.page)}
50
50
  hsh.collect{|k,v| [k.to_s, v]}.to_h
51
51
  end
52
52
  return result
@@ -17,8 +17,8 @@ module Jekyll
17
17
  end
18
18
 
19
19
  @classResources.each{|key, value|
20
- value.findDirectSubClasses.each{|s|
21
- value.addSubClass(@classResources[s])
20
+ value.find_direct_subclasses.each{|s|
21
+ value.add_subclass(@classResources[s])
22
22
  }
23
23
  }
24
24
  end
@@ -26,8 +26,8 @@ module Jekyll
26
26
  def assign_class_templates(classes_to_templates)
27
27
  if(classes_to_templates.is_a?(Hash))
28
28
  classes_to_templates.each{|key, value|
29
- @classResources[key].propagateTemplate(value,0)
30
- @classResources[key].traverseHierarchyValue(0);
29
+ @classResources[key].propagate_template(value,0)
30
+ @classResources[key].traverse_hierarchy_value(0);
31
31
  }
32
32
  end
33
33
  end
@@ -6,18 +6,18 @@ module Jekyll
6
6
  if(entry['./'].nil?)
7
7
  if(@config['render_orphaned_uris'])
8
8
  entry.each{|name, resource|
9
- createPage(site, resource, mapper, @global_config)
9
+ create_page(site, resource, mapper, @global_config)
10
10
  }
11
11
  end
12
12
  else
13
13
  resource = entry.delete('./')
14
14
  resource.subResources = entry
15
- createPage(site, resource, mapper, @global_config)
15
+ create_page(site, resource, mapper, @global_config)
16
16
  end
17
17
  }
18
18
 
19
19
  @blanknodes.each{|resource|
20
- createPage(site, resource, mapper, @global_config)
20
+ create_page(site, resource, mapper, @global_config)
21
21
  }
22
22
  end
23
23
 
@@ -109,7 +109,7 @@ module Jekyll
109
109
  end.uniq
110
110
  end
111
111
 
112
- def createPage(site, resource, mapper, global_config)
112
+ def create_page(site, resource, mapper, global_config)
113
113
  page = RdfPageData.new(site, site.source, resource, mapper, global_config)
114
114
  if(page.complete)
115
115
  site.pages << page
@@ -38,9 +38,9 @@ module Jekyll
38
38
  def load_prefixes
39
39
  if !self.data["rdf_prefix_path"].nil?
40
40
  begin
41
- prefixFile=File.new(File.join(@base, 'rdf-data', self.data["rdf_prefix_path"].strip)).readlines
42
- self.data["rdf_prefixes"] = prefixFile.join(" ")
43
- self.data["rdf_prefix_map"] = Hash[ *(prefixFile.collect { |v|
41
+ prefix_file=File.new(File.join(@base, 'rdf-data', self.data["rdf_prefix_path"].strip)).readlines
42
+ self.data["rdf_prefixes"] = prefix_file.join(" ")
43
+ self.data["rdf_prefix_map"] = Hash[ *(prefix_file.collect { |v|
44
44
  arr = v.split(":",2)
45
45
  [arr[0][7..-1].strip, arr[1].strip[1..-2]]
46
46
  }.flatten)]
@@ -68,10 +68,10 @@ module Jekyll
68
68
  tmpl = resources_to_templates ? resources_to_templates[resource.term.to_s] : nil
69
69
  lock = -1
70
70
  hier = -1
71
- warnMultTempl = false
72
- duplicateLevelTempl = []
71
+ warn_mult_templ = false
72
+ duplicate_level_templ = []
73
73
  if(tmpl.nil?)
74
- resource.directClasses.each do |classUri|
74
+ resource.direct_classes.each do |classUri|
75
75
  classRes = classResources[classUri]
76
76
  if((classRes.lock <= lock || lock == -1) && !classRes.template.nil?)
77
77
  if(classRes.subClassHierarchyValue > hier)
@@ -79,20 +79,20 @@ module Jekyll
79
79
  lock = classRes.lock
80
80
  tmpl = classRes.template
81
81
  hier = classRes.subClassHierarchyValue
82
- warnMultTempl = false
83
- duplicateLevelTempl.clear.push(tmpl)
84
- if(classRes.multipleTemplates?)
85
- warnMultTempl = true
86
- duplicateLevelTempl.concat(classRes.alternativeTemplates)
82
+ warn_mult_templ = false
83
+ duplicate_level_templ.clear.push(tmpl)
84
+ if(classRes.multiple_templates?)
85
+ warn_mult_templ = true
86
+ duplicate_level_templ.concat(classRes.alternativeTemplates)
87
87
  end
88
88
  elsif(classRes.subClassHierarchyValue == hier)
89
- warnMultTempl = true
90
- duplicateLevelTempl.push(classRes.template)
89
+ warn_mult_templ = true
90
+ duplicate_level_templ.push(classRes.template)
91
91
  end
92
92
  end unless classRes.nil?
93
93
  end
94
- if(warnMultTempl)
95
- Jekyll.logger.warn("Warning: multiple possible templates for #{resource.term.to_s}: #{duplicateLevelTempl.uniq.join(', ')}")
94
+ if(warn_mult_templ)
95
+ Jekyll.logger.warn("Warning: multiple possible templates for #{resource.term.to_s}: #{duplicate_level_templ.uniq.join(', ')}")
96
96
  end
97
97
  end
98
98
  return tmpl unless tmpl.nil?
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: 2.1.0.alpha.pre.171
4
+ version: 2.1.0.alpha.pre.186
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elias Saalmann
@@ -16,7 +16,7 @@ authors:
16
16
  autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
- date: 2017-07-03 00:00:00.000000000 Z
19
+ date: 2017-07-14 00:00:00.000000000 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: linkeddata
@@ -190,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
190
190
  version: 1.3.1
191
191
  requirements: []
192
192
  rubyforge_project:
193
- rubygems_version: 2.6.12
193
+ rubygems_version: 2.4.5
194
194
  signing_key:
195
195
  specification_version: 4
196
196
  summary: Hypertext Publication System for Templated Resource Rendering