[Rails] Re: Is it possible with Rails to interact with SVN Server and/or the server's shell?
Monserrat Foster 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 Doe <john@example.com>" -m "Changing a test
file."
This would commit all change setting the commit author to "John Doe
<john@example.com>".
git log --author="John Doe <john@exmaple.com>"
This would filter the log output to just John's commits.
git log --author="John Doe <john@exmaple.com>" --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 Doe <john@example.com"
out = `git log --no-color --author="#{git_user}" --pretty=full`
puts out
-------------------------
$ ./main.rb
commit 58359794f4443985279cdd1627cdf944fd140d24 (HEAD, master)
Author: John Doe <john@example.com>
Commit: Robert Walker <robert@example.com>
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.
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/d6a57e2d5d36f7af40c9b43b216a39a6%40ruby-forum.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home