Alien-SVN
view release on metacpan or search on metacpan
src/subversion/subversion/bindings/swig/ruby/svn/util.rb view on Meta::CPAN
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
def windows?
/cygwin|mingw|mswin32|bccwin32/.match(RUBY_PLATFORM)
end
end
end
( run in 0.827 second using v1.01-cache-2.11-cpan-ceb78f64989 )