1 if /cygwin|mingw|mswin32|bccwin32/.match(RUBY_PLATFORM)
2 $LOAD_PATH.each do |load_path|
3 svn_ext_path = File.join(load_path, "svn", "ext")
4 if File.exists?(svn_ext_path)
5 svn_ext_path_win = File.expand_path(svn_ext_path)
6 svn_ext_path_win = svn_ext_path.gsub(File::SEPARATOR, File::ALT_SEPARATOR)
7 unless ENV["PATH"].split(";").find {|path| path == svn_ext_path_win}
8 ENV["PATH"] = "#{svn_ext_path_win};#{ENV['PATH']}"
16 unless respond_to?(:__send!)
18 alias __send! __send__
25 def to_ruby_class_name(name)
26 name.split("_").collect do |x|
27 "#{x[0,1].upcase}#{x[1..-1].downcase}"
31 def to_ruby_const_name(name)
39 def copy?(copyfrom_path, copyfrom_rev)
40 Util.valid_rev?(copyfrom_rev) && !copyfrom_path.nil?
43 def hash_to_prop_array(hash)
44 hash.collect do |key, value|
45 Svn::Core::Prop.new(key, value)
49 def set_constants(ext_mod, target_mod=self)
51 ext_mod.constants.each do |const|
55 # ignore private constants
56 when /^SVN_(?:#{target_mod.name.split("::").last.upcase}_)?/
57 target_name = $POSTMATCH
59 target_name = $POSTMATCH
60 when /^Svn_(?:#{target_mod.name.split("::").last.downcase}_)?(.+)_t$/
61 target_name = to_ruby_class_name($1)
62 when /^Svn_(?:#{target_mod.name.split("::").last.downcase}_)?/
63 target_name = to_ruby_const_name($POSTMATCH)
67 unless target_name.nil?
68 target_mod.const_set(target_name, ext_mod.const_get(const))
73 def set_methods(ext_mod, target_mod=self)
75 ext_mod.public_methods(false).each do |meth|
78 when /^svn_(?:#{target_mod.name.split("::").last.downcase}_)?/
79 target_name = $POSTMATCH
83 unless target_name.nil?
84 target_mod.module_eval(<<-EOC, __FILE__, __LINE__ + 1)
85 def #{target_name}(*args, &block)
86 #{ext_mod.name}.#{meth}(*args, &block)
88 module_function :#{target_name}
94 def filename_to_temp_file(filename)
95 file = Tempfile.new("svn-ruby")
97 file.print(File.open(filename, "rb") {|f| f.read})
104 def reset_message_directory
105 if /cygwin|mingw|mswin32|bccwin32/.match(RUBY_PLATFORM)
106 top_directory = File.join(File.dirname(__FILE__), "..", "..")
107 top_directory = File.expand_path(top_directory)
108 locale_directory = File.join(top_directory, "share", "locale")
109 locale_directory_win = locale_directory.tr(File::SEPARATOR,
111 GetText.bindtextdomain(locale_directory_win)
115 def validate_options(options, optional_keys, required_keys=[])
116 unknown_keys = options.keys - (optional_keys + required_keys)
117 unless unknown_keys.empty?
118 raise(ArgumentError, "Unknown key(s): #{unknown_keys.join(", ")}")
121 required_keys.each do |key|
122 missing_keys << key if options[key].nil?
124 unless missing_keys.empty?
125 raise(ArgumentError, "Missing key(s): #{missing_keys.join(", ")}")