jekyll-rdf 3.0.1.pre.develop.603 → 3.0.1.pre.develop.609

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: 69e331abb5f5d77a0ff200969d3a243f6de1e7cc8bce1b7c50c631b901a75e4b
4
- data.tar.gz: 90420ef9c6886f68ebb125a92db4cf45b8a61ca7af662e4665cfcd0e211f761a
3
+ metadata.gz: 60acf8bf7badc13104259acce8ef88567485c967035825d4ba45f610295876b6
4
+ data.tar.gz: '033170361298f9ea3b9c4933aff6d2c51808ef21b5cc01a352aa6d65f96ac87f'
5
5
  SHA512:
6
- metadata.gz: 75b24f1cef6ef4ba1001472b20fddf541284bd50a8ff57742032c72f4df0114dbc81306214ea4bf99a1a281f36052dfda07704946219695c4939935c6e2c1a4c
7
- data.tar.gz: dbfef75a4cb81f215148369bccd58a5c48f9a1628ac2eb851ed6b75b87d5720889a17788cd3939542d1c0620300da3ec2f1d311617d3819a15695fa7e79e9d90
6
+ metadata.gz: cf3b190598b4434f54295b1a43c2d2cedf0d5abd568f12db196e556a46140c1fc02e827daa23c2ce2c26a439de368e4594f4dcd347069de88aa3f710c8b8f7be
7
+ data.tar.gz: e980afbab5b7f38c7681fdca44223378fe2eadda3a2e12057e09b77d92b9a3b79701ab00629e3e76f0ca0e374bc55bd5c4bb7995443c9a4986f7de9f07f62328
@@ -81,6 +81,8 @@ module Jekyll
81
81
  mapper = Jekyll::RdfTemplateMapper.new(@config['instance_template_mappings'], @config['class_template_mappings'], @config['default_template'], sparql)
82
82
 
83
83
  prepare_pages(site, mapper)
84
+
85
+ mapper.print_warnings
84
86
  return true
85
87
  end
86
88
  end
@@ -30,20 +30,6 @@ module Jekyll
30
30
  #
31
31
  class RdfTemplateMapper
32
32
 
33
- ##
34
- # A Hash mapping a resource to a template name
35
- attr_accessor :resources_to_templates
36
-
37
- ##
38
- # Default template name
39
- attr_accessor :default_template
40
-
41
- ##
42
- # A Hash mapping a type resource to a template name
43
- attr_accessor :classes_to_templates
44
-
45
- attr_accessor :classResources
46
-
47
33
  include Jekyll::JekyllRdf::Helper::RdfClassExtraction
48
34
 
49
35
  ##
@@ -56,6 +42,7 @@ module Jekyll
56
42
  @default_template = default_template
57
43
  @classes_to_templates = classes_to_templates
58
44
  @classResources = {}
45
+ @warnings = {}
59
46
  create_resource_class(search_for_classes(sparql), sparql)
60
47
  assign_class_templates(classes_to_templates)
61
48
  end
@@ -65,39 +52,48 @@ module Jekyll
65
52
  #
66
53
  # Returns the template name of one of the +resource+'s types, if available. Returns the default template name otherwise.
67
54
  def map(resource)
68
- tmpl = resources_to_templates ? resources_to_templates[resource.term.to_s] : nil
55
+ tmpl = @resources_to_templates ? @resources_to_templates[resource.term.to_s] : nil
69
56
  lock = -1
70
57
  hier = -1
71
- warn_mult_templ = false
72
58
  duplicate_level_templ = []
73
- if(tmpl.nil?)
74
- resource.direct_classes.each do |classUri|
75
- classRes = classResources[classUri]
76
- if((classRes.lock <= lock || lock == -1) && !classRes.template.nil?)
77
- if(classRes.subClassHierarchyValue > hier)
78
- Jekyll.logger.info("classMapped: #{classUri} : #{resource.term.to_s} : #{classResources[classUri].template}") if Jekyll.env.eql? "development"
79
- lock = classRes.lock
80
- tmpl = classRes.template
81
- hier = classRes.subClassHierarchyValue
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
- end
88
- elsif(classRes.subClassHierarchyValue == hier)
89
- warn_mult_templ = true
90
- duplicate_level_templ.push(classRes.template)
59
+ resource.direct_classes.each do |classUri|
60
+ classRes = @classResources[classUri]
61
+ if((classRes.lock <= lock || lock == -1) && !classRes.template.nil?)
62
+ if(classRes.subClassHierarchyValue > hier)
63
+ lock = classRes.lock
64
+ tmpl = classRes.template
65
+ hier = classRes.subClassHierarchyValue
66
+ duplicate_level_templ.clear.push(tmpl)
67
+ if(classRes.multiple_templates?)
68
+ duplicate_level_templ.concat(classRes.alternativeTemplates)
91
69
  end
92
- end unless classRes.nil?
93
- end
94
- if(warn_mult_templ)
95
- Jekyll.logger.warn("Warning: multiple possible templates for #{resource.term.to_s}: #{duplicate_level_templ.uniq.join(', ')}")
96
- end
97
- end
70
+ elsif(classRes.subClassHierarchyValue == hier)
71
+ duplicate_level_templ.push(classRes.template)
72
+ end
73
+ end unless classRes.nil?
74
+ end if(tmpl.nil?)
75
+ add_warning(duplicate_level_templ.uniq, resource.iri) if (duplicate_level_templ.length > 1) && (Jekyll.env.eql? "development")
98
76
  return tmpl unless tmpl.nil?
99
- return default_template
77
+ return @default_template
78
+ end
79
+
80
+ ##
81
+ # Add a warning for a resource having multiple possible templates
82
+ # The warnings are then later displayed with print_warnings
83
+ #
84
+ def add_warning(keys, iri)
85
+ keys.sort!
86
+ key = keys.join(', ')
87
+ @warnings[key] = [] if @warnings[key].nil? # using a hash ensures that a warning is printed only once for each combination of templates
88
+ # and for each resource at most once
89
+ @warnings[key].push(iri) unless @warnings[key].include? iri
100
90
  end
101
- end
102
91
 
103
- end
92
+ def print_warnings
93
+ @warnings.delete_if{ |key, iris|
94
+ Jekyll.logger.warn("Warning: multiple possible templates for resources #{iris.join(", ")}\nPossible Templates: #{key}")
95
+ true
96
+ }
97
+ end
98
+ end # RdfTemplateMapper
99
+ end #Jekyll
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.0.1.pre.develop.603
4
+ version: 3.0.1.pre.develop.609
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: 2018-11-20 00:00:00.000000000 Z
21
+ date: 2018-11-27 00:00:00.000000000 Z
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
24
24
  name: net-http-persistent