| 1 | package Neovim::Ext::RemoteMap; | ||||||||||||||||||||
| 2 | 56 | $Neovim::Ext::RemoteMap::VERSION = '0.01'; | |||||||||||||||||||
| 3 | 56 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 56 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 56 | ▶ | use Carp qw/croak/; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 56 | ▶ | use Class::Accessor; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 56 | ▶ | use Tie::Hash; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 56 | our @ISA = (qw/Class::Accessor Tie::Hash/); | |||||||||||||||||||
| 10 | 56 | __PACKAGE__->mk_accessors (qw/nvim get_method set_method del_method/); | |||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | sub TIEHASH | ||||||||||||||||||||
| 14 | { | ||||||||||||||||||||
| 15 | 33 | ▶ | my ($this, $nvim, $get_method, $set_method, $del_method) = @_; | ||||||||||||||||||
|
Subroutine
TIEHASH: called CC=2 SCAR=7.4
| |||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 33 | ▶ | my $class = ref ($this) || $this; | ||||||||||||||||||
|
Condition33%1/3
ref $this || $this
MC/DC0%0/2
ref $this || $this
ref $this
$this
Truth table33%1/3
A || B
A= ref $thisB= $this
| |||||||||||||||||||||
| 18 | 33 | my $self = | |||||||||||||||||||
| 19 | { | ||||||||||||||||||||
| 20 | nvim => $nvim, | ||||||||||||||||||||
| 21 | get_method => $get_method, | ||||||||||||||||||||
| 22 | set_method => $set_method, | ||||||||||||||||||||
| 23 | del_method => $del_method, | ||||||||||||||||||||
| 24 | }; | ||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | 33 | return bless $self, $class; | |||||||||||||||||||
| 27 | } | ||||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | sub STORE | ||||||||||||||||||||
| 32 | { | ||||||||||||||||||||
| 33 | 3 | ▶ | my ($this, $key, $value) = @_; | ||||||||||||||||||
|
Subroutine
STORE: called CC=2 SCAR=7.1
| |||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | 3 | ▶ | croak "not available" if (!$this->set_method); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 36 | 3 | $this->nvim->request ($this->set_method, $key, $value); | |||||||||||||||||||
| 37 | } | ||||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | sub FETCH | ||||||||||||||||||||
| 42 | { | ||||||||||||||||||||
| 43 | 11 | ▶ | my ($this, $key) = @_; | ||||||||||||||||||
|
Subroutine
FETCH: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 44 | 11 | $this->nvim->request ($this->get_method, $key); | |||||||||||||||||||
| 45 | } | ||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | sub DELETE | ||||||||||||||||||||
| 50 | { | ||||||||||||||||||||
| 51 | 0 | ▶ | my ($this, $key) = @_; | ||||||||||||||||||
|
Subroutine
DELETE: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | 0 | ▶ | croak "not available" if (!$this->del_method); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 54 | 0 | my $value = $this->FETCH ($key); | |||||||||||||||||||
| 55 | 0 | $this->nvim->request ($this->del_method, $key); | |||||||||||||||||||
| 56 | 0 | return $value; | |||||||||||||||||||
| 57 | } | ||||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | sub EXISTS | ||||||||||||||||||||
| 62 | { | ||||||||||||||||||||
| 63 | 0 | ▶ | my ($this, $key) = @_; | ||||||||||||||||||
|
Subroutine
EXISTS: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | 0 | my $result = eval { $this->nvim->request ($this->get_method, $key); }; | |||||||||||||||||||
| 66 | 0 | return !!$result; | |||||||||||||||||||
| 67 | } | ||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | sub new | ||||||||||||||||||||
| 72 | { | ||||||||||||||||||||
| 73 | 33 | ▶ | my $this = shift; | ||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | 33 | tie my %hash, 'Neovim::Ext::RemoteMap', @_; | |||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | 33 | return \%hash; | |||||||||||||||||||
| 78 | } | ||||||||||||||||||||
| 79 | |||||||||||||||||||||
| 80 | |||||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | sub fetch | ||||||||||||||||||||
| 83 | { | ||||||||||||||||||||
| 84 | 0 | ▶ | my ($this, $key, $default) = @_; | ||||||||||||||||||
|
Subroutine
fetch: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 85 | |||||||||||||||||||||
| 86 | 0 | ▶ | return eval { $this->nvim->request ($this->get_method, $key) } // $default; | ||||||||||||||||||
|
Condition0%0/3
eval {
do {
$this->nvim->request($this->get_method, $key)
}
} // $default
MC/DC0%0/2
eval {
do {
$this->nvim->request($this->get_method, $key)
}
} // $default
eval {
do {
$this->nvim->request($this->get_method, $key)
}
}
$default
Truth table0%0/3
A // B
A= eval {
do {
$this->nvim->request($this->get_method, $key)
}
}B= $default
| |||||||||||||||||||||
| 87 | } | ||||||||||||||||||||
| 88 | |||||||||||||||||||||
| 89 | |||||||||||||||||||||
| 90 | =head1 NAME | ||||||||||||||||||||
| 91 | |||||||||||||||||||||
| 92 | Neovim::Ext::RemoteMap - Neovim RemoteMap class | ||||||||||||||||||||
| 93 | |||||||||||||||||||||
| 94 | =head1 VERSION | ||||||||||||||||||||
| 95 | |||||||||||||||||||||
| 96 | version 0.01 | ||||||||||||||||||||
| 97 | |||||||||||||||||||||
| 98 | =head1 SYNOPSIS | ||||||||||||||||||||
| 99 | |||||||||||||||||||||
| 100 | use Neovim::Ext; | ||||||||||||||||||||
| 101 | |||||||||||||||||||||
| 102 | =head1 METHODS | ||||||||||||||||||||
| 103 | |||||||||||||||||||||
| 104 | =head2 new( $nvim, $get_method, [$set_method, $del_method]) | ||||||||||||||||||||
| 105 | |||||||||||||||||||||
| 106 | =head2 fetch( $key, $default ) | ||||||||||||||||||||
| 107 | |||||||||||||||||||||
| 108 | Return C<$key> if present, otherwise C<$default>. | ||||||||||||||||||||
| 109 | |||||||||||||||||||||
| 110 | =cut | ||||||||||||||||||||
| 111 | |||||||||||||||||||||
| 112 | 56 | 1; | |||||||||||||||||||