use Bugzilla::Constants;
use Algorithm::BloomFilter;
-use File::Slurper qw(write_binary read_binary read_lines);
+use Mojo::File qw(path);
use File::Spec::Functions qw(catfile);
sub _new_bloom_filter {
return Algorithm::BloomFilter->new($m, $k);
}
-sub _filename {
+sub _file {
my ($name, $type) = @_;
my $datadir = bz_locations->{datadir};
- return catfile($datadir, "$name.$type");
+ return path(catfile($datadir, "$name.$type"));
}
sub populate {
my ($class, $name) = @_;
my $memcached = Bugzilla->memcached;
- my @items = read_lines(_filename($name, 'list'));
+ my @items = split(/\n/, _file($name, 'list')->slurp);
my $filter = _new_bloom_filter(@items + 0);
$filter->add($_) foreach @items;
- write_binary(_filename($name, 'bloom'), $filter->serialize);
+ _file($name, 'bloom')->spurt( $filter->serialize );
$memcached->clear_bloomfilter({name => $name});
}
sub lookup {
my ($class, $name) = @_;
my $memcached = Bugzilla->memcached;
- my $filename = _filename($name, 'bloom');
+ my $file = _file($name, 'bloom');
my $filter_data = $memcached->get_bloomfilter( { name => $name } );
- if (!$filter_data && -f $filename) {
- $filter_data = read_binary($filename);
+ if (!$filter_data && -f $file) {
+ $filter_data = $file->slurp;
$memcached->set_bloomfilter({ name => $name, filter => $filter_data });
}
use File::Basename;
use File::Copy qw(move);
use File::Spec;
+use Mojo::File qw(path);
use Cwd ();
-use File::Slurp;
use IO::File;
use POSIX ();
use English qw(-no_match_vars $OSNAME);
my $yui_all_css = sub {
return join("\n",
map {
- my $css = read_file($_);
+ my $css = path($_)->slurp;
_css_url_fix($css, $_, "skins/yui.css.list")
- } read_file("skins/yui.css.list", { chomp => 1 })
+ } split(/\n/, path("skins/yui.css.list")->slurp)
);
};
my $yui_all_js = sub {
return join("\n",
- map { scalar read_file($_) } read_file("js/yui.js.list", { chomp => 1 })
+ map { path($_)->slurp } split(/\n/, path("js/yui.js.list")->slurp)
);
};
my $yui3_all_css = sub {
return join("\n",
map {
- my $css = read_file($_);
+ my $css = path($_)->slurp;
_css_url_fix($css, $_, "skins/yui3.css.list")
- } read_file("skins/yui3.css.list", { chomp => 1 })
+ } split(/\n/, path("skins/yui3.css.list")->slurp)
);
};
my $yui3_all_js = sub {
return join("\n",
- map { scalar read_file($_) } read_file("js/yui3.js.list", { chomp => 1 })
+ map { path($_)->slurp } split(/\n/, path('js/yui3.js.list')->slurp)
);
};
use Sub::Quote 2.005000;
use Sub::Name;
use Socket qw(AF_INET inet_aton);
-use File::Spec::Functions qw(catfile);
-use File::Slurper qw(read_text);
+use Mojo::File qw(path);
use English qw(-no_match_vars);
use Bugzilla::Quantum::Stdout;
use Bugzilla::Constants qw(bz_locations USAGE_MODE_BROWSER);
sub load_one {
my ($class, $name, $file) = @_;
my $package = __PACKAGE__ . "::$name", my $inner_name = "_$name";
- my $content = read_text(catfile(bz_locations->{cgi_path}, $file));
+ my $content = path(bz_locations->{cgi_path}, $file)->slurp;
$content = "package $package; $content";
untaint($content);
my %options = (package => $package, file => $file, line => 1, no_defer => 1,);
use File::Basename qw(basename dirname);
use File::Find;
use File::Path qw(rmtree mkpath);
-use File::Slurp;
use File::Spec;
use IO::Dir;
use List::MoreUtils qw(firstidx);
'Email::MIME' => '1.904',
'Email::Send' => '1.911',
'FFI::Platypus' => 0,
- 'File::Slurp' => '9999.13',
- 'File::Slurper' => '0.012',
'Future' => '0.34',
'HTML::Escape' => '1.10',
'IPC::System::Simple' => 0,
use Scalar::Util qw(blessed);
use Sys::Syslog qw(:DEFAULT);
use Text::Balanced qw( extract_bracketed extract_multiple );
-use File::Slurp qw(read_file);
-use JSON::XS;
+use JSON::MaybeXS;
+use Mojo::File qw(path);
use Bugzilla::Extension::BMO::Constants;
use Bugzilla::Extension::BMO::FakeBug;
# version.json needs to have a source attribute pointing to
# our repository. We already have this information in the (static)
# contribute.json file, so parse that in
- my $json = JSON::XS->new->pretty->utf8->canonical();
+ my $json = JSON::MaybeXS->new->pretty->utf8->canonical();
my $contribute = eval {
- $json->decode(scalar read_file(bz_locations()->{cgi_path} . "/contribute.json"));
+ $json->decode(path(bz_locations()->{cgi_path}, "/contribute.json")->slurp);
};
if (!$contribute) {
use Bugzilla::User;
use Bugzilla::Util qw(format_time datetime_from);
use Email::MIME;
-use File::Slurp qw(read_file);
+use Mojo::File qw(path);
use File::Temp qw(tempfile);
-use JSON qw(encode_json decode_json);
+use Mojo::JSON qw(encode_json decode_json);
use Sys::Hostname qw(hostname);
Bugzilla->usage_mode(USAGE_MODE_CMDLINE);
@ARGV = grep { !/^-/ } @ARGV;
if (my $filename = shift @ARGV) {
- _send_email(decode_json(scalar read_file($filename)));
+ _send_email(decode_json(path($filename)->slurp));
exit;
}
use Bugzilla::Constants;
use Bugzilla::Install::Localconfig;
-use File::Slurp;
+use Mojo::File qw(path);
Bugzilla->usage_mode(USAGE_MODE_CMDLINE);
die "Invalid param name: $param_name\n" unless exists $localconfig->{$param_name};
if ($localconfig->{$param_name} ne $param_value) {
- my @file = read_file('localconfig');
+ my @file = split(/\n/, path('localconfig')->slurp);
my $updated = 0;
foreach my $line (@file) {
next unless $line =~ /^\s*\$([\w_]+)\s*=\s*'([^']*)'/;
$updated = 1;
}
}
- write_file('localconfig', @file) if $updated;
+ path('localconfig')->spurt(join("\n", @file)) if $updated;
} else {
print "'$param_name' is already '$param_value'\n";
}
use 5.10.1;
use lib qw( . lib local/lib/perl5 );
use File::Spec;
-use File::Slurp qw(read_file);
+use Mojo::File qw(path);
use File::Find qw(find);
use Cwd qw(realpath cwd);
use Test::More;
wanted => sub {
if (/\.css$/) {
my $css_file = $File::Find::name;
- my $content = read_file($_);
+ my $content = path($_)->slurp;
while ($content =~ m{url\(["']?([^\?\)"']+)(?:\?.+)?['"]?\)}g) {
my $file = $1;
my $file_rel_root = File::Spec->abs2rel(realpath(File::Spec->rel2abs($file)), $root);