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   1861 use v5.20;
  3         9  
8 3     3   15 use utf8;
  3         3  
  3         13  
9 3     3   72 use Role::Commons -all;
  3         6  
  3         13  
10 3     3   3657 use feature 'signatures';
  3         5  
  3         220  
11 3     3   18 use namespace::autoclean 0.16;
  3         48  
  3         16  
12              
13 3     3   172 use Path::Tiny;
  3         5  
  3         151  
14 3     3   24 use Module::Runtime qw/use_module/;
  3         5  
  3         15  
15 3     3   181 use Boxer::CLI -command;
  3         7  
  3         17  
16              
17 3     3   826 use strictures 2;
  3         16  
  3         86  
18 3     3   430 no warnings "experimental::signatures";
  3         7  
  3         171  
19              
20             =head1 VERSION
21              
22             Version v1.4.3
23              
24             =cut
25              
26             our $VERSION = "v1.4.3";
27              
28             use constant {
29 3         1034 abstract => q[compose system recipe from abstract node],
30             usage_desc => q[%c compose %o NODE [NODE...]],
31 3     3   18 };
  3         5  
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 391 qw(
48             compose
49             );
50             }
51              
52             sub opt_spec
53             {
54             return (
55 3     3 1 28457 [ "suite=s", "suite of classes to use (bullseye)" ],
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         6 sub execute ( $self, $opt, $args )
  3         4  
67 3     3 1 5574 {
  3         5  
  3         6  
68             Log::Any::Adapter->set( 'Screen', default_level => 'info' )
69 3 50       17 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         14 )->run;
77 3         4674 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<< >>.
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;