line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Gherkin::Dialect; |
2
|
|
|
|
|
|
|
$Gherkin::Dialect::VERSION = '25.0.2'; |
3
|
1
|
|
|
1
|
|
8
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use Cucumber::Messages; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
17
|
|
7
|
1
|
|
|
1
|
|
4
|
use Gherkin::Exceptions; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
|
|
6
|
use Class::XSAccessor accessors => |
10
|
1
|
|
|
1
|
|
4
|
[ qw/_current_dialect dialect dictionary_location dictionary /, ]; |
|
1
|
|
|
|
|
3
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
3
|
|
|
3
|
1
|
8
|
my ( $class, $options ) = @_; |
14
|
3
|
|
50
|
|
|
11
|
$options->{'dialect'} ||= 'en'; |
15
|
|
|
|
|
|
|
|
16
|
3
|
50
|
|
|
|
9
|
unless ( $options->{'dictionary'} ) { |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Load from a file if one was given |
19
|
3
|
50
|
|
|
|
9
|
if ( my $filename = $options->{'dictionary_location'} ) { |
20
|
0
|
|
|
|
|
0
|
require Cpanel::JSON::XS; |
21
|
0
|
0
|
|
|
|
0
|
open( my $fh, '<', $filename ) || die "Can't open [$filename]"; |
22
|
0
|
|
|
|
|
0
|
my $input = join '', (<$fh>); |
23
|
0
|
|
|
|
|
0
|
close $fh; |
24
|
0
|
|
|
|
|
0
|
$options->{'dictionary'} = Cpanel::JSON::XS::decode_json($input); |
25
|
|
|
|
|
|
|
} else { |
26
|
3
|
|
|
|
|
560
|
require Gherkin::Generated::Languages; |
27
|
3
|
|
|
|
|
24
|
$options->{'dictionary'} = $Gherkin::Generated::Languages::data; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
3
|
|
|
|
|
9
|
bless $options, $class; |
32
|
|
|
|
|
|
|
$options->change_dialect( $options->{'dialect'} ) |
33
|
3
|
50
|
|
|
|
23
|
if $options->{'dialect'}; |
34
|
|
|
|
|
|
|
|
35
|
3
|
|
|
|
|
14
|
return $options; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub change_dialect { |
39
|
9
|
|
|
9
|
1
|
21
|
my ( $self, $name, $location ) = @_; |
40
|
|
|
|
|
|
|
Gherkin::Exceptions::NoSuchLanguage->throw( $name, $location ) |
41
|
9
|
50
|
|
|
|
36
|
unless $self->dictionary->{$name}; |
42
|
9
|
|
|
|
|
15
|
$self->{'dialect'} = $name; |
43
|
9
|
|
|
|
|
21
|
$self->{'_current_dialect'} = $self->dictionary->{$name}; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
3
|
|
|
3
|
1
|
14
|
sub Feature { $_[0]->_current_dialect->{'feature'}; } |
47
|
9
|
|
|
9
|
1
|
25
|
sub Rule { $_[0]->_current_dialect->{'rule'}; } |
48
|
15
|
|
|
15
|
1
|
41
|
sub Scenario { $_[0]->_current_dialect->{'scenario'}; } |
49
|
3
|
|
|
3
|
1
|
32
|
sub Background { $_[0]->_current_dialect->{'background'}; } |
50
|
6
|
|
|
6
|
1
|
20
|
sub Examples { $_[0]->_current_dialect->{'examples'}; } |
51
|
30
|
|
|
30
|
1
|
120
|
sub Given { $_[0]->_current_dialect->{'given'}; } |
52
|
30
|
|
|
30
|
1
|
99
|
sub When { $_[0]->_current_dialect->{'when'}; } |
53
|
30
|
|
|
30
|
1
|
76
|
sub Then { $_[0]->_current_dialect->{'then'}; } |
54
|
30
|
|
|
30
|
1
|
101
|
sub And { $_[0]->_current_dialect->{'and'}; } |
55
|
30
|
|
|
30
|
1
|
118
|
sub But { $_[0]->_current_dialect->{'but'}; } |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub stepKeywordTypes { |
59
|
0
|
|
|
0
|
0
|
0
|
return @{ $_[0]->{'_step_keywords'}->{$_[1]} }; |
|
0
|
|
|
|
|
0
|
|
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub ScenarioOutline { |
63
|
9
|
|
|
9
|
1
|
37
|
$_[0]->_current_dialect->{'scenarioOutline'}; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
__END__ |