Sélectionner une révision Git
-
Alexandre Morignot a rédigé
hopefully this will help !cycle
Alexandre Morignot a rédigéhopefully this will help !cycle
query.pm 1,97 Kio
package commands::get::query;
use Moose;
use overload '~~' => \&_equals;
use Scalar::Util qw(looks_like_number);
has 'query' => (
is => 'ro',
isa => 'Str',
required => 1
);
has 'chan' => (
is => 'ro',
isa => 'Str',
required => 1
);
has 'is_global' => (
is => 'ro',
isa => 'Bool',
lazy => 1,
builder => '_build_is_global',
init_arg => undef
);
has 'tags' => (
is => 'ro',
isa => 'ArrayRef[Str]',
lazy => 1,
builder => '_build_tags',
init_arg => undef
);
has 'words' => (
is => 'ro',
isa => 'ArrayRef[Str]',
lazy => 1,
builder => '_build_words',
init_arg => undef
);
has 'id' => (
is => 'ro',
isa => 'Int',
lazy => 1,
builder => '_build_id',
init_arg => undef
);
sub _build_is_global {
my $self = shift;
if ($self->chan !~ /^#/ || $self->query =~ /(^|\s)-a(ll)?($|\s)/) {
return 1;
} else {
return 0;
}
}
sub _build_tags {
my $self = shift;
my $query = $self->query;
$query =~ s/(^|\s)-a(ll)?($|\s)//;
return [$query =~ /#([a-zA-Z0-9_-]+)/g];
}