NAME
App::WRT::EntryStore - model the contents of a wrt repo's entry_dir
SYNOPSIS
use App::WRT::EntryStore;
my $entries = App::WRT::EntryStore->new('./archives');
my @all = $entries->all();
my @months = $entries->all_months();
my @years = $entries->all_years();
my @days = $entries->all_days();
# all_* are wrappers for dates_by_depth():
my @days = $entries->dates_by_depth(
3 # 1 for years, 2 for months, 3 for days
);
my @recent_days = $entries->recent_days(30);
my @recent_months = $entries->recent_months(12);
my @recent_years = $entries->recent_years(10);
# recent_* are wrappers for recent_by_depth():
my @recent_days $entries->recent_by_depth(
3, # 1 for years, 2 for months, 3 for days
30 # count
);
METHODS
- new($class, $entry_dir)
-
Get a new EntryStore, using a given $entry_dir.
Finds a list of entries for the given directory, and builds data structures which can be used to index into entries by depth, property, and next/previous entry.
- all()
-
Returns a list of all source files for the current entry archive (excepting index files, which are a special case - this part could use some work).
This was originally in App::WRT::Renderer, so there may be some pitfalls here.
- dates_by_depth($depth)
-
Returns a sorted list of all date-like entries which are at a specified depth. Use 1 for years, 2 for months, and 3 for days.
Fairly silly, but entertaining in its perverse way. all_years(), all_months(), and all_days() are provided for convenience.
- all_years(), all_months(), all_days()
-
Convenience wrappers for dates_by_depth().
- days_for($month), months_for($year)
-
Convenience wrappers for extracting days or months in a given month or year.
- recent_by_depth($depth, $entry_count)
-
Returns the $entry_count most recent dated entries at $depth (1 for year, 2 for month, 3 for day). recent_years(), recent_months(), and recent_days() are provided for convenience.
- all_years(), all_months(), all_days()
-
Convenience wrappers for recent_by_depth().
- generate_date_hashes()
-
Store hashes which map dated entries to their previous and next entries at the same depth in the tree. That is, something like:
%prev_dates = { '2014' => '2013', '2014/1' => '2013/12' '2014/1/1' => '2013/12/30', ... } %next_dates = { '2013' => '2014', '2013/12' => '2014/1', '2013/12/30' => '2014/1/1', ... }
- parent($entry)
-
Return an entry's parent, or undef if it's at the top level.
- children($entry)
-
Return an entry's (immediate) children.
- previous($entry)
-
Return the previous entry at the same depth for the given entry.
- next($entry)
-
Return the next entry at the same depth for the given entry.
- by_prop($property)
-
Return an array of any entries for the given property.
- props_for($entry)
-
Return an array of any properties for the given entry.
- has_prop($entry, $prop)
-
Return 1 if the given entry has the given property.
- all_props()
-
Return an array of all properties.
- is_extant($entry)
-
Check if a given entry exists.
- is_dir($entry)
-
Check if an entry is a directory.
- is_file($entry)
-
Check if an entry is a flatfile.
- has_index($entry)
-
Check if an entry contains an index file.
TODO: Should this care about the pathological(?) case where index is a directory?
- basename($entry)
-
Get a base name (i.e., filename without path) for a given entry.