Subversion Ruby Bindings access to URL
6 Message(s) by 3 Author(s) originally posted in ruby programming
| From: Jacob Burkhart |
Date: Friday, May 04, 2007
|
So I struggled through the installation of swig, subversion and the
ruby bindings, and now I want to
connect to subversion from ruby.
It turns out this is usually done through the
file system with:
Svn::Repos.open
But, I do not have filesystem access to my
repository , I only have web
access
So I need to do something like this:
url = '
http://trac-hacks.swapoff.org/svn'
ctx = Svn::Client::Context.new
cb = Svn::Ra::Callbacks.new(ctx.auth_baton)
cb.auth_baton = Svn::Core.auth_open([])
CFG = Svn::Core::config_get_config(nil)
s = Svn::Ra::Session.open(url, cfg, cb)
st = s.stat(", 1)
(from:
http://www.oneofthewolves.com/2007/03/06/ruby-subversion-bindings-finally-some-documentation /#comment-137)
The problem with that one, is that there's no way to pass in my
username and
password for htaccess
Looking at the swig and other documentation It seems I need to pass a
C
struct struct svn_auth_
provider _
object _t
To Svn::Core.auth_open([])
And that C struct needs to also contain a
function pointer to a
function that then returns username and password somehow?
00149 typedef struct svn_auth_provider_object_t
00150 {
00151 const svn_auth_provider_t *vtable;
00152 void *provider_baton;
00153
00154 } svn_auth_provider_object_t;
http://svn.collab.net/svn-doxygen/group__auth__fns.htmlSo it seems I need to figure out how to implement a C function pointer
from ruby over swig, I'm guessing this is not possible....
So, if that's the case I was thinking maybe I could use a Proxy server
to proxy localhost:2901 or some other
random port over to my real
repository
URL and pass the
authentication username and password
through the proxy
Does anybody have any suggestions for such a proxy? perhaps on
implemented in ruby.And, does anybody have any other suggestions for what I could try to
in order to connect to my remote (And authenticated) repository via
ruby subversion bindings?thanks,
Jacob
| From: Brian Candler |
Date: Friday, May 04, 2007
|
wrote in message:
So I need to do something like this:
url = 'http://trac-hacks.swapoff.org/svn'
ctx = Svn::Client::Context.new
cb = Svn::Ra::Callbacks.new(ctx.auth_baton)
cb.auth_baton = Svn::Core.auth_open([])
CFG = Svn::Core::config_get_config(nil)
s = Svn::Ra::Session.open(url, cfg, cb)
st = s.stat(", 1)
(from:
http://www.oneofthewolves.com/2007/03/06/ruby-subversion-bindings-finally-some-documentation/#comment-137)
The problem with that one, is that there's no way to pass in my
username and password for htaccess
I'm sure you can - probably doing something with the auth_baton.
Unfortunately I have not tried it myself yet, as I have not needed it.
The "Practical Subversion" book has a whole chapter on using the
API (application
programming interface )though.
Looking at the swig and other documentation It seems I need to pass a
C struct struct svn_auth_provider_object_t
To Svn::Core.auth_open([])
I
expect there's a corresponding wrapped object already in the Swig
interface. You just have to work out how to create it.
If you can google for an example written in some other
language (e.g.
python) you should be able to make it work.
B.
| From: Jacob Burkhart |
Date: Friday, May 04, 2007
|
require 'svn/client'
require 'svn/ra'
url = '___'
ctx = Svn::Client::Context.new
cb = Svn::Ra::Callbacks.new(ctx.auth_baton)
provider = Proc.new do
|cred, realm, default, may_save, pool|
simplecreds = Svn::Ext::Core::Svn_auth_cred_simple_t.new
simplecreds.username = "___"
simplecreds.password = "___"
simplecreds
end
cb.auth_baton = Svn::Core.auth_open(
[
Svn::Client::get_simple_prompt_provider(provider, 2)
])
CFG = Svn::Core::config_get_config(nil)
s = Svn::Ra::Session.open(url, cfg, cb)
st = s.stat('', 1)
puts <<EOS
Status of node(#{url})
created
revision = #{st.created_rev}
committed time = #{Time.at(st.time / 1_000_000)}
author = #{st.last_author}
size = #{st.size}
EOS
There it is!Now that I have figured out how to connect... I realize that the
Svn::Client interface and the Svn::Repos APIS are completely
different... and my original
goal of making Retrospectiva work or
remote repositories is looking a lot bleaker.
| From: =?utf-8?Q?Juanse_P=c3=a9rez_herrero?= |
Date: Sunday, October 28, 2007
|
I am trying to authenticate to remote svn using the ruby bindings.
I create my provider as follows
provider = Proc.new do |cred, args |
cred = Svn::Ext::Core::Svn_auth_cred_simple_t.new
cred.username = username
cred.password = password
cred
end
These are snippets from Client.rb
I have been playing around with rdebug to find out that my auth
information gets lost (see comments).
def add_simple_prompt_provider(retry_limit, prompt=Proc.new)
args = [retry_limit]
klass = Core::AuthCredSimple
add_prompt_provider("simple", args, prompt, klass)
end
def add_prompt_provider(name, args, prompt, cred_class)
# the prompt
parameter arrives ok
# prompt.call().username is my username
real_prompt = Proc.new do |*prompt_args|
cred = cred_class.new
prompt.call(cred, *prompt_args)
cred
end
# here real_prompt.call().username returns nil (!!!!)
method_name = "swig_rb_auth_get_#{name}_prompt_provider"
baton, pro = Core.__send__(method_name, real_prompt, *args)
[...]
Am I doing something wrong?
Any help is appreciated
--
Posted via
http://www.ruby-forum.com/.
| From: =?utf-8?Q?Juanse_P=c3=a9rez_herrero?= |
Date: Sunday, October 28, 2007
|
The
code I am using
username = "*****"
password = "*****"
root = "svn+ssh://******/trunk"
ctx = Svn::Client::Context.new
provider = Proc.new do |cred, realm, default, may_save, pool|
cred.username = username
cred.password = password
cred
end
cb = Svn::Ra::Callbacks.new(ctx.auth_baton)
cb.auth_baton =
Svn::Core.auth_open([Svn::Client::get_simple_prompt_provider(provider,
2)])
session = Svn::Ra::Session.open(root, Svn::Core::config_get_config(nil),
cb)
If anyone got svn bindings auth working please post
--
Posted via
http://www.ruby-forum.com/.
| From: =?utf-8?Q?Juanse_P=c3=a9rez_herrero?= |
Date: Sunday, October 28, 2007
|
Hi
Thanks a lot for your answers Kouhei,
I have to admit it I do not know that much what I am doing
I just know I want to browse dirs and get file contents for a remote
subversion repos
I know Session.dir and Session.file work ok on a public repos and do
what I expect (I have tried that successfully), so it should be a matter
of getting an auth session for the repos username/password
This seems to me the function to connect with ra
Ra::Session.open(url, config={}, callbacks=nil)
I am wondering if anyone has gotten this auth stuff done
Cheers
--
Posted via
http://www.ruby-forum.com/.
Next Message: Witch Oracle library should I use
Blogs related to Subversion Ruby Bindings access to URL
[fm-news] Newsletter for Wednesday, April 11th 2007
About: RailRoad is a class diagram generator for
Ruby on Rails applications. It produces diagrams of controllers and models as DOT graphs. License: GNU General Public License (GPL).
URL: http://freshmeat.net/projects/rubyrailroad/
...
nvidia agp card driver
Ruby vs. Java nvisia agp card driver This book is still, I believe, is what the finished data. The main tools I"m using SWIG with Perl5 allows people to convene and interact with the topic of business any time by going to a multipage
...
[fm-news] Newsletter for Thursday, March 22nd 2007
accommodate any number of sounds, each with any number of channels. It can be customized and extended using Guile,
Ruby, or Forth. License: GNU General Public License (GPL).
URL: http://freshmeat.net/projects/snd/. - % - % - % - % -
...
[fm-news] Newsletter for Thursday, April 19th 2007
About: Sode.rb generates a
Ruby program to use long Taylor series to solve systems of ordinary differential equations. It generates code to solve the equations in
Ruby. Using the Taylor series, estimates are made of the
...
Web framework notes
model-less data
access via sqlalchemy introspection ("simpledb" module, hopefully soon to make it into sqlalchemy.ext
subversion); "data
binding" (ASP.NET term) in select box; no need to manually specify option tags
...
Rails Installation Help
There’sa pure
Ruby adapter in rails. However, for performance reasons, you will want to be use the mysql-
ruby bindings if at all possible. Next, let’s make sure that you can reach the
Subversion code repository that your project is in.
...