File Coverage

blib/lib/Bundler/MultiGem/Command/setup.pm
Criterion Covered Total %
statement 20 37 54.0
branch 0 6 0.0
condition n/a
subroutine 7 12 58.3
pod 5 5 100.0
total 32 60 53.3


line stmt bran cond sub pod time code
1             package Bundler::MultiGem::Command::setup;
2              
3 1     1   65749 use 5.006;
  1         19  
4 1     1   6 use strict;
  1         2  
  1         29  
5 1     1   6 use warnings;
  1         2  
  1         35  
6              
7 1     1   429 use Bundler::MultiGem -command;
  1         5  
  1         10  
8 1     1   5186 use YAML::Tiny;
  1         6191  
  1         62  
9 1     1   457 use Bundler::MultiGem::Model::Directories;
  1         2  
  1         29  
10 1     1   433 use Bundler::MultiGem::Model::Gem;
  1         3  
  1         338  
11              
12             =head1 NAME
13              
14             Bundler::MultiGem::Command::setup - Create multiple gem versions out of a configuration file (alias: install i s)
15              
16             =head1 VERSION
17              
18             Version 0.02
19              
20             =cut
21              
22             our $VERSION = '0.02';
23              
24             =head1 SYNOPSIS
25              
26             This module includes the commands to create multiple versions of the same gem out of a config yml file
27              
28             bundle-multigem [-f] [long options...]
29              
30             -f --file provide the yaml configuration file (default:
31             ./.bundle-multigem.yml)
32              
33              
34             =head1 SUBROUTINES/METHODS
35              
36             =head2 command_names
37              
38             Command aliases: C
39              
40             =cut
41              
42             sub command_names {
43 0     0 1   qw(setup install i s)
44             }
45              
46             =head2 usage_desc
47              
48             =cut
49              
50 0     0 1   sub usage_desc { "bundle-multigem %o " }
51              
52             =head2 opt_spec
53              
54             =cut
55              
56             sub opt_spec {
57             return (
58 0     0 1   [ "file|f=s", "provide the yaml configuration file (default: ./.bundle-multigem.yml)" ],
59             );
60             }
61              
62             =head2 validate_args
63              
64             =cut
65              
66             sub validate_args {
67 0     0 1   my ($self, $opt, $args) = @_;
68              
69 0 0         if (!defined $opt->{file}) {
70 0           $opt->{file} = '.bundle-multigem.yml';
71             }
72 0 0         if (!-f $opt->{file}){
73 0           $self->usage_error("You should provide a valid path ($opt->{file} does not exists)");
74             }
75 0 0         $self->usage_error("No args allowed") if @$args;
76             }
77              
78             =head2 execute
79              
80             Load the YAML configuration file, validates the directories provided and apply the gem creation
81              
82             =cut
83              
84             sub execute {
85 0     0 1   my ($self, $opt, $args) = @_;
86              
87 0           my $yaml = YAML::Tiny->read($opt->{file});
88              
89 0           my $gem = Bundler::MultiGem::Model::Gem->new($yaml->[0]{gem});
90             my $dir = Bundler::MultiGem::Model::Directories->new({
91             cache => $yaml->[0]{cache},
92             directories => $yaml->[0]{directories},
93 0           });
94              
95 0           $dir->validates;
96 0           $dir->apply_cache;
97              
98 0           $gem->apply($dir);
99              
100 0           print "Completed!";
101             }
102              
103             =head1 AUTHOR
104              
105             Mauro Berlanda, C<< >>
106              
107             =head1 BUGS
108              
109             Please report any bugs or feature requests to L, or through
110             the web interface at L. I will be notified, and then you'll
111             automatically be notified of progress on your bug as I make changes.
112              
113             =head1 SUPPORT
114              
115             You can find documentation for this module with the perldoc command.
116              
117             perldoc Bundler::MultiGem::Directories
118              
119              
120             You can also look for information at:
121              
122             =over 2
123              
124             =item * RT: CPAN's request tracker (report bugs here)
125              
126             L
127              
128             =item * Github Repository
129              
130             L
131              
132             =back
133              
134              
135             =head1 ACKNOWLEDGEMENTS
136              
137              
138             =head1 LICENSE AND COPYRIGHT
139              
140             Copyright 2018 Mauro Berlanda.
141              
142             This program is free software; you can redistribute it and/or modify it
143             under the terms of the the Artistic License (2.0). You may obtain a
144             copy of the full license at:
145              
146             L
147              
148             Any use, modification, and distribution of the Standard or Modified
149             Versions is governed by this Artistic License. By using, modifying or
150             distributing the Package, you accept this license. Do not use, modify,
151             or distribute the Package, if you do not accept this license.
152              
153             If your Modified Version has been derived from a Modified Version made
154             by someone other than you, you are nevertheless required to ensure that
155             your Modified Version complies with the requirements of this license.
156              
157             This license does not grant you the right to use any trademark, service
158             mark, tradename, or logo of the Copyright Holder.
159              
160             This license includes the non-exclusive, worldwide, free-of-charge
161             patent license to make, have made, use, offer to sell, sell, import and
162             otherwise transfer the Package with respect to any patent claims
163             licensable by the Copyright Holder that are necessarily infringed by the
164             Package. If you institute patent litigation (including a cross-claim or
165             counterclaim) against any party alleging that the Package constitutes
166             direct or contributory patent infringement, then this Artistic License
167             to you shall terminate on the date that such litigation is filed.
168              
169             Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
170             AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
171             THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
172             PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
173             YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
174             CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
175             CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
176             EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
177              
178              
179             =cut
180              
181             1;