App-SimplenoteSync
view release on metacpan or search on metacpan
lib/App/SimplenoteSync/Note.pm view on Meta::CPAN
package App::SimplenoteSync::Note;
$App::SimplenoteSync::Note::VERSION = '0.2.1';
# ABSTRACT: stores notes in plain files,
use v5.10;
use Moose;
use MooseX::Types::Path::Class;
use Try::Tiny;
use namespace::autoclean;
extends 'WebService::Simplenote::Note';
use Method::Signatures;
has '+title' => (trigger => \&_title_to_filename,);
has file => (
is => 'rw',
isa => 'Path::Class::File',
coerce => 1,
traits => ['NotSerialised'],
trigger => \&_has_markdown_ext,
predicate => 'has_file',
);
has file_extension => (
is => 'ro',
isa => 'HashRef',
traits => ['NotSerialised'],
default => sub {
{
default => 'txt',
markdown => 'mkdn',
};
},
);
has notes_dir => (
is => 'ro',
isa => 'Path::Class::Dir',
traits => ['NotSerialised'],
required => 1,
default => sub {
my $self = shift;
if ($self->has_file) {
return $self->file->dir;
} else {
return Path::Class::Dir->new($ENV{HOME}, 'Notes');
}
},
);
has ignored => (
is => 'rw',
isa => 'Bool',
traits => ['NotSerialised'],
default => 0,
);
# set the markdown systemtag if the file has a markdown extension
method _has_markdown_ext(@_) {
my $ext = $self->file_extension->{markdown};
if ($self->file =~ m/\.$ext$/ && !$self->is_markdown) {
$self->set_markdown;
}
return 1;
( run in 0.853 second using v1.01-cache-2.11-cpan-39bf76dae61 )