finanalyst/pod-cached

.update-cache functionality

Closed this issue · 5 comments

In order to only regenerate those files who have changed, I need to know the name of the files. Currently, I'm getting them parsing the output that .update-cache produces. This is a kind of a hack so it would be useful if .update-cache returns those names.

Mmm I saw .list-files but I'm having problems trying to use it. If I pass Pod::To::Cached::Valid (or some other) it just freezes. That's the example in the README.

I have taken a look to the signature and it accepts a string, so I pass the same .enum calling .gist it always return an empty list.

Is this the expected behavior or am i doing something wrong?

Ok, after seeing the test I have realized you need to pass this: 'Old', 'New' or similar. When you pass 'Current' it works fine, but I do not know how to get the files that has changed. I am using this code:

use Pod::To::Cached;

my $pod-cache = Pod::To::Cached.new(
    source => "doc",
    :verbose,
    path   => ".doc"
);

# $pod-cache.update-cache;

# This do not print anything (if I actually update the cache neither)
.say for $pod-cache.list-files( 'Old' );

I also must point out that Pod::To::Cached::Tainted do not exist in the enum (and it appears in the code example at the documentation).

First reactions:

  1. Tainted was in the first version of the Module, which was then changed. The tests were changed, but I did not catch it in the enum. This is an error, which I will fix.
  2. The .list-files was intended to avoid parsing the .update-cache output. But I'm glad you have a current work-around: it gives me a bit of time to sort out .list-files. And yes, the intent is to get an immediate list of only those files that need re-generating. If you are not getting this easily, I must fix it.
  3. .list-files is tested, and the tests pass. Look at test 22 (there is a marker comment). It looks like I will need to add some tests for other enum values not just Current and Valid.
  4. Also .list-files( :all ) should give you a hash structure with keys of file name, and status as value.
  5. Note that I tested .list-files with a list of strings, eg. .list-files(< Current Valid>), but you called with a scalar string .list-files('Old'). Perhaps try .list-files('Old',) Does this work?
  6. Let me know if I should amend the API to test for a single string, not just an array.

Thanks for the info. I have just realized that I have misunderstood the 'Old' value. I thought it was the replacement for 'Tainted', so when I called '.list-files' with 'Old', I expected to get the names of the modified pods. It looks like I should have used 'Valid'. I have tested it with lists and it works without any problems.

  1. It's funny because I have the exact work-around that list-file is trying to avoid.
  2. Maybe update the README with the current behavior.

Thanks a lot for your time. Good job with this module, it's making my work a lot easier. 💯 .