Class: RoadForest::RemoteHost
Constant Summary
RoadForest::RDF::Normalization::Vocabs
Instance Attribute Summary collapse
Instance Method Summary
collapse
#expand_curie, #expand_curie_pair, #interned_uri, #literal, #normalize_context, #normalize_property, #normalize_resource, #normalize_statement, #normalize_term, #normalize_tuple, #normalize_uri, #relevant_prefixes_for_graph, #root_url, #uri, #vocabularies_in_graph
Constructor Details
#initialize(well_known_url) ⇒ RemoteHost
Returns a new instance of RemoteHost.
14
15
16
|
# File 'lib/roadforest/remote-host.rb', line 14
def initialize(well_known_url)
self.url = well_known_url
end
|
Instance Attribute Details
#http_client ⇒ Object
28
29
30
|
# File 'lib/roadforest/remote-host.rb', line 28
def http_client
@http_client ||= HTTP::ExconAdapter.new(url)
end
|
#url ⇒ Object
Returns the value of attribute url.
17
18
19
|
# File 'lib/roadforest/remote-host.rb', line 17
def url
@url
end
|
Instance Method Details
#add_credentials(username, password) ⇒ Object
44
45
46
|
# File 'lib/roadforest/remote-host.rb', line 44
def add_credentials(username, password)
user_agent.keychain.add(url, username, password)
end
|
#anneal(focus) ⇒ Object
61
62
63
64
65
66
67
|
# File 'lib/roadforest/remote-host.rb', line 61
def anneal(focus)
graph = build_graph_store
annealer = RDF::SourceRigor::CredenceAnnealer.new(graph)
annealer.resolve do
yield focus
end
end
|
#build_graph_store ⇒ Object
23
24
25
|
# File 'lib/roadforest/remote-host.rb', line 23
def build_graph_store
RDF::GraphStore.new
end
|
#getting(&block) ⇒ Object
110
111
112
113
114
115
116
117
118
119
|
# File 'lib/roadforest/remote-host.rb', line 110
def getting(&block)
graph = build_graph_store
access = RDF::ReadOnlyManager.new
access.rigor = source_rigor
access.source_graph = graph
reader = RDF::GraphFocus.new(access, url)
anneal(reader, &block)
end
|
#graph_transfer ⇒ Object
40
41
42
|
# File 'lib/roadforest/remote-host.rb', line 40
def graph_transfer
@graph_transfer ||= HTTP::GraphTransfer.new(user_agent)
end
|
#posting(&block) ⇒ Object
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
# File 'lib/roadforest/remote-host.rb', line 91
def posting(&block)
require 'roadforest/rdf/post-focus'
graph = build_graph_store
access = RDF::PostManager.new
access.rigor = source_rigor
access.source_graph = graph
poster = RDF::PostFocus.new(access, url)
graphs = {}
poster.graphs = graphs
anneal(poster, &block)
graphs.each_pair do |url, graph|
graph_transfer.post(url, graph)
end
end
|
#put_file(destination, type, io) ⇒ Object
121
122
123
124
125
126
127
128
|
# File 'lib/roadforest/remote-host.rb', line 121
def put_file(destination, type, io)
if destination.respond_to?(:to_context)
destination = destination.to_context
elsif destination.respond_to?(:to_s)
destination = destination.to_s
end
response = user_agent.make_request("PUT", destination, {"Content-Type" => type}, io)
end
|
#putting(&block) ⇒ Object
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/roadforest/remote-host.rb', line 69
def putting(&block)
graph = build_graph_store
access = RDF::UpdateManager.new
access.rigor = source_rigor
access.source_graph = graph
updater = RDF::GraphFocus.new(access, url)
annealer = RDF::SourceRigor::CredenceAnnealer.new(graph)
annealer.resolve do
access.target_graph = ::RDF::Repository.new
yield updater
end
target_graph = access.target_graph
target_graph.each_context do |context|
graph = ::RDF::Graph.new(context, :data => target_graph)
graph_transfer.put(context, graph)
end
end
|
#render_graph(graph) ⇒ Object
57
58
59
|
# File 'lib/roadforest/remote-host.rb', line 57
def render_graph(graph)
Resource::ContentType::JSONLD.from_graph(graph)
end
|
#source_rigor ⇒ Object
48
49
50
51
52
53
54
55
|
# File 'lib/roadforest/remote-host.rb', line 48
def source_rigor
@source_rigor ||=
begin
rigor = RDF::SourceRigor.http
rigor.graph_transfer = graph_transfer
rigor
end
end
|
#trace=(target) ⇒ Object
32
33
34
|
# File 'lib/roadforest/remote-host.rb', line 32
def trace=(target)
user_agent.trace = target
end
|
#user_agent ⇒ Object
36
37
38
|
# File 'lib/roadforest/remote-host.rb', line 36
def user_agent
@user_agent ||= HTTP::UserAgent.new(http_client)
end
|