class WebVac::Vac
Stateless-ish client for venti. I completely punted on implementing a venti client, so it just calls the vac/unvac binaries. Does the job!
Attributes
config[R]
Public Class Methods
new(cfg)
click to toggle source
Takes an instance of Config
.
# File lib/webvac.rb, line 75 def initialize cfg @config = cfg end
Public Instance Methods
load!(vac)
click to toggle source
# File lib/webvac.rb, line 102 def load! vac load_io(vac).read end
load_io(vac)
click to toggle source
# File lib/webvac.rb, line 92 def load_io vac unless /^vac:[a-f0-9]{40}$/.match(vac) raise ArgumentError, "#{vac.inspect} not a vac score?" end IO.popen( {'venti' => config.venti_server}, ["#{config.plan9bin}/unvac", '-c', vac] ).tap { |io| Thread.new { Process.wait(io.pid) } } end
save!(fn)
click to toggle source
# File lib/webvac.rb, line 79 def save! fn contents = File.read(fn) pi, po = IO.pipe io = IO.popen( {'venti' => config.venti_server}, ["#{config.plan9bin}/vac", '-i', File.basename(fn)], in: pi ).tap { |io| Thread.new { Process.wait(io.pid) } } po.write contents po.close io.read.chomp.sub(/^vac:/, '') end