Archive for 15 de junho de 2008
Notificações de testes (Novidades)
Posted by alexandre in Linux, Open Source, Ruby on Rails, rails, ruby, tecnologia on junho 15, 2008
Mesmo os testes automatizados rodando perfeitamente com as nofitificações libnotify do gnome eu ainda não fiquei sossegado, afinal aquela mensagem ali na parte de baixo da tela (me lembrando os tempos de windows) não estava muito ao meu agrado, além de que segundos após a mensagem some e não há outro modo a não ser ir até o console para verificar o que havia acontecido (não que seja algo ruim, pois eu particularmente prefiro trabalhar sempre com a janela do editor não cobrindo a tela toda e ter o final da saida da linha de comando de um shell sempre visível). Pesquisando um pouquinho mais sobre o assunto dos testes automatizados e notificações encontrei este post, falando sobre o ruby-libnotify. Hum, vejamos, no post original o autor sugere que instalemos os seguintes componentes via apt-get:
ruby-gnome2 build-essential ruby1.8-dev libnotify-dev.
O detalhe é apenas que a biblioteca ruby-gnome2 (ao menos no Ubuntu) instala toda a parafernalha do Ruby/GTK, coisa que aparentemente não precisamos, uma vez que vamos dar um simples require 'gtk2' em nosso arquivo de configurações. Lendo os comentários do post havia um que dizia que o arquivo gtk2.rb pertencia à biblioteca libgtk2-ruby1.8 (que é instalada juntamente com o restante da parafernalha por ser um requisito da ruby-gnome2). Note que a instalação da libgtk2-ruby1.8 também vai instalar bastante dependências, mas acredito que sejam aproximadamente a metade dos pacotes.
Vamos a instalação e configuração:
primeiro, abra um terminal e vamos aos comandos.
$ sudo apt-get install libgtk2-ruby1.8 build-essential ruby1.8-dev libnotify-dev
ele vai instalar todas as dependências, mas são todos pacotes pequenos
Agora você vai precisar do pacote ruby-libnotify, baixar e instalar com os comandos:
$ wget -c http://rubyforge.org/frs/download.php/27134/ruby-libnotify-0.3.3.tar.bz2
$ tar -jxvf ruby-libnotify-0.3.3.tar.bz2
$ cd ruby-libnotify-0.3.3
$ ruby extconf.rb && make && sudo make install
Isso roda a configuração, compila e instala a extensão.
agora você precisa de uma versão modificada do arquivo .autotest do post anterior: (baixe aqui se tiver problemas com as aspas)
#!/usr/bin/env ruby
#
# Copyright (c) 2007 Thomas Weibel,
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
require 'rnotify'
require 'gtk2'
module Autotest::RNotify
class Notification
attr_accessor :verbose, :image_root, :tray_icon, :notification,
:image_pass, :image_pending, :image_fail
def initialize(timeout = 5000,
image_root = "#{ENV['HOME']}/.autotest_images" ,
verbose = false)
self.verbose = verbose
self.image_root = image_root
puts 'Autotest Hook: loading Notify' if verbose
Notify.init('Autotest') || raise('Failed to initialize Notify')
puts 'Autotest Hook: initializing tray icon' if verbose
self.tray_icon = Gtk::StatusIcon.new
tray_icon.icon_name = 'face-monkey'
tray_icon.tooltip = 'RSpec Autotest'
puts 'Autotest Hook: Creating Notifier' if verbose
self.notification = Notify::Notification.new('X', nil, nil, tray_icon)
notification.timeout = timeout
Thread.new { Gtk.main }
sleep 1
tray_icon.embedded? || raise('Failed to set up tray icon')
end
def notify(icon, tray, title, message)
notification.update(title, message, nil)
notification.pixbuf_icon = icon
tray_icon.tooltip = "Last Result: #{message}"
tray_icon.icon_name = tray
notification.show
end
def passed(title, message)
self.image_pass ||= Gdk::Pixbuf.new("#{image_root}/pass.png", 48,48)
notify(image_pass, 'face-smile', title, message)
end
def pending(title, message)
self.image_pending ||= Gdk::Pixbuf.new("#{image_root}/pending.png",48,48)
notify(image_pending, 'face-surprise', title, message)
end
def failed(title, message)
self.image_fail ||= Gdk::Pixbuf.new("#{image_root}/fail.png", 48,48)
notify(image_fail, 'face-sad', title, message)
end
def quit
puts 'Autotest Hook: Shutting Down...' if verbose
#Notify.uninit
Gtk.main_quit
end
end
Autotest.add_hook :initialize do |at|
@notify = Notification.new
end
Autotest.add_hook :ran_command do |at|
results = at.results.last
unless results.nil?
# Test::Unit
if results.include? 'tests'
output =
results[/(\d+)\s+tests?,\s*(\d+)\s+assertions?,\s*(\d+)\s+failures?(,\s*(\d+)\s+errors)?/]
if output
failures = $~[3].to_i + $~[5].to_i
end
# RSpec
else
output =
results[/(\d+)\s+examples?,\s*(\d+)\s+failures?(,\s*(\d+)\s+pending)?/]
if output
failures = $~[2].to_i
pending = $~[4].to_i
end
end
if failures > 0
@notify.failed("Tests Failed", output)
elsif pending > 0
@notify.pending("Tests Pending", output)
else
unless at.tainted
@notify.passed("All Tests Passed", output)
else
@notify.passed("Tests Passed", output)
end
end
end
end
Autotest.add_hook :quit do |at|
@notify.quit
end
end
opcionalmente você pode baixar diretamente do post do autor, um arquivo zip contendo o .autotest e as imagens
não esqueça que o arquivo deve ficar dentro de sua pasta HOME



as Imagens utilizadas foram baixadas daqui. para utilizar com o script acima, baixe as imagens e descompacte dentro de um diretório chamado .autotest_images dentro de sua pasta HOME
The last programmer’s editor for Linux and Windows Part #1
Posted by alexandre in Linux, Open Source, Ubuntu, tecnologia on junho 15, 2008
UPDATE: Today I came back to Gedit, If you use Linux, don’t forget to see my posts about gedit:
- All related posts
- GTKSourceview improvements
- Gmate Project -> Collection of plugins and improvements to Gedit, to be used with Rails
- Rails Footnotes for Linux
I loved use Gedit as my favorite text editor last year, it was really util, I was maintaining a plugin to manage TODO marks. But some major force don’t want that my plugin works correctly in new Ubuntu version, I don’t know the real cause, but seems to be related with url-handlers, and I don’t got it working as it worked in previous ubuntu and Firefox Version. After some headaches, and without enough time to solve the problem, I decided to try another programmer’s editor… 99% of searches the replies are: TextMate, Vim, Emacs.
Well, for now I am not a happy MacBook owner, I cannot use the “Number One”, for me the last two are choices, and for mac users all are available
. All are great editors, I use Vim without any problems, to edit config files and another minor edits, I know how to use most of its features, by the other hand, the Emacs I had just some little testings some time ago, and I see it is also a great editor,for both is possible enable code completion to Python and Ruby, the languages I am working on.
Everything great, everything beautiful, a lot of “plugins” available for both, and the Vim is a very powerful editor. (For all those newbies to Vim/Gvim/vi, there is a config (customization) called Cream, that make the use for Vim very easy without loose the power and get the use of Vim very similar to another Gnome applications such as Gedit). But, nor Vim neither Emacs are the editors I was looking for. I want something powerfull and, at same time simple as Gedit.
So I found jEdit. No it’s not a typo, is jEdit (in Portuguese you spell same as Gedit), but jEdit is really a Java Written Programmers Editor, by this way it is cross-platform, and I was tested by me in a Windows computer and in mine laptop Ubuntu(hardy).
After some tests and…. the best editor I already been used.
Some features:
- Multiplatform
- Filebrowser
- Customizable by language
- Easy to add support to new programmming languages
- A lot of plugins available
- Macros
- Integrated console[plugin]
- Integrated SCM (SVN, CVS, etc) [plugin]
- Search by regular expressions
- Code completion [plugin]
- Text Autocomplete [plugin]
- Diff [plugin]
- Task List (TODO List similar to my Gedit plugin) [plugin]
- SuperAbbrevs (Code Snippets) [plugin]
- Tabbed Documents(and another inteligent modes to change between files) [plugin]
- Code Folding
- Sintax Highlight very complete
- and more…
Some screenshots:




is really a good choice install and test in your computer… it’s free, its OpenSource.




