File Coverage

blib/lib/Boxer/CLI/Command/Compose.pm
Criterion Covered Total %
statement 43 44 97.7
branch 1 2 50.0
condition 2 2 100.0
subroutine 14 15 93.3
pod 4 4 100.0
total 64 67 95.5


line stmt bran cond sub pod time code
1             package Boxer::CLI::Command::Compose;
2              
3             =encoding UTF-8
4              
5             =cut
6              
7 3     3   2121 use v5.20;
  3         9  
8 3     3   24 use utf8;
  3         5  
  3         24  
9 3     3   110 use Role::Commons -all;
  3         4  
  3         25  
10 3     3   4099 use feature 'signatures';
  3         6  
  3         239  
11 3     3   21 use namespace::autoclean 0.16;
  3         50  
  3         16  
12              
13 3     3   189 use Path::Tiny;
  3         6  
  3         167  
14 3     3   18 use Module::Runtime qw/use_module/;
  3         6  
  3         24  
15 3     3   143 use Boxer::CLI -command;
  3         17  
  3         21  
16              
17 3     3   897 use strictures 2;
  3         15  
  3         92  
18 3     3   466 no warnings "experimental::signatures";
  3         7  
  3         168  
19              
20             =head1 VERSION
21              
22             Version v1.4.2
23              
24             =cut
25              
26             our $VERSION = "v1.4.2";
27              
28             use constant {
29 3         1078 abstract => q[compose system recipe from abstract node],
30             usage_desc => q[%c compose %o NODE [NODE...]],
31 3     3   18 };
  3         4  
32              
33             sub description
34             {
35 0     0 1 0 <<'DESCRIPTION';
36             Compose a system recipe.
37              
38             Resolve a recipe to build a system. Input is one or more abstract nodes
39             to resolve using a set of abstract classes, and output is one or more
40             recipies serialized in one or more formats.
41              
42             DESCRIPTION
43             }
44              
45             sub command_names
46             {
47 5     5 1 384 qw(
48             compose
49             );
50             }
51              
52             sub opt_spec
53             {
54             return (
55 3     3 1 27287 [ "suite=s", "suite of classes to use (buster)" ],
56             [ "nodedir=s", "location of nodes (current dir)" ],
57             [ "classdir=s", "location of classes (XDG datadir + suite/classes)" ],
58             [ "datadir=s", "location containing nodes and classes" ],
59             [ "skeldir=s", "location of skeleton files (use builtin)" ],
60             [ "format=s", "serialize into these formats (preseed script)" ],
61             [ "nonfree", "enable use of contrib and non-free code" ],
62             [ "verbose|v", "verbose output" ],
63             );
64             }
65              
66 3         7 sub execute ( $self, $opt, $args )
  3         4  
67 3     3 1 5531 {
  3         4  
  3         5  
68             Log::Any::Adapter->set( 'Screen', default_level => 'info' )
69 3 50       18 if ( $opt->{verbose} );
70              
71             my $world = use_module('Boxer::Task::Classify')->new(
72             suite => $opt->{suite},
73             nodedir => $opt->{nodedir},
74             classdir => $opt->{classdir},
75             datadir => $opt->{datadir},
76 3         11 )->run;
77 3         4485 for my $node (@$args) {
78             use_module('Boxer::Task::Serialize')->new(
79             world => $world,
80             skeldir => $opt->{skeldir},
81             format => $opt->{format} || 'preseed script',
82             nonfree => $opt->{nonfree},
83 3   100     15 node => $node,
84             )->run;
85             }
86             }
87              
88             =head1 AUTHOR
89              
90             Jonas Smedegaard C<< <dr@jones.dk> >>.
91              
92             =cut
93              
94             our $AUTHORITY = 'cpan:JONASS';
95              
96             =head1 COPYRIGHT AND LICENCE
97              
98             Copyright © 2013-2016 Jonas Smedegaard
99              
100             This is free software; you can redistribute it and/or modify it under
101             the same terms as the Perl 5 programming language system itself.
102              
103             =head1 DISCLAIMER OF WARRANTIES
104              
105             THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
106             WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
107             MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
108              
109             =cut
110              
111             1;