jekyll-rdf 3.0.0.pre.develop.485 → 3.0.0.pre.develop.492

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 40d322354f39315a2878094d864daf1e35bf3d54e655ff2c19c05e8c98fc8e99
4
- data.tar.gz: d8334ac5308962db090fceae39ebaa600b64cf66d66733a84a5bdf3db8495239
3
+ metadata.gz: bab304764598a48c7c06c699b54cba89ec90ca556b71c9a33c6177e9abd671f7
4
+ data.tar.gz: 20d2ce470b77d909bb977414bdffcc8a6c4f6a175298665618e0aed2d3abe9a8
5
5
  SHA512:
6
- metadata.gz: f487edc4b85b19acfc341952748271cb97126ebef37a3067a30423b0a427883722f9124f37d3fa8b0d5b85bae6b6fb850297d412399db269d54c33afaef99044
7
- data.tar.gz: b05b421d4d276b4532797ad62a21790a1972f71bf2e5132f9ba5b19c6e5a16769059b7ed07dd4043584ecaa6afaa3b09d9a6974ae3a61f5376ede8481121320f
6
+ metadata.gz: dc9d18faac569d8aa60240d38725316cd1fb8b5483fdd2a939f80bb46017aea8f328a6aca7e076cdcdda35e3ef4a476db227bdc0799a3c506db79f4e393df360
7
+ data.tar.gz: 95cec3ca98dbf963357a2da339f3f86d85ab3d98b3583e0d394317e84f219f4f6892bc088d2cc490d354683dee3eb367572baa02470c28b1e9e92a34b3b396d8
data/lib/jekyll-rdf.rb CHANGED
@@ -33,6 +33,11 @@ require 'set'
33
33
  require 'addressable/uri'
34
34
  require 'pp'
35
35
 
36
+ require 'jekyll/helper/rdf_types'
37
+ require 'jekyll/types/XsdInteger'
38
+ require 'jekyll/types/XsdDecimal'
39
+ require 'jekyll/types/XsdDouble'
40
+ require 'jekyll/types/XsdBoolean'
36
41
  require 'jekyll/drops/rdf_term'
37
42
  require 'jekyll/drops/rdf_statement'
38
43
  require 'jekyll/drops/rdf_literal'
@@ -56,6 +61,7 @@ require 'jekyll/filters/rdf_get'
56
61
  require 'jekyll/filters/rdf_message'
57
62
  require 'jekyll/filters/rdf_page_to_resource'
58
63
 
64
+
59
65
  Liquid::Template.register_filter(Jekyll::JekyllRdf::Filter)
60
66
  require 'jekyll/rdf_main_generator'
61
67
  require 'jekyll/rdf_template_mapper'
@@ -42,8 +42,16 @@ module Jekyll
42
42
  ##
43
43
  # Return literal value to allow liquid filters to compute
44
44
  # rdf literals as well
45
+ # source: https://github.com/eccenca/jekyll-rdf/commit/704dd98c5e457a81e97fcd011562f1f39fc3f813
45
46
  #
46
47
  def to_liquid
48
+ # Convert scientific notation
49
+
50
+ term_str = term.to_s
51
+ if(term.has_datatype?)
52
+ custom_type = Jekyll::JekyllRdf::Helper::Types::find(term.datatype)
53
+ return custom_type.to_type term_str if (!custom_type.nil?) && (custom_type.match? term_str)
54
+ end
47
55
  return term.to_s
48
56
  end
49
57
 
@@ -0,0 +1,47 @@
1
+ ##
2
+ # MIT License
3
+ #
4
+ # Copyright (c) 2017 Sebastian Zänker
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ # of this software and associated documentation files (the "Software"), to deal
8
+ # in the Software without restriction, including without limitation the rights
9
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ # copies of the Software, and to permit persons to whom the Software is
11
+ # furnished to do so, subject to the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be included in all
14
+ # copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ # SOFTWARE.
23
+ #
24
+
25
+ module Jekyll
26
+ module JekyllRdf
27
+ module Helper
28
+
29
+ ##
30
+ # Internal module for registering custom types
31
+ #
32
+ module Types
33
+ @@types = []
34
+ def self.register type
35
+ @@types.push type
36
+ end
37
+
38
+ def self.find type
39
+ index = @@types.find_index {|x| x === type.to_s}
40
+ return @@types[index] unless index.nil?
41
+ return nil
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+
@@ -0,0 +1,33 @@
1
+ module Jekyll
2
+ module JekyllRdf
3
+ module Types
4
+ class XsdBoolean
5
+ @@class_uri = "http://www.w3.org/2001/XMLSchema#boolean"
6
+
7
+ def self.match? string
8
+ return regex.match string
9
+ end
10
+
11
+ def self.regex
12
+ @@regex ||= /^\b1|\b0|\btrue|\bfalse$/
13
+ return @@regex
14
+ end
15
+
16
+ def self.to_type string
17
+ return "TRUE".eql?(string).to_s
18
+ end
19
+
20
+ def self.=== other
21
+ return other.to_s.eql? @@class_uri
22
+ end
23
+
24
+ def self.to_s
25
+ return @@class_uri
26
+ end
27
+ end
28
+
29
+ Jekyll::JekyllRdf::Helper::Types::register XsdBoolean
30
+ end
31
+ end
32
+
33
+ end
@@ -0,0 +1,33 @@
1
+ module Jekyll
2
+ module JekyllRdf
3
+ module Types
4
+ class XsdDecimal
5
+ @@class_uri = "http://www.w3.org/2001/XMLSchema#decimal"
6
+
7
+ def self.match? string
8
+ return regex.match string
9
+ end
10
+
11
+ def self.regex
12
+ @@regex ||= /^[+-]?[0-9]*\.[0-9]+$/
13
+ return @@regex
14
+ end
15
+
16
+ def self.to_type string
17
+ return string.to_f.to_s
18
+ end
19
+
20
+ def self.=== other
21
+ return other.to_s.eql? @@class_uri
22
+ end
23
+
24
+ def self.to_s
25
+ return @@class_uri
26
+ end
27
+ end
28
+
29
+ Jekyll::JekyllRdf::Helper::Types::register XsdDecimal
30
+ end
31
+ end
32
+
33
+ end
@@ -0,0 +1,46 @@
1
+ module Jekyll
2
+ module JekyllRdf
3
+ module Types
4
+ class XsdDouble
5
+ @@class_uri = "http://www.w3.org/2001/XMLSchema#double"
6
+
7
+ def self.match? string
8
+ return regex.match string.upcase
9
+ end
10
+
11
+ def self.regex
12
+ @@regex ||= /^[+-]?[0-9]+\.(\d+)E[+-]?(\d+)$/
13
+ return @@regex
14
+ end
15
+
16
+ def self.to_type string
17
+ string = string.upcase
18
+ number = string.to_f
19
+ negative = number < 0
20
+ if negative
21
+ number = number * (-1)
22
+ end
23
+ e = [-1 * (Math.log10(number).floor - (string.to_s.index('E') - string.to_s.index('.'))), 0].max
24
+ vz = ""
25
+ if negative
26
+ vz = "-"
27
+ end
28
+
29
+ result = vz.to_s + sprintf("%." + e.to_s + "f", number)
30
+ return result
31
+ end
32
+
33
+ def self.=== other
34
+ return other.to_s.eql? @@class_uri
35
+ end
36
+
37
+ def self.to_s
38
+ return @@class_uri
39
+ end
40
+ end
41
+
42
+ Jekyll::JekyllRdf::Helper::Types::register XsdDouble
43
+ end
44
+ end
45
+
46
+ end
@@ -0,0 +1,32 @@
1
+ module Jekyll
2
+ module JekyllRdf
3
+ module Types
4
+ class XsdInteger
5
+ @@class_uri = "http://www.w3.org/2001/XMLSchema#integer"
6
+
7
+ def self.match? string
8
+ return regex.match string
9
+ end
10
+
11
+ def self.regex
12
+ @@regex ||= /^[+-]?[0-9]+$/
13
+ return @@regex
14
+ end
15
+
16
+ def self.to_type string
17
+ return string.to_i.to_s
18
+ end
19
+
20
+ def self.=== other
21
+ return other.to_s.eql? @@class_uri
22
+ end
23
+
24
+ def self.to_s
25
+ return @@class_uri
26
+ end
27
+ end
28
+
29
+ Jekyll::JekyllRdf::Helper::Types::register XsdInteger
30
+ end
31
+ end
32
+ end
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.0.pre.develop.485
4
+ version: 3.0.0.pre.develop.492
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elias Saalmann
@@ -17,7 +17,7 @@ authors:
17
17
  autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
- date: 2018-07-17 00:00:00.000000000 Z
20
+ date: 2018-08-03 00:00:00.000000000 Z
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  name: linkeddata
@@ -193,9 +193,14 @@ files:
193
193
  - lib/jekyll/helper/rdf_generator_helper.rb
194
194
  - lib/jekyll/helper/rdf_page_helper.rb
195
195
  - lib/jekyll/helper/rdf_prefix_helper.rb
196
+ - lib/jekyll/helper/rdf_types.rb
196
197
  - lib/jekyll/hooks/rdf_page_pointer.rb
197
198
  - lib/jekyll/rdf_main_generator.rb
198
199
  - lib/jekyll/rdf_template_mapper.rb
200
+ - lib/jekyll/types/XsdBoolean.rb
201
+ - lib/jekyll/types/XsdDecimal.rb
202
+ - lib/jekyll/types/XsdDouble.rb
203
+ - lib/jekyll/types/XsdInteger.rb
199
204
  homepage: https://github.com/white-gecko/jekyll-rdf
200
205
  licenses:
201
206
  - MIT