I'd like to create a progress bar to indicate the status of an a batch job in Ruby.
I've read some tutorials / libraries on using (n)curses, none of which were particularly helpful in explaining how to create an "animated" progress bar in the terminal or using curses with Ruby.
I'm already aware of using a separate thread to monitor the progress of a given job, I'm just not sure how to proceed with drawing a progress bar.
Update
ProgressBar class was incredibly straight-forward, perfectly solved my problem.
You might be able to get some implementation ideas from the Ruby/ProgressBar library, which generates text progress bars. I stumbled across it a couple of months back but haven't made any use of it.
Very late answer and sorry for self promotion, but I created library to show progress in terminal.
Personally I think curses is overkill in this case. While the curses lib is nice (and I frequently use it myself) it's a PITA to relearn every time I haven't needed it for 12 months which has to be the sign of a bad interface design.
If for some reason you can't get on with the progress bar lib Joey suggested roll your own and release it under a pretty free licence for instant kudos :)
On windows, curses works out of the box, ncurses doesn't, and for a progress bar curses should be sufficient. So, use curses instead of ncurses.
Also, both curses and ncurses are wafer-thin wrappers around the c library - that means you don't really need Ruby-specific tutorials.
However, on the site for the PickAxe you can download all the code examples for the book. The file "ex1423.rb" contains a curses demo which plays Pong - that should give you plenty of material to get you going.
Related
I am looking for some tool that supports me in refactoring ruby code.
I know that it is very hard to implement these kind of tools for a dynamic language like ruby, but I also know there are different solutions for RubyMine and Vim to help with basic stuff like "extract method" and "rename method".
It does not seem very practical to have multiple editors / IDEs open, so I am searching something specifically for emacs.
There is a project called ruby-refactor with recent activity. It can be installed through MELPA. It was inspired by a plugin for Vim called vim-refactoring-ruby. It seems to work well upon my first impression.
I don't know if this will be exactly what you looking for, but maybe you can take a look at
Rdefs
Rdefs is a tiny Ruby script that extracts class, module, method,
attribute definitions from a given Ruby source code.
Use Rdefs with Emacs
You might want to put etc/rdefs.el into your elisp directory and add
something like this to your dot.emacs:
(require 'rvm)
(rvm-use-default)
(require 'rdefs)
Hope it helps a bit... but anyway there seem to be no alternatives at the moment.
You could also try and check Rsense status:
RSense is a Ruby development tools, which is specialized for high
function text editors such as Emacs, Vim, etc. Following UNIX
philosophy, RSense has a high transparency and is easy to learn,
extend and fix for users. Adopting copyleft license, it also keeps
being a free software.
In the future, the following features will be available:
Static code checking
Caller jump
Refactoring
But there has been no activity on the project github page for 1 year now (new branch for v 2.0)
Maybe you could try to get in contact with the author...
I am trying to work with FranTK in order to make some examples to work for class. But cant go further the installation process (cabal install may be to mainstream).
I've gotten it from http://src.gnu-darwin.org/ports/x11-toolkits/hs-frantk/work/
in the readme a directory above it says i need to compile TclHaskellSrc, then FranSrc, then FranTkSrc. but i dont know how.
It also says it works with ghc-5, will it work with ghc-7?
has someone already use it successfully?
FRAN is outdated, bitrotted, and will almost certainly not compile under GHC 7. (See Conal Elliott's page for confirmation of this.) It was supposed to have been followed up with successors Reactive and FieldTrip, but, if I remember correctly, these projects hit a snag over OpenGL implementation issues.
If you're looking for good demos of FRP animation, then you'll be better off with one of the following:
elerea - it's simple, and has several good examples
sodium - also simple, and also has several good examples
reactive-banana - More complex than the other two, and more intended for GUI programming than for animation. Still worth a look, as it is well-documented and actively maintained.
The state of the art for FRP used to be Yampa, but I'd recommend against using either it or its recent fork Animas, not because they're bad in any way, but rather because they use Arrows, which tend to overcomplicate an already-difficult subject.
Hope this helps.
Old thread, I know, but Elm (elm-lang.org) has come along in the meantime. It compiles down the JavaScript, supports animations easily, and is under active development.
I am using Ruby 1.9.1p430 (2010-08-16 revision 28998) on MS Ws7 with MS Office 2010
I have launched a copy of Word from Ruby using WIN32OLE:
wd = WIN32OLE.new('Word.Application')
All works fine, I can manipulate my document as required.
However, the Word window is in the background and I would like to bring it to the foreground so that the user sees the window and can interact with it as necessary.
I have done some reading but cannot find a way to do this using Ruby.
Any help or pointers in the right direction greatly appreciated.
You are using
wd.visible = true
And it is still in the background?
Good luck :-)
Unfortunately, that sort of thing is both os specific, and not in the standard libs, so it is going to be tough. First thing is dig through the WIN32OLE docs a bit http://ruby-doc.org/stdlib/libdoc/win32ole/rdoc/index.html, but I don't think it will be there.
after that, I would poke around github a bit (although I wouldn't hold out too much hope).
After that, I would look at http://www.autoitscript.com/autoit3/index.shtml (or something like it), and see if I could use that or integrate with it somehow.
finally, I would look at how http://win32utils.rubyforge.org/ handles api wrapping, figure out the win32 api call you need, and then write a c extension wrapper for it.
I've done quite a bit of research on Ruby GUI design, and it appears to be the one area where Ruby tends to be behind the curve. I've explored the options of MonkeyBars, wxRuby, fxRuby, Shoes, etc. and was just wanted to get some input from the Ruby community.
While they're definitely usable, the development on each seems to have fallen off. There is not a great deal of useful documentation or user bases that I could find on any (minus the fxRuby book). I'm just looking to make a simple GUI, so I don't really want to spend hundreds of hours learning the intricacies of the more complex tools or attempt to use something that is no longer even being developed (Shoes is the type of application I'm looking for, but it's extremely buggy and not being actively developed.) Out of all of the options, which would you guys recommend as being the quickest to pick up and that still has some sort of development base?
Thanks!
I don't know what you mean by Shoes being extremely buggy. It works perfectly fine for building your own little application :-)
Yes there are problems with shoes3 and packaging/installer. However the community is one of the nicest I ever saw. Always nice and helpful figuring out problems. You can reach the mailing list at shoes#librelist.com.
If you're looking for basic information Nobody Knows Shoes and the shoes manual are your best friends.
However we are currently working on shoes 4 - which is a complete rewrite having multiple backends in mind - first backend being jruby/swt
So I would definitely recommend shoes :-)
Shoes on!
I've been looking at similar needs and am considering picking up a javascript gui library like Dojo or Sproutcore; or using JRuby + Netbeans for a Java based GUI.
For me, Aptana was a nice environment to start trying the javascript libraries to test the pain starting the learning curve. I'm still trying to find time to finsh my comparison.
http://en.wikibooks.org/wiki/Ruby_Programming/GUI_Toolkit_Modules
might help
limelight looks interesting
You might try:
DialogBlocks to create an XRC file using wxWidgets / wxRuby
xrcise - to create a ruby file to load the XRC
I am faced with the task of writing many small GUI's and a few
that are complicated. The above has worked for me. While the
above works on Windows, I can only vouch for the Linux implementations
which work very nicely.
FYI: DialogBlocks will run you about $100. It will create C++
or XRC files. It is also good at switching platforms. I think
there's a demo version.
My version info:
ruby 1.9.1p243
wxWidgets 2.8.10
wxRuby 2.0.1
DialogBlocks 4.28
wx_sugar 0.1.22 (for xrcise)
I'm still trying to get a handle on Cocoa (both in Obj-C and MacRuby), and I'd really appreciate seeing how to download a file with ASIHTTPRequest (or without it) and MacRuby. Ideally, I'd like to be able show the progress inside a progress bar too.
Must use a cocoa method for downloading, since open-uri in MacRuby is borken.
Thanks for your help.
Here is an example app doing exactly that using HotCocoa: http://github.com/richkilmer/hotcocoa/tree/master/examples/download_and_progress_indicator
You would have to convert it to normal Cocoa but if you look at http://github.com/richkilmer/hotcocoa/blob/master/examples/download_and_progress_indicator/lib/application.rb you will see the main callbacks defined.
You might want to ask your questions in the MacRuby mailing so people involved with the project can help.
Matt
p.s: The cocoa IO methods are way more stable and efficient than Ruby's. Also keep in mind that you want to do async calls, something net/http won't help you with.
Here are more explanations and an example from the book I'm writting: http://macruby.labs.oreilly.com/ch03.html#_urls_requests_connections Hopefully that will help.