<commit_before>package Mojolicious::Command::inflate;
use Mojo::Base 'Mojo::Command';

use Mojo::Util 'encode';

has description => "Inflate embedded files to real files.\n";
has usage       => "usage: $0 inflate\n";

# "Come on stem cells! Work your astounding scientific nonsense!"
sub run {
  my $self = shift;

  # Find all embedded files
  my $all = {};
  my $app = $self->app;
  for my $class (@{$app->renderer->classes}, @{$app->static->classes}) {
    $all = {%{$self->get_all_data($class)}, %$all};
  }

  # Turn them into real files
  for my $file (keys %$all) {
    my $prefix = $file =~ /\.\w+\.\w+$/ ? 'templates' : 'public';
    my $path = $self->rel_file("$prefix/$file");
    $self->write_file($path, encode('UTF-8', $all->{$file}));
  }
}

1;
__END__

=head1 NAME

Mojolicious::Command::inflate - Inflate command

=head1 SYNOPSIS<commit_msg>fixed a minor inflate command bug with classes without __DATA__ section<commit_after>package Mojolicious::Command::inflate;
use Mojo::Base 'Mojo::Command';

use Mojo::Util 'encode';

has description => "Inflate embedded files to real files.\n";
has usage       => "usage: $0 inflate\n";

# "Come on stem cells! Work your astounding scientific nonsense!"
sub run {
  my $self = shift;

  # Find all embedded files
  my $all = {};
  my $app = $self->app;
  for my $class (@{$app->renderer->classes}, @{$app->static->classes}) {
    $all = {%{$self->get_all_data($class) // {}}, %$all};
  }

  # Turn them into real files
  for my $file (keys %$all) {
    my $prefix = $file =~ /\.\w+\.\w+$/ ? 'templates' : 'public';
    my $path = $self->rel_file("$prefix/$file");
    $self->write_file($path, encode('UTF-8', $all->{$file}));
  }
}

1;
__END__

=head1 NAME

Mojolicious::Command::inflate - Inflate command

=head1 SYNOPSIS
{'fraction_non_alphanumeric': 0.19101123595505617, 'fraction_numerical': 0.0056179775280898875, 'mean_word_length': 3.852861035422343, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6940500', 'n_tokens_mistral': 643, 'n_tokens_neox': 626, 'n_words': 175}