Remove dependency on Path::Tiny

So it's usable on el6
tags/patrix-0.1.4-1
Daniel Berteaud 7 years ago
parent e86c3e98d3
commit e19d403832
  1. 1
      README.md
  2. 1
      patrix.spec
  3. 13
      scripts/patrix

@ -9,7 +9,6 @@ It requires the following perl modules
* File::Basename * File::Basename
* File::MimeInfo * File::MimeInfo
* File::Spec * File::Spec
* Path::Tiny
* Getopt::Long * Getopt::Long
* URI::Escape * URI::Escape
* JSON * JSON

@ -19,7 +19,6 @@ Requires: perl(JSON)
Requires: perl(File::Basename) Requires: perl(File::Basename)
Requires: perl(File::MimeInfo) Requires: perl(File::MimeInfo)
Requires: perl(File::Spec) Requires: perl(File::Spec)
Requires: perl(Path::Tiny)
Requires: perl(URI::Escape) Requires: perl(URI::Escape)
Requires: perl(Term::ReadKey) Requires: perl(Term::ReadKey)
Requires: perl(Hash::Merge::Simple) Requires: perl(Hash::Merge::Simple)

@ -12,7 +12,6 @@ use File::MimeInfo;
use File::Basename; use File::Basename;
use File::Spec; use File::Spec;
use URI::Escape; use URI::Escape;
use Path::Tiny;
use Term::ReadKey; use Term::ReadKey;
use Hash::Merge::Simple qw(merge); use Hash::Merge::Simple qw(merge);
use Scalar::Util qw(looks_like_number); use Scalar::Util qw(looks_like_number);
@ -155,6 +154,16 @@ sub send_request {
return $resp; return $resp;
} }
# Read the content of a file
sub slurp {
my $file = shift;
open my $f, '<', $file or die;
local $/ = undef;
my $bytes = <$f>;
close $f;
return $bytes;
}
# Load values from the config file if it exists # Load values from the config file if it exists
sub read_conf { sub read_conf {
my $cfg = Config::Simple->new; my $cfg = Config::Simple->new;
@ -256,7 +265,7 @@ sub send_file {
my $resp = send_request({ my $resp = send_request({
uri => $uri, uri => $uri,
content_type => mimetype($file), content_type => mimetype($file),
content => path($file)->slurp_raw content => slurp($file)
}); });
debug("File upload response is\n" . to_json(from_json($resp->decoded_content), { pretty => 1 })); debug("File upload response is\n" . to_json(from_json($resp->decoded_content), { pretty => 1 }));
die "Error uploading file\n" unless ($resp->is_success); die "Error uploading file\n" unless ($resp->is_success);

Loading…
Cancel
Save