line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Juju::Util; |
2
|
|
|
|
|
|
|
$Juju::Util::VERSION = '2.0'; |
3
|
|
|
|
|
|
|
# ABSTRACT: helper methods for Juju |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
570
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
7
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
20
|
|
8
|
1
|
|
|
1
|
|
589
|
use HTTP::Tiny; |
|
1
|
|
|
|
|
37649
|
|
|
1
|
|
|
|
|
38
|
|
9
|
1
|
|
|
1
|
|
728
|
use JSON::PP; |
|
1
|
|
|
|
|
11105
|
|
|
1
|
|
|
|
|
88
|
|
10
|
1
|
|
|
1
|
|
673
|
use Method::Signatures; |
|
1
|
|
|
|
|
51712
|
|
|
1
|
|
|
|
|
19
|
|
11
|
1
|
|
|
1
|
|
1023
|
use Moo; |
|
1
|
|
|
|
|
7277
|
|
|
1
|
|
|
|
|
6
|
|
12
|
1
|
|
|
1
|
|
1663
|
use namespace::clean; |
|
1
|
|
|
|
|
3446
|
|
|
1
|
|
|
|
|
5
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has series => (is => 'ro', default => sub { qr/precise|trusty|utopic/ }); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
1
|
100
|
|
1
|
|
102688
|
method query_cs($charm, $series = "trusty") { |
|
5
|
100
|
|
5
|
|
106736
|
|
|
5
|
50
|
|
|
|
28
|
|
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
13
|
|
|
4
|
|
|
|
|
15
|
|
18
|
4
|
|
|
|
|
6
|
my $cs_url = 'https://manage.jujucharms.com/api/3/charm'; |
19
|
|
|
|
|
|
|
|
20
|
4
|
|
|
|
|
26
|
my $composed_url = sprintf("%s/%s/%s", $cs_url, $series, $charm); |
21
|
4
|
|
|
|
|
30
|
my $res = HTTP::Tiny->new->get($composed_url); |
22
|
4
|
100
|
|
|
|
358457
|
die "Unable to query charm store: ".$res->{reason} unless $res->{success}; |
23
|
2
|
|
|
|
|
859
|
return decode_json($res->{content}); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
1; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
__END__ |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=pod |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=encoding UTF-8 |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 NAME |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Juju::Util - helper methods for Juju |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 VERSION |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
version 2.0 |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 SYNOPSIS |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
use Juju::Util; |
45
|
|
|
|
|
|
|
my $util = Juju::Util->new; |
46
|
|
|
|
|
|
|
my $charm = $util->query_cs('wordpress', 'precise'); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 METHODS |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head2 query_cs |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
helper for querying charm store for charm details |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
B<Params> |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=over 4 |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=item * |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
C<charm> |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
name of charm to query |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=item * |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
C<series> |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
(optional) series to limit to (defaults: trusty) |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=back |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 AUTHOR |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Adam Stokes <adamjs@cpan.org> |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
This software is Copyright (c) 2014 by Adam Stokes. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
This is free software, licensed under: |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
The MIT (X11) License |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 SEE ALSO |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Please see those modules/websites for more information related to this module. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=over 4 |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=item * |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
L<Juju|Juju> |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=back |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 DISCLAIMER OF WARRANTY |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY |
99
|
|
|
|
|
|
|
FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT |
100
|
|
|
|
|
|
|
WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER |
101
|
|
|
|
|
|
|
PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, |
102
|
|
|
|
|
|
|
EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE |
103
|
|
|
|
|
|
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
104
|
|
|
|
|
|
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE |
105
|
|
|
|
|
|
|
SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME |
106
|
|
|
|
|
|
|
THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING |
109
|
|
|
|
|
|
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR |
110
|
|
|
|
|
|
|
REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE |
111
|
|
|
|
|
|
|
TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR |
112
|
|
|
|
|
|
|
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE |
113
|
|
|
|
|
|
|
SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING |
114
|
|
|
|
|
|
|
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A |
115
|
|
|
|
|
|
|
FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF |
116
|
|
|
|
|
|
|
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH |
117
|
|
|
|
|
|
|
DAMAGES. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=cut |