Dne 05. 06. 2013 11:40, pi�e Hassan Schroeder:
> On Wed, Jun 5, 2013 at 1:07 AM, Sebastjan Hribar
> <
sebastja...@gmail.com> wrote:
>
>> return completed_projects ###########################
>> file.close
>> I have a problem when I use the commented lines as well to populate the
>> array. The array completed_projects gets populated, but items do not get
>> unlinked. If I only unlink the items without generating and populating the
>> array as seen above, everything works fine.
>> I need this array to use it for moving the respective folders to an archive.
>>
>> Is this related to nokogiri or have I made a pure ruby mistake?
> As soon as you call `return` your method ends; nothing past that point
> is going to be executed. (Try putting some print statements in to see.)
>
> All you need to do is put 'completed_projects' as the last statement
> of the method.
You're right of course. I found out what the problem was. This is my
first project that I'm trying to do on BDD principles and I'm using
minitest. The problem was in my poorly written test.
> BTW, there's no reason to write the file twice; you can reparse the
> 'doc' in memory before writing it out to the file.
>
How can I reparse an in memory document? Do I even need "doc2" variable
then? Because
doc2 = Nokogiri::XML(doc) {|x| x.noblanks}
where I try to parse the doc which is the in memory document, doesn't
work. I get this:
/home/sebah/.rvm/gems/ruby-1.9.3-p392/gems/nokogiri-1.5.9/lib/nokogiri/xml/document.rb:53:in
`parse': undefined method `empty?' for
#<Nokogiri::XML::Document:0x000000008f5160> (NoMethodError)
from
/home/sebah/.rvm/gems/ruby-1.9.3-p392/gems/nokogiri-1.5.9/lib/nokogiri/xml.rb:33:in
`XML'
from xml1.rb:24:in `remove_completed'
from xml1.rb:33:in `<main>'
Apart from that, my archiver is complete. The final step is the gui
(green_shoes).
regards,
seba