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   2355 use v5.20;
  3         10  
8 3     3   27 use utf8;
  3         6  
  3         15  
9 3     3   105 use Role::Commons -all;
  3         16  
  3         19  
10 3     3   4613 use feature 'signatures';
  3         6  
  3         270  
11 3     3   22 use namespace::autoclean 0.16;
  3         61  
  3         19  
12              
13 3     3   199 use Path::Tiny;
  3         7  
  3         207  
14 3     3   22 use Module::Runtime qw/use_module/;
  3         6  
  3         17  
15 3     3   168 use Boxer::CLI -command;
  3         5  
  3         28  
16              
17 3     3   924 use strictures 2;
  3         19  
  3         106  
18 3     3   524 no warnings "experimental::signatures";
  3         6  
  3         196  
19              
20             =head1 VERSION
21              
22             Version v1.4.1
23              
24             =cut
25              
26             our $VERSION = "v1.4.1";
27              
28             use constant {
29 3         1283 abstract => q[compose system recipe from abstract node],
30             usage_desc => q[%c compose %o NODE [NODE...]],
31 3     3   36 };
  3         22  
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 490 qw(
48             compose
49             );
50             }
51              
52             sub opt_spec
53             {
54             return (
55 3     3 1 35530 [ "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         8 sub execute ( $self, $opt, $args )
  3         6  
67 3     3 1 6954 {
  3         6  
  3         6  
68             Log::Any::Adapter->set( 'Screen', default_level => 'info' )
69 3 50       22 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         17 )->run;
77 3         5380 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     16 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;