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.
Related
This is my first question here, please tell me if I can in some way tag it better or make a better question :)
I'm trying to make a ruby script to install some packages and edit some configurations after I format a computer. I use Manjaro Linux, and my script can already install the official Arch packages, but when it comes to AUR (with Yay) I sometimes receive an error message, saying that Yay can't run as sudo. Also I saw that some people can integrate their Shell with other scripting languages, I started this, but still need to type my Root password more than I want to.
I searched for help on this and found that Python have a library called Pexpct, but didn't found any Ruby alternatives to it. I saw somethings related to Ruby's Expect and IO, but couldn't understand how and when to use it.
programs = [
"zsh",
"zathura",
"zathura-cb",
"zathura-djvu",
"zathura-pdf-mupdf",
"zathura-ps",
"texlive-most",
"texlive-lang",
"geogebra",
"vim",
"yay",
"adobe-source-code-pro-fonts",
"firefox-developer-edition"
]
#Array iteration to install Arch official repo's packages
programs.each do |name|
system ("pacman -Sq #{name} --noconfirm")
end
I want to know if in some way can this code inside the programs block insert my password. I know it has a lot of security problems, but is on this case for this one snippet of code and study cases. I won't use it on other scripts.
I want to step into extension development for Gnome Shell, but I can't seem to understand how I do a few tasks in Looking Glass lg to actually debug my stuff.
When I type global.log("hi"); into LG, it throws me back r(...) = undefined. Why?
When I want to debug an extensions that doesn't load, how do I do that?
It would be nice to see why an extension can't be loaded.
I tried Main.ExtensionSystem.loadExtension() but it returns undefined no matter if I give it the extension's name string or the extension's object.
Where do I find documentation for classes, objects and member methods?
(The LG inspector does not seem to be able to inspect functions.)
If I had these resources I could at least start to work on updating some extensions for newer Gnome versions. I would not ask these simple questions if they would be nicely explained somewhere but getting all the info seems really tough (I've googled for hours).
1: LookingGlass is basically a GJS console. It allows you to execute and test lines of GJS, grab and manipulate objects and use r(...) to use results in following commands.
The reason you get r(...) = undefined is because log(String); does not return anything, thus the result is undefined.
2: Either log throughout init() and enable(), then check where it breaks and try to pinpoint the breaking line using log or commenting out lines of code (although the culprit is probably defined in the general logging, described in the section at the bottom).
3: There is no official documentation. They have some outdated tutorials for GNOME Shell 3.4 with a small difference explanation to 3.6, a few pages on the C(++) ends of the libraries you use (most of the functions, variables and constants use the same names though), but for any real info you'd need experience, digging through other GNOME and shell extension code or some unofficial sources. Unofficial sources aren't always up to date, however.
Up to date generated docs at RooJS, although at least events are off as they are separated with - (minus) rather than _ (underscore).
Old, but mostly useful documentation, MathematicalCoffee has more useful things, like in depth explained code that is quite a solid learning source.
Generated docs, almost everything is there, very extensive, but sometimes the site drops offline for a few days. You could try to clone the git repo to run it locally, but the readme.md is a verbatim copy of what they forked...
More recent reference made by a user, although this is quite extensive, it's not of much use if you're on an older version of GNOME Shell, as deprecated and old is more likely to work than next gen stuff.
I recommend checking the official extensions website and go through whatever interesting extensions' source code you can get, as that is your best bet to learn anything.
Generally Debugging gnome can be done in several ways.
- use the log() function and follow journalctl in a commandline, check either GNOME or JS, use journalctl -f | grep -i js (or use grep -i gnome). You will see some warnings no matter what, but most mention what extension they're from. This is nice and works on all distros implementing systemd
- Or log a specific process that is a part of GNOME like journalctl /usr/bin/gnome-session -f -o cat, just beware that some distros and versions log to different files and old GNOME versions often log to whatever your display manager logs to.
- use the official (albeit tricky) manner of logging: GNOME on debugging.
I personally couldn't get this to work.
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
I'm looking to create a Ruby application with a command-prompt-based interface. By "command-prompt-interface," I mean something similar to irb, but note that I do not mean actually executing Ruby code. The gems I'm finding via Google seem to be more suited to CLIs like git, not an actual prompt like irb.
I need to be able to define commands and handlers for those commands, so something like:
(prompt) helloworld
Hello World
(prompt)
Validation and a built-in help system would also be good extras, as would the ability to execute a single command from the command line (calling it from the shell cliapp.rb -c helloworld).
I'm able to create this from scratch, but if there are any libraries available I'd prefer to use that rather than reinventing the wheel.
You may want to try Methadone, which was created by David Bryant Copeland, the author of the book "Build Awesome Command-Line Apps in Ruby". You may want to check out the book as well.
See this blog post for more information.
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 ;-)