/usr/lib/ruby/1.8/svn/util.rb is in libsvn-ruby1.8 1.6.17dfsg-3ubuntu3.
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 70 71 72 73 74 75 76 77 78 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 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | if /cygwin|mingw|mswin32|bccwin32/.match(RUBY_PLATFORM)
$LOAD_PATH.each do |load_path|
svn_ext_path = File.join(load_path, "svn", "ext")
if File.exists?(svn_ext_path)
svn_ext_path_win = File.expand_path(svn_ext_path)
svn_ext_path_win = svn_ext_path.gsub(File::SEPARATOR, File::ALT_SEPARATOR)
unless ENV["PATH"].split(";").find {|path| path == svn_ext_path_win}
ENV["PATH"] = "#{svn_ext_path_win};#{ENV['PATH']}"
end
end
end
end
require 'tempfile'
unless respond_to?(:__send!)
module Kernel
alias __send! __send__
end
end
module Svn
module Util
module_function
def to_ruby_class_name(name)
name.split("_").collect do |x|
"#{x[0,1].upcase}#{x[1..-1].downcase}"
end.join("")
end
def to_ruby_const_name(name)
name.upcase
end
def valid_rev?(rev)
rev and rev >= 0
end
def copy?(copyfrom_path, copyfrom_rev)
Util.valid_rev?(copyfrom_rev) && !copyfrom_path.nil?
end
def hash_to_prop_array(hash)
hash.collect do |key, value|
Svn::Core::Prop.new(key, value)
end
end
def set_constants(ext_mod, target_mod=self)
target_name = nil
ext_mod.constants.each do |const|
target_name = nil
case const
when /^SVN__/
# ignore private constants
when /^SVN_(?:#{target_mod.name.split("::").last.upcase}_)?/
target_name = $POSTMATCH
when /^SWIG_SVN_/
target_name = $POSTMATCH
when /^Svn_(?:#{target_mod.name.split("::").last.downcase}_)?(.+)_t$/
target_name = to_ruby_class_name($1)
when /^Svn_(?:#{target_mod.name.split("::").last.downcase}_)?/
target_name = to_ruby_const_name($POSTMATCH)
# else
# puts const
end
unless target_name.nil?
target_mod.const_set(target_name, ext_mod.const_get(const))
end
end
end
def set_methods(ext_mod, target_mod=self)
target_name = nil
ext_mod.public_methods(false).each do |meth|
target_name = nil
case meth
when /^svn_(?:#{target_mod.name.split("::").last.downcase}_)?/
target_name = $POSTMATCH
when /^apr_/
target_name = meth
end
unless target_name.nil?
target_mod.module_eval(<<-EOC, __FILE__, __LINE__ + 1)
def #{target_name}(*args, &block)
#{ext_mod.name}.#{meth}(*args, &block)
end
module_function :#{target_name}
EOC
end
end
end
def filename_to_temp_file(filename)
file = Tempfile.new("svn-ruby")
file.binmode
file.print(File.open(filename, "rb") {|f| f.read})
file.close
file.open
file.binmode
file
end
def reset_message_directory
if /cygwin|mingw|mswin32|bccwin32/.match(RUBY_PLATFORM)
top_directory = File.join(File.dirname(__FILE__), "..", "..")
top_directory = File.expand_path(top_directory)
locale_directory = File.join(top_directory, "share", "locale")
locale_directory_win = locale_directory.tr(File::SEPARATOR,
File::ALT_SEPARATOR)
GetText.bindtextdomain(locale_directory_win)
end
end
def validate_options(options, optional_keys, required_keys=[])
unknown_keys = options.keys - (optional_keys + required_keys)
unless unknown_keys.empty?
raise(ArgumentError, "Unknown key(s): #{unknown_keys.join(", ")}")
end
missing_keys = []
required_keys.each do |key|
missing_keys << key if options[key].nil?
end
unless missing_keys.empty?
raise(ArgumentError, "Missing key(s): #{missing_keys.join(", ")}")
end
end
end
end
|