1234567891011121314151617181920212223242526272829303132333435363738
  1. package SugarTrail::Repo;
  2. # provide access to STM objects
  3. #
  4. # * load_master()
  5. use strict;
  6. use warnings;
  7. use Carp;
  8. use helper;
  9. use SugarTrail::Template::Master;
  10. # initialize repo
  11. sub new {
  12. my $class = shift;
  13. my $args = { @_ };
  14. exists($args->{type}) or $args->{type} = 'SugarTrail::Repo::Filesystem';
  15. $class = $args->{type};
  16. #TODO: remove use fail
  17. use SugarTrail::Repo::Filesystem;
  18. return $class->new(%$args);
  19. }
  20. sub load_master {
  21. my $self = shift;
  22. my $args = { @_ };
  23. my $src = $args->{source};
  24. my $master = SugarTrail::Template::Master->new();
  25. $master->{source} = $src;
  26. $master->{revision} = $self->get_revision($src);
  27. $master->{text} = $self->load_text($src)
  28. or return;
  29. return $master;
  30. }
  31. 1;