Is it possible with Rails to interact with SVN Server and/or the server's shell?

Hello! I’m fairly new to Ruby and Rails, and currently I don’t have any
knowledge on interacting with the server’s shell or a SVN server, but
now I
have to develop an app where admins allow/restrict access to files and
folders from the app and some sort of version control of the files is
need
so I thought, to install a SVN server also and from the app allow users
to
access files they’ve been authorized to. I’ve been searching about this
but
I can’t seem to find a concrete answer. Could some please tell me if
this
is possible and if so, point me in the right direction, what sort of
stuff
should i look into first?

Thank you.

On Nov 6, 2013, at 8:21 AM, Monserrat F. wrote:

Hello! I’m fairly new to Ruby and Rails, and currently I don’t have any
knowledge on interacting with the server’s shell or a SVN server, but now I have
to develop an app where admins allow/restrict access to files and folders from the
app and some sort of version control of the files is need so I thought, to install
a SVN server also and from the app allow users to access files they’ve been
authorized to. I’ve been searching about this but I can’t seem to find a concrete
answer. Could some please tell me if this is possible and if so, point me in the
right direction, what sort of stuff should i look into first?

Thank you.

I built something vaguely similar to this a number of years ago, and
while I didn’t go down the SVN path, what I did was this:

  1. User authentication with Devise, authorization with CanCan.
  2. Files stored with Paperclip (in this case they were all PDF) with
    text scraped from each file into a keywords field on the parent model.
  3. Files versioned with vestal_version, which provided forward/back in
    time navigation. (I did have to hack Paperclip to never delete an
    attachment, and to rename each attached file to include the version
    info.)

I’m not sure if SVN would have been a saner choice here, I did end up
reinventing the wheel. The benefit for me was that everything was in one
(Rails) mental model, so I didn’t have to create a bridge back and forth
between my user management and file management.

Walter

Monserrat F. wrote in post #1126580:

Hello! I’m fairly new to Ruby and Rails, and currently I don’t have any
knowledge on interacting with the server’s shell or a SVN server, but
now I
have to develop an app where admins allow/restrict access to files and
folders from the app and some sort of version control of the files is
need
so I thought, to install a SVN server also and from the app allow users
to
access files they’ve been authorized to. I’ve been searching about this
but
I can’t seem to find a concrete answer. Could some please tell me if
this
is possible and if so, point me in the right direction, what sort of
stuff
should i look into first?

Issuing system commands is as simple as:

system svn

Or when you want to capture the command’s standard output into a string:

out = svn <command> # These are back tics

And, if you decide to use a SCM as a backed to store your files what not
choose a SCM that isn’t a steaming pile of sh*t. Like git
(http://git-scm.com). Just saying…

Hello all, thanks for replying.

Explaining a little further what I need is to set the permissions to
determined users from the app, however, the files aren’t in the same
server
as the app and it should be relatively easy to the users to access the
files, and the admin wants to be able to see what files and exactly what
was modified by that user on that file and when, etc,etc (That’s why I
thought of an SVN server or something similar) . My idea was adding the
permissions to a folder via the app so, the user in whatever SVN client
he
has, is able to download the lastest file and modify it and at the same
time, the admin would be able to view who, what and when the files were
modified. The app would only keep a record filled by the user but that
wouldn’t be 100% accurate due to users (because they can pretty much
write
whatever they want).

On Wednesday, November 6, 2013 9:37:08 AM UTC-4:30, Ruby-Forum.com User

Robert W. wrote in post #1126590:

Issuing system commands is as simple as:

system svn

My apologies, but you need to quote the command part:

system 'svn ’

Monserrat F. wrote in post #1126594:

Explaining a little further what I need is to set the permissions to
determined users from the app, however, the files aren’t in the same
server

Keeping in mind that what I’m about to say is completely off the top of
my head…

Given that your documents are stored on a separate server from the app
thing get a little more tricky. For sake of reference let’s call them
“Doc Server” and “App Server”.

Assuming you have enough control of the Doc Server that you could
install a service application that’s probably the approach I would take.
I would hide all access to the files behind a service application with
some sort of HTTP interface. It would be REST based if I were to build
it returning JSON responses. It would also provide secured access to the
requested files. So we have JSON for the file metadata and HTTP access
to the file data.

The service app would have a multi-part form upload used to receive
incoming files from a user. The service app would need to know the name
and email of the user, the path in the local git working tree along with
the file data.

git add --all

Used to add any new (untracked) files to the git repository.

git commit --author=“John D. [email protected]” -m “Changing a test
file.”

This would commit all change setting the commit author to “John D.
[email protected]”.

git log --author=“John D. [email protected]

This would filter the log output to just John’s commits.

git log --author=“John D. [email protected]” --name-status

This would also include a list of files changes and the status code for
the type of change.

All of this power would be available to the service application via the
Ruby system command (or back tic):


#!/usr/bin/env ruby
git_user = “John D. <[email protected]

out = git log --no-color --author="#{git_user}" --pretty=full
puts out

$ ./main.rb
commit 58359794f4443985279cdd1627cdf944fd140d24 (HEAD, master)
Author: John D. [email protected]
Commit: Robert W. [email protected]

Changing test file.

M test.txt

Notice I used --pretty-full in this example to illustrate the difference
in the author vs. the committer of the change. The committer would
always be the service app, or whatever is configured in your git config.
The author is provided by the service application.

Now it’s just a matter of writing a Ruby class to parse the git output
and create the JSON metadata that the service application would return
to the application running on the App Server.

Secure the whole this with some sort of basic single sign-on or API
token.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs