| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Global::Context::Env; |
|
2
|
|
|
|
|
|
|
{ |
|
3
|
|
|
|
|
|
|
$Global::Context::Env::VERSION = '0.003'; |
|
4
|
|
|
|
|
|
|
} |
|
5
|
3
|
|
|
3
|
|
4170
|
use Moose::Role; |
|
|
3
|
|
|
|
|
13297
|
|
|
|
3
|
|
|
|
|
16
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: the global execution environment |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
with 'MooseX::Clone'; |
|
10
|
|
|
|
|
|
|
|
|
11
|
3
|
|
|
3
|
|
18193
|
use Global::Context::Stack::Basic; |
|
|
3
|
|
|
|
|
11
|
|
|
|
3
|
|
|
|
|
135
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
3
|
|
|
3
|
|
27
|
use namespace::autoclean; |
|
|
3
|
|
|
|
|
8
|
|
|
|
3
|
|
|
|
|
31
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has auth_token => ( |
|
17
|
|
|
|
|
|
|
is => 'ro', |
|
18
|
|
|
|
|
|
|
does => 'Global::Context::AuthToken', |
|
19
|
|
|
|
|
|
|
predicate => 'has_auth_token', |
|
20
|
|
|
|
|
|
|
); |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub agent { |
|
23
|
0
|
0
|
|
0
|
0
|
0
|
return undef unless $_[0]->has_auth_token; |
|
24
|
0
|
|
|
|
|
0
|
return $_[0]->auth_token->agent; |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
has terminal => ( |
|
29
|
|
|
|
|
|
|
is => 'ro', |
|
30
|
|
|
|
|
|
|
does => 'Global::Context::Terminal', |
|
31
|
|
|
|
|
|
|
required => 1, |
|
32
|
|
|
|
|
|
|
); |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
has stack => ( |
|
36
|
|
|
|
|
|
|
is => 'ro', |
|
37
|
|
|
|
|
|
|
does => 'Global::Context::Stack', |
|
38
|
|
|
|
|
|
|
required => 1, |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# XXX: This seems wrong; probably there should be no default, and it's up to |
|
41
|
|
|
|
|
|
|
# ctx_init to get this right. -- rjbs, 2010-12-13 |
|
42
|
|
|
|
|
|
|
default => sub { Global::Context::Stack::Basic->new }, |
|
43
|
|
|
|
|
|
|
); |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub stack_trace { |
|
47
|
1
|
|
|
1
|
1
|
1705
|
my ($self) = @_; |
|
48
|
1
|
|
|
|
|
40
|
map $_->as_string, $self->stack->frames; |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub with_pushed_frame { |
|
52
|
5
|
|
|
5
|
0
|
943
|
my ($self, $frame) = @_; |
|
53
|
|
|
|
|
|
|
|
|
54
|
5
|
|
|
|
|
171
|
return $self->clone( |
|
55
|
|
|
|
|
|
|
stack => $self->stack->with_pushed_frame($frame), |
|
56
|
|
|
|
|
|
|
); |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__END__ |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=pod |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 NAME |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Global::Context::Env - the global execution environment |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 VERSION |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
version 0.003 |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 OVERVIEW |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Global::Context::Env is a role. |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Global::Context::Env objects are the heart of the L<Global::Context> system. |
|
78
|
|
|
|
|
|
|
They're the things that go in the shared C<$Context> variable, and they're the |
|
79
|
|
|
|
|
|
|
things that point to the AuthToken, Terminal, and Stack. |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 auth_token |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Every environment either has an auth token that does |
|
86
|
|
|
|
|
|
|
L<Global::Context::AuthToken> or it has none. This attribute cannot be changed |
|
87
|
|
|
|
|
|
|
after initialization. |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
The C<agent> method will return undef if there is no auth token, and will |
|
90
|
|
|
|
|
|
|
otherwise get the agent from the token. |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head2 terminal |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Every environment has a terminal that does L<Global::Context::Terminal>. |
|
95
|
|
|
|
|
|
|
This attribute cannot be changed after initialization. |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 stack |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Every environment has a stack that does L<Global::Context::Stack>. |
|
100
|
|
|
|
|
|
|
This attribute cannot be changed after initialization. |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Instead, the C<with_pushed_frame> method is used to create a clone of the |
|
103
|
|
|
|
|
|
|
entire environment, save for a new frame pushed onto the stack. |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 METHODS |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head2 stack_trace |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
C<< ->stack_trace >> is a convenience method that returns a list |
|
110
|
|
|
|
|
|
|
containing the string representation of each frame in the stack. |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 AUTHOR |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Ricardo Signes <rjbs@cpan.org> |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
This software is copyright (c) 2010 by Ricardo Signes. |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
121
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=cut |