File: Document.pm

package info (click to toggle)
libtest-bdd-cucumber-perl 0.26-1~bpo70%2B1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy-backports
  • size: 528 kB
  • sloc: perl: 3,436; makefile: 8
file content (81 lines) | stat: -rw-r--r-- 1,419 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package Test::BDD::Cucumber::Model::Document;
$Test::BDD::Cucumber::Model::Document::VERSION = '0.26';
use Moose;
use Test::BDD::Cucumber::Model::Line;

=head1 NAME

Test::BDD::Cucumber::Model::Document - Model to represent a feature file on disk or in memory

=head1 VERSION

version 0.26

=head1 DESCRIPTION

Model to represent a feature file on disk or in memory

=head1 ATTRIBUTES

=head2 filename

The filename from which the document was loaded.

=cut

has 'filename' => ( is => 'ro', isa => 'Str' );

=head2 content

The file contents, as a string

=cut

has 'content'  => ( is => 'ro', isa => 'Str' );

=head2 lines

The file contents, as an arrayref of L<Test::BDD::Cucumber::Model::Line>
objects

=cut

has 'lines'    => ( is => 'rw', default => sub {[]},
	isa => 'ArrayRef[Test::BDD::Cucumber::Model::Line]' );

=head1 OTHER

=head2 BUILD

The instantiation populates C<lines()> by splitting the input on newlines.

=cut

# Create lines
sub BUILD {
	my $self = shift;

	# Reset any content that was in lines
	my $counter = 0;

	for my $line ( split(/\n/, $self->content ) ) {
		my $obj = Test::BDD::Cucumber::Model::Line->new({
			number      => ++$counter,
			document    => $self,
			raw_content => $line
		});
		push( @{ $self->lines }, $obj );
	}
};

=head1 AUTHOR

Peter Sergeant C<pete@clueball.com>

=head1 LICENSE

Copyright 2011-2014, Peter Sergeant; Licensed under the same terms as Perl

=cut

1;