App-vaporcalc

 view release on metacpan or  search on metacpan

bin/vaporcalc  view on Meta::CPAN

  $lines[0] = colorify red => $lines[0];
  join "\n", @lines
}

fun flavor_strings (RecipeResultSet $rset) {
  my $recipe = $rset->recipe;
  my $result = $rset->result;

  my $flav_recipe_str = '';
  for my $flav ($recipe->flavor_array->all) {
    my $pcnt = colorify 'bold red' => $flav->percentage;
    my $tag  = $flav->tag;
    my $type = $flav->type;
    $flav_recipe_str .= "   $tag -> $pcnt %  ($type)\n";
  }

  my $flav_result_str = '';
  for my $flav ($result->flavors->kv->all) {
    my ($tag, $ml) = @$flav;
    $ml = colorify 'bold yellow' => $ml;
    $flav_result_str .= "   $tag => [$ml ml]\n";
  }

  hash(
    recipe_flavor_string => $flav_recipe_str,
    result_flavor_string => $flav_result_str
  )->inflate
}

fun format_resultset (RecipeResultSet $rset) {

bin/vaporcalc  view on Meta::CPAN

  my $recipe = $rset->recipe;
  my $result = $rset->result;

  my $flav_recipe_str = flavor_strings($rset)->recipe_flavor_string;
  my $flav_result_str = flavor_strings($rset)->result_flavor_string;

  format_str( $tmpl =>
    notes => sub {
      $recipe->notes->has_any ?
        "\n" . $recipe->notes
                ->map(sub { colorify('bold yellow', ' - '.$_) })
                ->join("\n")
        : 'none'
    },

    flavor_recipe => $flav_recipe_str,
    flavor_result => $flav_result_str,

    (map {; $_ => colorify('bold red', $recipe->$_) } qw/
      target_quantity target_nic_per_ml
      base_nic_per_ml base_nic_type
      target_pg target_vg
    /),

    (map {; $_ => colorify('bold yellow', $result->$_) } qw/
      vg pg nic total
    /),

    max_vg_total => sub {
      colorify('bold yellow', $result->pg + $result->vg)
    },
  )
}


use Term::UI;
use Term::ReadLine;
my $termpkg = 
  $ENV{PERL_RL} 
  || try { use_module('Term::ReadLine::Perl5') }



( run in 0.350 second using v1.01-cache-2.11-cpan-5dc5da66d9d )