Module: Chronicle::Schema::RDFParsing::Schemaorg
- Defined in:
- lib/chronicle/schema/rdf_parsing/schemaorg.rb
Constant Summary collapse
- DEFAULT_NAMESPACE =
'https://schema.org/'.freeze
Class Method Summary collapse
- .build_graph(version) ⇒ Object
- .graph_for_version(version) ⇒ Object
- .seed_graph_from_file(version, file_path) ⇒ Object
- .ttl_for_version(version) ⇒ Object
- .ttl_via_download(url) ⇒ Object
- .url_for_version(version) ⇒ Object
Class Method Details
.build_graph(version) ⇒ Object
16 17 18 19 |
# File 'lib/chronicle/schema/rdf_parsing/schemaorg.rb', line 16 def self.build_graph(version) ttl = ttl_for_version(version) Chronicle::Schema::RDFParsing::TTLGraphBuilder.build_from_ttl(ttl, default_namespace: DEFAULT_NAMESPACE) end |
.graph_for_version(version) ⇒ Object
12 13 14 |
# File 'lib/chronicle/schema/rdf_parsing/schemaorg.rb', line 12 def self.graph_for_version(version) @memoized_graphs[version] ||= build_graph(version) end |
.seed_graph_from_file(version, file_path) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/chronicle/schema/rdf_parsing/schemaorg.rb', line 34 def self.seed_graph_from_file(version, file_path) ttl = File.read(file_path) graph = Chronicle::Schema::RDFParsing::TTLGraphBuilder.build_from_ttl(ttl, default_namespace: DEFAULT_NAMESPACE) @memoized_graphs[version] = graph end |
.ttl_for_version(version) ⇒ Object
21 22 23 24 |
# File 'lib/chronicle/schema/rdf_parsing/schemaorg.rb', line 21 def self.ttl_for_version(version) url = url_for_version(version) ttl_via_download(url) end |
.ttl_via_download(url) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/chronicle/schema/rdf_parsing/schemaorg.rb', line 26 def self.ttl_via_download(url) uri = URI(url) response = Net::HTTP.get_response(uri) raise "Error: #{response.}" unless response.is_a?(Net::HTTPSuccess) response.body end |
.url_for_version(version) ⇒ Object
41 42 43 |
# File 'lib/chronicle/schema/rdf_parsing/schemaorg.rb', line 41 def self.url_for_version(version) "https://schema.org/version/#{version}/schemaorg-current-https.ttl" end |