Rsync: pure Ruby implementation? - ruby

I have a Rsync program Deltacopy with an executable as client and server but would like to replace this if possible with a pure Ruby implementation of Rsync. I found gems like six-rsync and rsync-update but they seem to be no general implementations. I'm looking for a pure Ruby solution, so no executables involved and preferably runnable on multiple OS.
If possible a simple sample would be great.
I only look for Rsync, no other transfer or backup solutions please.

There's this:
"Cheapest Rsync Replacement (with Ruby)"
Archived dzone: https://web.archive.org/web/20090101014459/http://snippets.dzone.com/posts/show/1812
Archived original: https://web.archive.org/web/20070615023341/http://eigenclass.org/hiki.rb?cheap+rsync
https://github.com/avh4/ruby-sync
"A full file synchronisation library for ruby, supports syncing/mirroring with local and FTP/SSH directories."
http://synchzor.com/
Best of luck, sir.

I've never used it, but it looks like rrsync might be a worth a try.
https://github.com/RichGuk/rrsync

I would try using Ruby Inline ( http://rubygems.org/gems/RubyInline and http://www.zenspider.com/ZSS/Products/RubyInline/ ). You might be able to use the Rsync source code with Ruby Inline.
I don't know how this would work on Windows platforms, however.
Rsync source code: http://rsync.samba.org/download.html

Related

Perform SVN operations through a ruby script on windows/osx

I am a newbie and need to perform some basic SVN operations (like get info of the repository, add, commit, update etc) through a ruby script, on both windows/osx.
I searched the forum and internet, only to find partial and confusing answers related to SWIG ruby-subversion bindings etc, but none of them was well documented or simple enough to use [Also, most of these questions and answers are pretty old].
I am assuming that a simpler way to perform SVN operations through a ruby script should exist by now. Correct me if my assumption is wrong.
Also, is it worth the hassle to install SWIG bindings, understand 'svn/core' library and use it with a gem (like svn_wc) OR better to simply call svn command line commands from ruby? Is there a massive difference in performance for these approaches?
Any help will be much appreciated.
A simple way is to use SVN command line tools from Ruby.
Say you are in a sandbox and you have a script 'svn-get_uuid'.
It could look like this:
$ cat svn-get_uuid
#!/usr/bin/ruby
uuid = `svn info`.lines.grep /^UUID/
uuid = uuid[0].chomp.sub /^.*: (.+)/, '\1'
print "{#{uuid}}\n"
$ ./svn-get_uuid
{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}
May be you can do it faster using the svn-bindings, but working this way is OK for my daily work.

How to Design/Figure out the Required Path in Ruby Programming?

Is there a well-designed method that can run my ruby program from anywhere? I already searched a couple of ways to import my ruby program from the different directories by using the relative path.
i.e.
File.expand_path(“my_path”)
It worked and let me run it anywhere, but somehow, it is a little unreadable and I think it is pretty messy. So I think there may be a solution or convention to deal with this kind of problem when there are many file paths that have to be imported.
I suggest you have a look how to package a gem and build your own and install it. Or you could place your binary in $PATH, but that's a bit more messy.

ctag database for Go

How to generate tags file for Go source
In mac, I installed exuberant ctags , and tried the below command in source directory
ctags -f gosource.tags -R `pwd`
But, it doesn't consider *.go files. Do I have to use -h option? But, isn't it only for header files, as per the manual?
Please give me the correct command so that I can use the tags file with vim. I also prefer absolute path so that I can keep the file anywhere
Thanks.
Edit:
I assumed current ctags support Go, seeing http://groups.google.com/group/golang-nuts/browse_thread/thread/3a4848db231b02c9.
but, http://ctags.sourceforge.net/languages.html desn't have go listed.
Add the following to ~/.ctags
--langdef=Go
--langmap=Go:.go
--regex-Go=/func([ \t]+\([^)]+\))?[ \t]+([a-zA-Z0-9_]+)/\2/d,func/
--regex-Go=/var[ \t]+([a-zA-Z_][a-zA-Z0-9_]+)/\1/d,var/
--regex-Go=/type[ \t]+([a-zA-Z_][a-zA-Z0-9_]+)/\1/d,type/
(From http://go-wise.blogspot.com/2011/09/using-ctags-with-go.html)
--langdef=Go
--langmap=Go:.go
--regex-Go=/func([ \t]+\([^)]+\))?[ \t]+([a-zA-Z0-9_]+)/\2/f,func/
--regex-Go=/var[ \t]+([a-zA-Z_][a-zA-Z0-9_]+)/\1/v,var/
--regex-Go=/type[ \t]+([a-zA-Z_][a-zA-Z0-9_]+)/\1/t,type/
Does indeed work with ctags 5.8. One slight change from the previous poster, ctags requires unique 1-char types at the ends of the regex lines. Thus /d,func/ should read /f,func/ intuitively. This allows the ctags to distinguish between and identify types, allowing ctags --go-types=fvt i.e.
I saw your post, bumbled around a bit trying to find a good tool for the job, tried ctags, and ultimately was unsatisfied. I wrote a program 'gotags' in Go that generates a ctags file for Go code. Its better than the current ctags support because, for example, it tags struct field names as well as the struct name itself. You can get it here: https://github.com/necro351/gotags.
Its a nice short simple Go program because it uses the standard library parser and has no extra features other than good Go parsing and tagging. Just check it out (or go get it) and do a go install. Also, if you have any suggestions or ideas about improving it, let me know.
Edit: I am an active Gopher and so will be updating this tool over time and as I use it.
Edit: I am not actively developing Go anymore. But my tool is very short and pretty much works as is so it should "just work" :)
universal-ctags supports Go. It's the successor of exuberant-ctags and works perfectly fine. See here for the man pages.
Check Go Dashborad/Projects, section "Tag Generators". Status of those tools is not known to me.
Edit 2011-11-22: Latest egotags fork announced today (cyclic reference possible ;-)

Can Ruby + Crate + Windows work?

I've got a project for work I'd like to do in Ruby that will have to run on Windows, but perturbing the filesystem for a Ruby install or RubyScript2Exe unpack isn't an option (this is supposed to be the harness for a testing system). Has anyone successfully used Crate to package up something on Windows? If so, what was your build environment like and can you pass on any other hints?
I've tried and worked in getting Crate work under Windows, but is a more complicated system than I would expect.
If extraction of code for your system is your problem. I recommend take a look to Exerb, and specially: exerb-mingw hosted on GitHub exerb-mingw
It will generate a single executable like Ocra or RubyScript2Exe, but with the difference that the source code will not be extracted and extensions will be dynamically loaded.
This works perfectly with RubyInstaller packages, and is being used with Pik (Ruby version manager for Windows).
Hope this helps.
You can embed a Ruby interpreter and script into a C program, which may be easier than trying to run Crate. Here are some helpful links that describe how to do this, and may provide enough sample code to use as a skeleton for what you are trying to build.

Continuous Integration setup for ruby projects on linux server

I would like to use open source tools if possible.
here are 2 links I found but haven't tried them -
http://pivots.pivotallabs.com/users/chad/blog/articles/471-continuous-integration-in-a-box-exploring-tsttcpw
http://laurentbois.com/category/continuous-integration/
Try this CruiseControl.rb
http://cruisecontrolrb.thoughtworks.com/
CruiseControl.rb is written in Ruby and designed for ruby.
Another one is Hudson, it is built in Java, but it has a plugin for ruby
https://hudson.dev.java.net/
Give Cinabox a try (I'm the author). It is intended to make this as simple as possible, and uses cruisecontrol.rb. There is a screencast and readme. If you have problems, open a ticket using the LightHouse link in the readme.
Good Luck!
There is a lightweight CI server written in Sinatra called Integrity which you might want to take a look at. I mainly used it because it supports git.
Git Reference

Resources