Beagle

 view release on metacpan or  search on metacpan

lib/Beagle/Backend/base.pm  view on Meta::CPAN

                $file{ $dir . $left } = {
                    path    => decode( locale_fs => $path ),
                    content => decode_utf8 <$fh>,
                };
            }
        }
    }
    return %file;
}

sub update {
    my $self   = shift;
    my $object = shift;
}

sub delete {
    my $self   = shift;
    my $object = shift;
}

sub updated {
    my $self = shift;
}

no Any::Moose;
__PACKAGE__->meta->make_immutable;

1;
__END__


lib/Beagle/Backend/fs.pm  view on Meta::CPAN

extends 'Beagle::Backend::base';

sub create {
    my $self   = shift;
    my $object = shift;
    return unless -e $self->encoded_root;
    my %args = (@_);
    $self->_save( $object, %args );
}

sub update {
    my $self         = shift;
    my $object       = shift;

    my $path = $object->path;
    return unless $path;

    if (   $object->can('original_path')
        && $object->original_path
        && $object->original_path ne $object->path )
    {

lib/Beagle/Backend/fs.pm  view on Meta::CPAN

        unless ( $object->can('is_raw') && $object->is_raw ) {
            $string = encode_utf8 $string;
        }
        print $fh $string;
        close $fh;
    }

    return 1;
}

sub updated {
    my $self = shift;
    my $updated = 0;

    require File::Find;
    File::Find::find(
        sub {
            return unless -f && $_ !~ /^\./;
            my $mt = (stat)[9];
            $updated = $mt if $updated < $mt;
        },

lib/Beagle/Backend/git.pm  view on Meta::CPAN

    local ( $ENV{GIT_AUTHOR_NAME}, $ENV{GIT_AUTHOR_EMAIL} ) =
      $self->_find_git_author($object);
    $ENV{GIT_AUTHOR_NAME}  ||= $self->git->config( '--get', 'user.name' );
    $ENV{GIT_AUTHOR_EMAIL} ||= $self->git->config( '--get', 'user.email' );

    my %args = (@_);
    $args{'message'} ||= $object->commit_message;
    $self->_save( $object, %args );
}

sub update {
    my $self   = shift;
    my $object = shift;

    my $path = $object->path;
    return unless $path;

    my $ret = 1;

    if (   $object->can('original_path')
        && $object->original_path

lib/Beagle/Backend/git.pm  view on Meta::CPAN


    if ( $self->git->has_changes_indexed ) {
        ($ret) = $self->git->commit( -m => $args{message} || 'save ' . $path );
        return $ret;
    }
    else {
        return 1;
    }
}

sub updated {
    my $self = shift;
    my ( $ret, $updated ) = $self->git->log( '-n1', '--format=%H', 'HEAD' );
    return unless $ret;
    chomp $updated if $updated;
    return $updated;
}

sub _find_git_author {
    my $self  = shift;
    my $entry = shift;

lib/Beagle/Handle.pm  view on Meta::CPAN


        my $updated = $self->backend->updated;
        $self->updated($updated) if $updated;
        $self->update_cache;
        $self->update_relation;
    }

    return $self;
}

sub update_cache {
    my $self = shift;
    return unless enabled_cache();

    unless ( -e $self->cache ) {
        my $parent = parent_dir( $self->cache );
        make_path($parent) or die $! unless -e $parent;
    }

    require Storable;
    Storable::nstore( $self, $self->cache );
}

sub update_relation {
    my $self = shift;
    my $map  = relation();
    for my $key ( keys %$map ) {
        delete $map->{$key}
          if $map->{$key} eq $self->name;
    }
    for my $entry ( @{ $self->comments }, @{ $self->entries } ) {
        $map->{ $entry->id } = $self->name if $entry->can('id');
    }
    set_relation($map);

lib/Beagle/Handle.pm  view on Meta::CPAN

    my $self = shift;

    my %ret;

    return map { $_ => $self->$_ } qw/info total_size sites
      map attachments_map comments_map updated
      entry_types
      /, map { $type_info->{$_}{plural} } keys %$type_info;
}

sub update_info {
    my $self = shift;
    my $info = shift;
    my %args = @_;
    my $message = 'update info';
    $message .= "\n\n" . $args{message} if defined $args{message};
    $message .= "\n\n" . $info->commit_message if $info->commit_message;
    return unless $self->backend->update( $info, @_, message => $message );
    $self->info($info);
    return 1;
}

sub update {
    my $self    = shift;
    my $updated = $self->backend->updated;
    my $map     = $self->map;

    if ( $self->updated != $updated ) {
        $self->map( {} );
        $self->init_info;
        $self->init_entries;

        $self->init_attachments;

lib/Beagle/Handle.pm  view on Meta::CPAN

            $self->comments_map->{ $entry->parent_id }{ $entry->id } = $entry;
        }
        else {
            my $attr = PL($type);
            $self->$attr( [ $entry, @{ $self->$attr || [] } ] );
        }
    }
    return 1;
}

sub update_entry {
    my $self   = shift;
    my $entry  = shift;
    my $type   = $entry->type;
    my $method = "update_$type";
    if ( $self->can($method) ) {
        return $self->$method( $entry, @_ );
    }
    else {
        my %args = @_;
        my $message =

lib/Beagle/Role/Date.pm  view on Meta::CPAN

sub created_month {
    my $self = shift;
    return $self->format_date( '%m', $self->created );
}

sub created_day {
    my $self = shift;
    return $self->format_date( '%d', $self->created );
}

sub updated_string {
    my $self = shift;
    return $self->format_date( '%Y-%m-%d %T %z', $self->updated );
}

sub updated_year {
    my $self = shift;
    return $self->format_date( '%Y', $self->updated );
}

sub updated_month {
    my $self = shift;
    return $self->format_date( '%m', $self->updated );
}

sub updated_day {
    my $self = shift;
    return $self->format_date( '%d', $self->updated );
}

no Any::Moose 'Role';
1;
__END__


=head1 AUTHOR

lib/Beagle/Web.pm  view on Meta::CPAN

            $category = join ', ', $category, $entry->type,
              from_array( $entry->tags );
        }
        $item->category($category);
    }

    $feed->normalize();
    return $feed{$name} = $feed;
}

sub update_feed {
    shift @_ if @_ && $_[0] eq 'Beagle::Web';
    my $bh = shift;
    delete $feed{ $bh->name };
    feed($bh);
}

my %archives;
my %tags;

use Storable 'dclone';

lib/Beagle/Web.pm  view on Meta::CPAN

    my $archives = {};
    for my $entry ( @{ $bh->entries } ) {
        push @{ $archives->{ $entry->created_year }{ $entry->created_month } },
          $entry;
    }

    $archives{$name} = $archives;
    return dclone($archives);
}

sub update_archives {
    shift @_ if @_ && $_[0] eq 'Beagle::Web';
    my $bh = shift;
    delete $archives{ $bh->name };
    archives($bh);
}

sub tags {
    shift @_ if @_ && $_[0] eq 'Beagle::Web';
    my $bh   = shift;
    my $name = $bh->name;

lib/Beagle/Web.pm  view on Meta::CPAN

            for my $tag ( @{ $entry->tags } ) {
                push @{ $tags->{$tag} }, $entry;
            }
        }
        push @{ $tags->{ $entry->type } }, $entry;
    }
    $tags{$name} = $tags;
    return dclone($tags);
}

sub update_tags {
    shift @_ if @_ && $_[0] eq 'Beagle::Web';
    my $bh = shift;
    delete $tags{ $bh->name };
    tags($bh);
}

sub field_list {
    shift @_ if @_ && $_[0] eq 'Beagle::Web';
    my $entry = shift;
    my @list  = (



( run in 0.419 second using v1.01-cache-2.11-cpan-95122f20152 )