Gherkin/Dialect.pm

filter: Statementstmt 85.4% 41 / 48 Branchbran 40.0% 4 / 10 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 94.7% 18 / 19 Podpod 92.8% 13 / 14 totaltotal 81.9% 77 / 94 CC 7 SCAR 11.5
CC
7
Cov
77%
new
9.5
change_dialect
2.0
stepKeywordTypes
2.0
CRAP 3.2
« Gherkin/TokenMatcher.pm ↑ Summary App/gherkin.pm »
1 package Gherkin::Dialect;
2 1 $Gherkin::Dialect::VERSION = '42.0.1';
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use Cucumber::Messages;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Gherkin::Exceptions;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 ▶use Class::XSAccessor accessors =>
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 [ qw/_current_dialect dialect dictionary_location dictionary /, ];
11  
12 3 ▶sub new {
Subroutine new: called CC=6 SCAR=22.5
Pod documented
13 3 my ( $class, $options ) = @_;
14 3 ▶ $options->{'dialect'} ||= 'en';
Condition50%1/2
$options->{"dialect"} ||= "en"
l!l
30
MC/DC0%0/1
$options->{"dialect"} ||= "en"
$options->{"dialect"}
Truth table50%1/2
A
A= $options->{"dialect"}
Aresult
11
00
15  
16 3 ▶ unless ( $options->{'dictionary'} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($options->{"dictionary"}) 3 0 3
17  
18 # Load from a file if one was given
19 3 ▶ if ( my $filename = $options->{'dictionary_location'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $filename = $options->{'dictionary_location'}) { } 0 3 3
20 0 require Cpanel::JSON::XS;
21 0 ▶ open( my $fh, '<', $filename ) || die "Can't open [$filename]";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $filename or die "Can't open [$filename]" 0 0 0
22 0 my $input = join '', (<$fh>);
23 0 close $fh;
24 0 $options->{'dictionary'} = Cpanel::JSON::XS::decode_json($input);
25 } else {
26 ## no critic (ProhibitPackageVars)
27 3 require Gherkin::Generated::Languages;
28 3 $options->{'dictionary'} = $Gherkin::Generated::Languages::data;
29 ## use critic
30 }
31 }
32  
33 3 bless $options, $class;
34 $options->change_dialect( $options->{'dialect'} )
35 3 ▶ if $options->{'dialect'};
Branch: 1 branch
BranchTrueFalseTotal
if $options->{"dialect"} 3 0 3
36  
37 3 return $options;
38 }
39  
40 9 ▶sub change_dialect {
Subroutine change_dialect: called CC=2 SCAR=7.0
Pod documented
41 9 my ( $self, $name, $location ) = @_;
42 Gherkin::Exceptions::NoSuchLanguage->throw( $name, $location )
43 9 ▶ unless $self->dictionary->{$name};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->dictionary->{$name} 0 9 9
44 9 $self->{'dialect'} = $name;
45 9 $self->{'_current_dialect'} = $self->dictionary->{$name};
46 }
47  
48 3 ▶sub Feature { $_[0]->_current_dialect->{'feature'}; }
Subroutine Feature: called CC=1 SCAR=0.0
Pod documented
49 9 ▶sub Rule { $_[0]->_current_dialect->{'rule'}; }
Subroutine Rule: called CC=1 SCAR=0.0
Pod documented
50 15 ▶sub Scenario { $_[0]->_current_dialect->{'scenario'}; }
Subroutine Scenario: called CC=1 SCAR=0.0
Pod documented
51 3 ▶sub Background { $_[0]->_current_dialect->{'background'}; }
Subroutine Background: called CC=1 SCAR=0.0
Pod documented
52 6 ▶sub Examples { $_[0]->_current_dialect->{'examples'}; }
Subroutine Examples: called CC=1 SCAR=0.0
Pod documented
53 12 ▶sub Given { $_[0]->_current_dialect->{'given'}; }
Subroutine Given: called CC=1 SCAR=0.0
Pod documented
54 12 ▶sub When { $_[0]->_current_dialect->{'when'}; }
Subroutine When: called CC=1 SCAR=0.0
Pod documented
55 12 ▶sub Then { $_[0]->_current_dialect->{'then'}; }
Subroutine Then: called CC=1 SCAR=0.0
Pod documented
56 12 ▶sub And { $_[0]->_current_dialect->{'and'}; }
Subroutine And: called CC=1 SCAR=0.0
Pod documented
57 12 ▶sub But { $_[0]->_current_dialect->{'but'}; }
Subroutine But: called CC=1 SCAR=0.0
Pod documented
58  
59  
60 0 ▶sub stepKeywordTypes {
Subroutine stepKeywordTypes: not called CC=1 SCAR=6.9
Pod undocumented
61 0 return @{ $_[0]->{'_step_keywords'}->{$_[1]} };
62 }
63  
64 9 ▶sub ScenarioOutline {
Subroutine ScenarioOutline: called CC=1 SCAR=0.0
Pod documented
65 9 $_[0]->_current_dialect->{'scenarioOutline'};
66 }
67  
68 1 1;
69  
70  
71 __END__
« Gherkin/TokenMatcher.pm ↑ Summary App/gherkin.pm »