Module: Jekyll::JekyllRdf::Helper::RdfHelper

Defined in:
lib/jekyll/helper/rdf_general_helper.rb

Overview

Internal module to hold support for functionalities like submitting sparql queries

Constant Summary collapse

@@prefixes =
{}
@@usePage =
false
@@resources =
{}
@@site =
nil
@@page =
nil

Class Method Summary collapse

Class Method Details

.domainiriObject



100
101
102
# File 'lib/jekyll/helper/rdf_general_helper.rb', line 100

def self.domainiri
  @@domainiri
end

.domainiri=(domain) ⇒ Object



96
97
98
# File 'lib/jekyll/helper/rdf_general_helper.rb', line 96

def self.domainiri= domain
  @@domainiri = domain
end

.load_prefixes(path, prefHolder) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/jekyll/helper/rdf_general_helper.rb', line 73

def self.load_prefixes(path, prefHolder)
  begin
    prefix_file = File.new(path).readlines
    prefHolder["rdf_prefixes"] = prefix_file.join(" ")
    prefHolder["rdf_prefix_map"] = Hash[ *(prefix_file.collect { |v|
          arr = v.split(":",2)
          next [nil, nil] if arr[1].nil?
          [arr[0][7..-1].strip, arr[1].strip[1..-2]]
        }.flatten.reject {|x| x.nil?})]
  rescue Errno::ENOENT
    Jekyll.logger.error("Prefix file not found: #{path}")
    raise
  end
end

.pageObject



64
65
66
# File 'lib/jekyll/helper/rdf_general_helper.rb', line 64

def self.page
  @@page
end

.page=(page) ⇒ Object



55
56
57
58
59
60
61
62
# File 'lib/jekyll/helper/rdf_general_helper.rb', line 55

def self.page= page
  @@page = page
  unless @@page.data["rdf_prefixes"].nil?
    @@usePage = true
  else
    @@usePage = false
  end
end

.pathiriObject



108
109
110
# File 'lib/jekyll/helper/rdf_general_helper.rb', line 108

def self.pathiri
  @@baseiri
end

.pathiri=(path) ⇒ Object



104
105
106
# File 'lib/jekyll/helper/rdf_general_helper.rb', line 104

def self.pathiri= path
  @@baseiri = path
end

.prefixesObject



88
89
90
91
92
93
94
# File 'lib/jekyll/helper/rdf_general_helper.rb', line 88

def self.prefixes
  if(@@usePage)
    return @@page.data
  else
    return @@prefixes
  end
end

.prefixes=(path) ⇒ Object



68
69
70
71
# File 'lib/jekyll/helper/rdf_general_helper.rb', line 68

def self.prefixes= path
  @@prefixes = {}
  self.load_prefixes(path, @@prefixes)
end

.reinitializeObject

resets RdfHelper to its initialization values



129
130
131
132
133
134
135
# File 'lib/jekyll/helper/rdf_general_helper.rb', line 129

def self.reinitialize
  @@prefixes.clear
  @@usePage = false
  @@resources.clear
  @@site = nil
  @@page = nil
end

.resources(uri) ⇒ Object

Constructs and returns a Jekyll::JekyllRdf::Drops::RdfResource. If the uri refers to an already created resource, this method wont create a new resource.



117
118
119
120
121
122
123
124
# File 'lib/jekyll/helper/rdf_general_helper.rb', line 117

def self.resources uri
  resource = @@resources[uri.to_s]
  if resource.nil?
    resource = Jekyll::JekyllRdf::Drops::RdfResource.new(RDF::URI(uri.to_s), @@site, @@page)
    @@resources[uri.to_s] = resource
  end
  return resource
end

.siteObject



51
52
53
# File 'lib/jekyll/helper/rdf_general_helper.rb', line 51

def self.site
  @@site
end

.site=(site) ⇒ Object



47
48
49
# File 'lib/jekyll/helper/rdf_general_helper.rb', line 47

def self.site= site
  @@site = site
end

.sparqlObject



43
44
45
# File 'lib/jekyll/helper/rdf_general_helper.rb', line 43

def self.sparql
  @@sparql
end

.sparql=(sparql) ⇒ Object



39
40
41
# File 'lib/jekyll/helper/rdf_general_helper.rb', line 39

def self.sparql= sparql
  @@sparql = sparql
end