/usr/lib/ruby/1.8/rd/rbl-file.rb is in librd-ruby1.8 0.6.22-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | require 'rd/search-file'
module RD
class RBLFile
include SearchFile
SUFFIX = "rbl"
attr_reader :labels
attr_reader :filename
def initialize(filename)
@filename = RBLFile.basename(filename)
@labels = []
end
def RBLFile.create_rbl_file(filename, resolver)
file = File.open(RBLFile.rbl_file_path(filename), "w")
file.print(RBLFile.labels_to_string(resolver))
file.close
end
def RBLFile.rbl_file_path(filename)
basename(filename) + "." + SUFFIX
end
def RBLFile.basename(path)
if /\.(rd|rb)$/ === path
$`
else
path
end
end
def RBLFile.labels_to_string(resolver)
(resolver.collect do |i|
i.to_label + " => " + resolver.get_anchor(i)
end).join("\n")
end
def load_rbl_file(search_paths)
f = search_file(@filename, search_paths, [SUFFIX])
raise "RBLFile not found." unless f
src = File.readlines(f).join("")
@labels = string_to_labels(src)
end
def string_to_labels(src)
labels = []
src.each_line do |i|
labels << parse_line(i)
end
labels
end
def parse_line(src)
col = src.rindex("=>")
raise "RBL file parse error." unless col
label = src[0 .. col - 1].strip
anchor = src[col + 2 .. -1].strip
[label, anchor]
end
def refer(label)
label = @labels.find{|i| i[0] == label}
return nil unless label
label[1]
end
end
end
|