/usr/lib/ruby/1.8/yaml/ypath.rb is in libruby1.8 1.8.7.352-2ubuntu1.
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 | #
# YAML::YPath
#
module YAML
class YPath
attr_accessor :segments, :predicates, :flags
def initialize( str )
@segments = []
@predicates = []
@flags = nil
while str =~ /^\/?(\/|[^\/\[]+)(?:\[([^\]]+)\])?/
@segments.push $1
@predicates.push $2
str = $'
end
unless str.to_s.empty?
@segments += str.split( "/" )
end
if @segments.length == 0
@segments.push "."
end
end
def YPath.each_path( str )
#
# Find choices
#
paths = []
str = "(#{ str })"
while str.sub!( /\(([^()]+)\)/, "\n#{ paths.length }\n" )
paths.push $1.split( '|' )
end
#
# Construct all possible paths
#
all = [ str ]
( paths.length - 1 ).downto( 0 ) do |i|
all = all.collect do |a|
paths[i].collect do |p|
a.gsub( /\n#{ i }\n/, p )
end
end.flatten.uniq
end
all.collect do |path|
yield YPath.new( path )
end
end
end
end
|