gitprep / lib / Mojolicious / Plugin / JSONConfigLoose.pm /
bf01392 11 years ago
1 contributor
24 lines | 0.55kb
package Mojolicious::Plugin::JSONConfigLoose;
use Mojo::Base 'Mojolicious::Plugin::JSONConfig';

sub load {
  my ($self, $file, $conf, $app) = @_;
  $app->log->debug(qq/Reading config file "$file"./);

  # Slurp UTF-8 file
  open my $handle, "<:encoding(UTF-8)", $file
    or die qq/Couldn't open config file "$file": $!/;
  my $content;
  while (my $line = <$handle>) {
    if ($line =~ m#^\s*//#) {
      $content .= "\n";
      next;
    }
    else { $content .= $line }
  }

  # Process
  return $self->parse($content, $file, $conf, $app);
}

1;