line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Gherkin::Dialect; |
2
|
|
|
|
|
|
|
$Gherkin::Dialect::VERSION = '27.0.0'; |
3
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
24
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use Cucumber::Messages; |
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
15
|
|
7
|
1
|
|
|
1
|
|
9
|
use Gherkin::Exceptions; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
|
|
7
|
use Class::XSAccessor accessors => |
10
|
1
|
|
|
1
|
|
5
|
[ qw/_current_dialect dialect dictionary_location dictionary /, ]; |
|
1
|
|
|
|
|
2
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
3
|
|
|
3
|
1
|
8
|
my ( $class, $options ) = @_; |
14
|
3
|
|
50
|
|
|
8
|
$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
|
|
|
|
|
642
|
require Gherkin::Generated::Languages; |
27
|
3
|
|
|
|
|
11
|
$options->{'dictionary'} = $Gherkin::Generated::Languages::data; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
3
|
|
|
|
|
7
|
bless $options, $class; |
32
|
|
|
|
|
|
|
$options->change_dialect( $options->{'dialect'} ) |
33
|
3
|
50
|
|
|
|
20
|
if $options->{'dialect'}; |
34
|
|
|
|
|
|
|
|
35
|
3
|
|
|
|
|
11
|
return $options; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub change_dialect { |
39
|
9
|
|
|
9
|
1
|
22
|
my ( $self, $name, $location ) = @_; |
40
|
|
|
|
|
|
|
Gherkin::Exceptions::NoSuchLanguage->throw( $name, $location ) |
41
|
9
|
50
|
|
|
|
33
|
unless $self->dictionary->{$name}; |
42
|
9
|
|
|
|
|
13
|
$self->{'dialect'} = $name; |
43
|
9
|
|
|
|
|
25
|
$self->{'_current_dialect'} = $self->dictionary->{$name}; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
3
|
|
|
3
|
1
|
13
|
sub Feature { $_[0]->_current_dialect->{'feature'}; } |
47
|
9
|
|
|
9
|
1
|
23
|
sub Rule { $_[0]->_current_dialect->{'rule'}; } |
48
|
15
|
|
|
15
|
1
|
43
|
sub Scenario { $_[0]->_current_dialect->{'scenario'}; } |
49
|
3
|
|
|
3
|
1
|
14
|
sub Background { $_[0]->_current_dialect->{'background'}; } |
50
|
6
|
|
|
6
|
1
|
18
|
sub Examples { $_[0]->_current_dialect->{'examples'}; } |
51
|
30
|
|
|
30
|
1
|
120
|
sub Given { $_[0]->_current_dialect->{'given'}; } |
52
|
30
|
|
|
30
|
1
|
92
|
sub When { $_[0]->_current_dialect->{'when'}; } |
53
|
30
|
|
|
30
|
1
|
80
|
sub Then { $_[0]->_current_dialect->{'then'}; } |
54
|
30
|
|
|
30
|
1
|
72
|
sub And { $_[0]->_current_dialect->{'and'}; } |
55
|
30
|
|
|
30
|
1
|
116
|
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
|
29
|
$_[0]->_current_dialect->{'scenarioOutline'}; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
__END__ |