Class: LogicalConstruct::NodeClient
- Inherits:
-
Object
- Object
- LogicalConstruct::NodeClient
- Defined in:
- lib/logical-construct/node-client.rb
Defined Under Namespace
Classes: ManifestBuilder
Instance Attribute Summary collapse
-
#node_url ⇒ Object
Returns the value of attribute node_url.
-
#plan_archives ⇒ Object
Returns the value of attribute plan_archives.
-
#server ⇒ Object
Returns the value of attribute server.
-
#silent ⇒ Object
Returns the value of attribute silent.
Instance Method Summary collapse
- #deliver_manifest ⇒ Object
- #deliver_plans ⇒ Object
-
#initialize ⇒ NodeClient
constructor
A new instance of NodeClient.
- #page_labeled(label, focus) ⇒ Object
- #report(item) ⇒ Object
- #resolved? ⇒ Boolean
- #state ⇒ Object
Constructor Details
#initialize ⇒ NodeClient
Returns a new instance of NodeClient.
26 27 28 29 |
# File 'lib/logical-construct/node-client.rb', line 26 def initialize @plan_archives = [] @silent = false end |
Instance Attribute Details
#node_url ⇒ Object
Returns the value of attribute node_url.
31 32 33 |
# File 'lib/logical-construct/node-client.rb', line 31 def node_url @node_url end |
#plan_archives ⇒ Object
Returns the value of attribute plan_archives.
31 32 33 |
# File 'lib/logical-construct/node-client.rb', line 31 def plan_archives @plan_archives end |
#server ⇒ Object
Returns the value of attribute server.
31 32 33 |
# File 'lib/logical-construct/node-client.rb', line 31 def server @server end |
#silent ⇒ Object
Returns the value of attribute silent.
31 32 33 |
# File 'lib/logical-construct/node-client.rb', line 31 def silent @silent end |
Instance Method Details
#deliver_manifest ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/logical-construct/node-client.rb', line 62 def deliver_manifest report "Delivering manifest" = [] server.putting do |root| = [] needs = page_labeled("Server Manifest", root) builder = ManifestBuilder.new(needs) plan_archives.each do |archive| << "Adding #{archive}" builder.add_plan(archive) end end report end |
#deliver_plans ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/logical-construct/node-client.rb', line 79 def deliver_plans loop do needs = [] server.getting do |root| needs = [] unresolved = page_labeled("Unresolved Plans", root) unresolved[:lc, "plans"].as_list.each do |need| needs << [need[:lc, "name"], need[:lc, "contents"]] end end if needs.empty? report "Target needs fulfilled" break end report "Delivering plan archives" needs.each do |need| name, path = *need plan = plan_archives.find do |plan| File.basename(plan) == name end next if plan.nil? File::open(plan, "r") do |file| report " Delivering #{name}" server.put_file(path, "application/x-gtar-compressed", file) #sorta like a ukulele end end end end |
#page_labeled(label, focus) ⇒ Object
55 56 57 58 59 60 |
# File 'lib/logical-construct/node-client.rb', line 55 def page_labeled(label, focus) concept = focus.all(:skos, "hasTopConcept").find do |concept| concept.all(:skos, "prefLabel").include?(label) or concept.all(:skos, "altLabel").include?(label) end concept.first(:foaf, "page") end |
#report(item) ⇒ Object
39 40 41 |
# File 'lib/logical-construct/node-client.rb', line 39 def report(item) puts item unless silent end |
#resolved? ⇒ Boolean
51 52 53 |
# File 'lib/logical-construct/node-client.rb', line 51 def resolved? state.downcase == "resolved" end |