On Tue, 20 Aug 2013 12:48:26 +0200 Lukas Ocilka <lukas.ocilka@suse.com> wrote:
On 08/19/2013 05:19 PM, Josef Reidinger wrote:
Hi, because we have now ruby I want to show really simple way how we can refactor existing code. I choose just simple example to be easy to understand and on other hand full working. [1]
There is two interesting points in it. 1) using minitest for testing, its structure ( so you can imagine how it looks ) and how it can be easy integrated with automake ( nice part is that if you run `make check` then both testsuite is run, old and new one 2) Using ruby builtin regex, so we no longer need our own.
Just to add some more info on this refactoring piece. Josef has used a standard Ruby Resolv [1] class to replace our built-in functionality. This will save our time in the future as we don't need to care about our own implementation and saves some space as well as our implementation was a duplicate to standard Ruby library which will be installed anyway.
I like the idea and I expect that you will identify and replace more ;) This is actually something that anyone with a basic Ruby knowledge can do. It's could even be marked as, so called, junior job.
Well, it is questionable if it is junior job, as there can be small differences between ruby and our implementation, so it needs a lot of testing of corner cases and good knowledge both implementations if there is differences. And to be honest in this change I heavily believe in tests because compare these two regexp is too much for my brain :) [1][2] Also I need to consider what is better to use as there is also IPAddr class in ruby, which for me is better to use, but it is different concept then our, so it is not so elegant to refactoring of IP module ( but I strongly recommend to use it to replace IP module in ruby code because you can use it as object ) [3] Josef [1] https://github.com/ruby/ruby/blob/ruby_2_0_0/lib/resolv.rb#L2172 [2] https://github.com/yast/yast-yast2/blob/0e08c9b93c2c730e79ea36451ea715a5746d... [3] http://www.ruby-doc.org/stdlib-2.0/libdoc/ipaddr/rdoc/IPAddr.html
Bye Lukas
#1 http://ruby-doc.org/stdlib-1.9.2/libdoc/resolv/rdoc/Resolv.html
-- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org To contact the owner, e-mail: yast-devel+owner@opensuse.org