lib/OAuthomatic/UserInteraction/ViaMicroWeb.pm

filter: Statementstmt 42.8% 15 / 35 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 44.4% 4 / 9 Podpod 25.0% 1 / 4 totaltotal 40.0% 20 / 50 SCAR 10.4
CC
2
Cov
41%
_open_in_browser
6.0
prepare_to_work
2.0
cleanup_after_work
2.0
CRAP 2.8
« blib/lib/OAuthomatic/Server.pm ↑ Summary blib/lib/OAuthomatic/Config.pm »
1 package OAuthomatic::UserInteraction::ViaMicroWeb;
2 # ABSTRACT: User is led using forms in the browser
3  
4  
5 3 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use Proc::Background;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10  
11 3 has 'micro_web' => (is=>'ro', isa=>'OAuthomatic::Internal::MicroWeb', required=>1,
12 handles => ['server', 'config']);
13  
14 sub prepare_to_work {
15 0 ▶ my $self = shift;
Subroutine prepare_to_work: not called CC=1 SCAR=6.9
Pod undocumented
16 0 $self->micro_web->start_using;
17 }
18  
19 sub cleanup_after_work {
20 0 ▶ my $self = shift;
Subroutine cleanup_after_work: not called CC=1 SCAR=6.9
Pod undocumented
21 0 $self->micro_web->finish_using;
22 }
23  
24  
25 sub prompt_client_credentials {
26 0 ▶ my ($self) = @_;
Subroutine prompt_client_credentials: not called CC=1 SCAR=6.9
Pod documented
27  
28 0 my $mweb = $self->micro_web;
29  
30 0 my $enter_url = $mweb->client_key_url;
31 0 $self->_open_in_browser($enter_url, <<"END");
32 Fill application tokens in the browser form.
33 This script will continue once they are submitted.
34 END
35 0 my $client_cred = $mweb->wait_for_client_cred();
36  
37 0 return $client_cred;
38 }
39  
40 sub visit_oauth_authorize_page {
41 0 ▶ my ($self, $url) = @_;
Subroutine visit_oauth_authorize_page: not called CC=1 SCAR=6.9
Pod undocumented
42  
43 0 my $site_name = $self->server->site_name;
44  
45 0 $self->_open_in_browser($url, <<"END");
46 Accept application authorization in the browser form (page from $site_name),
47 or just notification about succesfull authorization if you already authorized
48 in the past.
49 This script will continue once you authorize application.
50 END
51 }
52  
53 sub _open_in_browser {
54 0 ▶ my ($self, $url, $comment) = @_;
Subroutine _open_in_browser: not called CC=2 SCAR=17.9
55  
56 0 my $browser = $self->config->browser;
57 0 ▶ unless($browser) {
Branch: 1 branch
BranchTrueFalseTotal
if ($browser) { } 0 0 0
58 0 print <<"END";
59 Open your browser on
60 $url
61 $comment
62 END
63 } else {
64 0 print <<"END";
65 Spawning browser ($browser) on
66 $url
67 (open this page manually if for some reason it is not displayed automatically).
68  
69 $comment
70 END
71 0 my $bgr = Proc::Background->new($browser, $url);
72 }
73 0 return;
74 }
75  
76 3 with 'OAuthomatic::UserInteraction';
77  
78 3 1;
79  
80 __END__
81  
82 =pod
83  
84 =encoding UTF-8
85  
86 =head1 NAME
87  
88 OAuthomatic::UserInteraction::ViaMicroWeb - User is led using forms in the browser
89  
90 =head1 VERSION
91  
92 version 0.01
93  
94 =head1 DESCRIPTION
95  
96 Simple (local) web forms will be used to ask user for client
97 credentials and provide him with instructions.
98  
99 =head1 PARAMETERS
100  
101 =head2 micro_web
102  
103 Embedded web server object. Here it will be used to show forms.
104  
105 =head1 METHODS
106  
107 =head2 prompt_client_credentials() => ClientCred(...)
108  
109 Asks the user to visit appropriate remote page and provide application
110 (or developer) keys. Here use web form as an aid.
111  
112 =head1 AUTHOR
113  
114 Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
115  
116 =head1 COPYRIGHT AND LICENSE
117  
118 This software is copyright (c) 2015 by Marcin Kasperski.
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
« blib/lib/OAuthomatic/Server.pm ↑ Summary blib/lib/OAuthomatic/Config.pm »