Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compatibility with very old and very new versions of Perl #37

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions Build.PL
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,10 @@ my $build = $class->new
dist_author => 'Mark A. Jensen',
license => 'perl',
requires => {
'JSON' => 2.0,
'JSON::XS' => 2.0,
'JSON::ize' => 0.202,
'JSON::MaybeXS' => '1.003003',
'HOP::Stream' => 0,
'URI::Escape' => 3.3,
'HTTP::Tiny' => 0,
'LWP::UserAgent' => 6.04,
'LWP::Protocol::https' => 6.06,
'Exception::Class' => 1.3,
Expand All @@ -95,7 +94,6 @@ my $build = $class->new
'Test::NoWarnings' => 0,
'Mock::Quick' => 0,
'List::MoreUtils' => 0,
'Mojo::Exception' => 0,
'Neo4j::Driver' => '0.26', # cypher_params v2
experimental => 0,
'IPC::Run' => 0,
Expand All @@ -104,6 +102,7 @@ my $build = $class->new
},
build_recommends => {
'Test::Pod' => 1.0,
#'Mojo::Exception' => 0,
'Mojo::UserAgent' => 0,
'HTTP::Thin' => 0,
},
Expand Down
5 changes: 5 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
Revision history for Perl module REST::Neo4p

0.4011 DEVELOPMENT
- Drop dependencies on JSON, JSON::XS, JSON::ize
- Avoid deprecation warnings for smartmatch on Perl v5.38 and v5.40
- Fix test suite failing on old Perl versions

0.4010 NOT RELEASED
- Fix an issue that prevented the use of the Bolt protocol
with REST::Neo4p via Neo4j::Driver 1.02 or newer
Expand Down
7 changes: 3 additions & 4 deletions lib/REST/Neo4p.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ use v5.10;
package REST::Neo4p;
use Carp qw(croak carp);
use lib '../../lib';
use JSON;
use JSON::MaybeXS ();
use URI;
use URI::Escape;
use HTTP::Tiny;
use JSON::ize;
use Neo4j::Driver 0.26;
use REST::Neo4p::Agent;
use REST::Neo4p::Node;
Expand All @@ -17,15 +16,15 @@ use strict;
use warnings;

BEGIN {
$REST::Neo4p::VERSION = '0.4010';
$REST::Neo4p::VERSION = '0.4011';
}

our $CREATE_AUTO_ACCESSORS = 0;
our @HANDLES;
our $HANDLE = 0;
our $AGENT_MODULE = $ENV{REST_NEO4P_AGENT_MODULE} || 'LWP::UserAgent';

my $json = JSON->new->allow_nonref(1)->utf8;
my $json = JSON::MaybeXS->new->allow_nonref(1)->utf8;

$HANDLES[0]->{_q_endpoint} = 'cypher';

Expand Down
7 changes: 4 additions & 3 deletions lib/REST/Neo4p/Agent.pm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use v5.10;
package REST::Neo4p::Agent;
use REST::Neo4p::Exceptions;
use JSON;
use JSON::MaybeXS ();
use File::Temp;
use Carp qw(croak carp);
use strict;
Expand All @@ -10,12 +10,12 @@ use warnings;
our @ISA;
our $VERSION;
BEGIN {
$REST::Neo4p::Agent::VERSION = '0.4010';
$REST::Neo4p::Agent::VERSION = '0.4011';
}

our $AUTOLOAD;
our $JOB_CHUNK = 1024;
our $JSON = JSON->new()->allow_nonref(1)->utf8;
our $JSON = JSON::MaybeXS->new()->allow_nonref(1)->utf8;
our $RQ_RETRIES = 3;
our $RETRY_WAIT = 5;
sub new {
Expand Down Expand Up @@ -208,6 +208,7 @@ sub AUTOLOAD {
sub __do_request {
my $self = shift;
my ($rq, $action, @args) = @_;
no if $^V ge v5.37, warnings => 'deprecated::smartmatch';
use experimental qw/smartmatch/;
$self->{_errmsg} = $self->{_location} = $self->{_raw_response} = $self->{_decoded_content} = undef;
my $resp;
Expand Down
3 changes: 2 additions & 1 deletion lib/REST/Neo4p/Agent/HTTP/Thin.pm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use strict;
use warnings;

BEGIN {
$REST::Neo4p::Agent::HTTP::Thin::VERSION = '0.4010';
$REST::Neo4p::Agent::HTTP::Thin::VERSION = '0.4011';
}

my $unsafe = "^A-Za-z0-9\-\._~:+?%&=";
Expand Down Expand Up @@ -56,6 +56,7 @@ sub post { shift->_do('POST',@_) }
sub _do {
my $self = shift;
my ($rq, $url, @args) = @_;
no if $^V ge v5.37, warnings => 'deprecated::smartmatch';
use experimental qw/smartmatch/;
# if (length($self->{_user}) && length($self->{_pwd})) {
# $url =~ s|(https?://)|${1}$$self{_user}:$$self{_pwd}@|;
Expand Down
2 changes: 1 addition & 1 deletion lib/REST/Neo4p/Agent/LWP/UserAgent.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use LWP::ConnCache;
use strict;
use warnings;
BEGIN {
$REST::Neo4p::Agent::LWP::UserAgent::VERSION = '0.4010';
$REST::Neo4p::Agent::LWP::UserAgent::VERSION = '0.4011';
}
sub new {
my ($class,@args) = @_;
Expand Down
3 changes: 2 additions & 1 deletion lib/REST/Neo4p/Agent/Mojo/UserAgent.pm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use strict;
use warnings;

BEGIN {
$REST::Neo4p::Agent::Mojo::UserAgent::VERSION = '0.4010';
$REST::Neo4p::Agent::Mojo::UserAgent::VERSION = '0.4011';
}

our @default_headers;
Expand Down Expand Up @@ -89,6 +89,7 @@ sub post { shift->_do('POST',@_) }
sub _do {
my $self = shift;
my ($rq, $url, @args) = @_;
no if $^V ge v5.37, warnings => 'deprecated::smartmatch';
use experimental qw/smartmatch/;
my ($tx, $content, $content_file);
# neo4j wants to redirect .../data to .../data/
Expand Down
3 changes: 1 addition & 2 deletions lib/REST/Neo4p/Agent/Neo4j/Driver.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use v5.10;
use lib '../../../../../lib'; # testing
use base qw/REST::Neo4p::Agent/;
use Neo4j::Driver 0.26;
use JSON::ize;
use REST::Neo4p::Agent::Neo4j::DriverActions;
use REST::Neo4p::Exceptions;
use Try::Tiny;
Expand All @@ -14,7 +13,7 @@ use HTTP::Response;
use strict;
use warnings;
BEGIN {
$REST::Neo4p::Agent::Neo4j::Driver::VERSION = '0.4010';
$REST::Neo4p::Agent::Neo4j::Driver::VERSION = '0.4011';
}
my $WARN_ON_ERROR;

Expand Down
7 changes: 4 additions & 3 deletions lib/REST/Neo4p/Batch.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use v5.10.1;
package REST::Neo4p::Batch;
use REST::Neo4p::Exceptions;
use JSON::XS;
use JSON::MaybeXS ();
use REST::Neo4p::ParseStream;
use HOP::Stream qw/drop head/;
require REST::Neo4p;
Expand All @@ -13,7 +13,7 @@ use warnings;
no warnings qw(once);

BEGIN {
$REST::Neo4p::Batch::VERSION = '0.4010';
$REST::Neo4p::Batch::VERSION = '0.4011';
}

our @EXPORT = qw(batch);
Expand All @@ -33,14 +33,15 @@ sub batch (&@) {
$agent->batch_mode(1);
$coderef->();
my $tmpfh = $agent->execute_batch_chunk;
my $jsonr = JSON::XS->new->utf8;
my $jsonr = JSON::MaybeXS->new->utf8;
my $buf;
$tmpfh->read($buf, $BUFSIZE);
$jsonr->incr_parse($buf);
my $res = j_parse($jsonr);
die "j_parse: expecting BATCH stream" unless ($res->[0] eq 'BATCH');
my $str = $res->[1]->();
while (my $obj = drop($str)) {
no if $^V ge v5.37, warnings => 'deprecated::smartmatch';
use experimental qw/smartmatch/;
$obj = $obj->[1];
given ($obj) {
Expand Down
2 changes: 1 addition & 1 deletion lib/REST/Neo4p/Constrain.pm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ no warnings qw(once redefine);


BEGIN {
$REST::Neo4p::Constrain::VERSION = '0.4010';
$REST::Neo4p::Constrain::VERSION = '0.4011';
}
our @EXPORT = qw(create_constraint drop_constraint constrain relax);
our @VALIDATE = qw(validate_properties validate_relationship validate_relationship_type);
Expand Down
6 changes: 3 additions & 3 deletions lib/REST/Neo4p/Constraint.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package REST::Neo4p::Constraint;
use base 'Exporter';
use REST::Neo4p;
use REST::Neo4p::Exceptions;
use JSON;
use JSON::MaybeXS qw(decode_json);
use Data::Dumper;

use Scalar::Util qw(looks_like_number);
Expand All @@ -19,7 +19,7 @@ our %EXPORT_TAGS = (
all => [@EXPORT,@EXPORT_OK]
);

our $jobj = JSON->new->utf8;
our $jobj = JSON::MaybeXS->new->utf8;
$jobj->allow_blessed(1);
$jobj->convert_blessed(1);
my $regex_to_json = sub {
Expand All @@ -31,7 +31,7 @@ my $regex_to_json = sub {
};

BEGIN {
$REST::Neo4p::Constraint::VERSION = '0.4010';
$REST::Neo4p::Constraint::VERSION = '0.4011';
}

# valid constraint types
Expand Down
6 changes: 3 additions & 3 deletions lib/REST/Neo4p/Constraint/Property.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use strict;
use warnings;

BEGIN {
$REST::Neo4p::Constraint::Property::VERSION = '0.4010';
$REST::Neo4p::Constraint::Property::VERSION = '0.4011';
}

sub new_from_constraint_hash {
Expand Down Expand Up @@ -189,7 +189,7 @@ use base 'REST::Neo4p::Constraint::Property';
use strict;
use warnings;
BEGIN {
$REST::Neo4p::Constraint::NodeProperty::VERSION='0.4010';
$REST::Neo4p::Constraint::NodeProperty::VERSION='0.4011';
}

sub new {
Expand All @@ -216,7 +216,7 @@ use strict;
use warnings;

BEGIN {
$REST::Neo4p::Constraint::RelationshipProperty::VERSION='0.4010';
$REST::Neo4p::Constraint::RelationshipProperty::VERSION='0.4011';
}
# relationship_type is added as a pseudoproperty

Expand Down
2 changes: 1 addition & 1 deletion lib/REST/Neo4p/Constraint/Relationship.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use strict;
use warnings;

BEGIN {
$REST::Neo4p::Constraint::Relationship::VERSION = '0.4010';
$REST::Neo4p::Constraint::Relationship::VERSION = '0.4011';
}

sub new {
Expand Down
2 changes: 1 addition & 1 deletion lib/REST/Neo4p/Constraint/RelationshipType.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use strict;
use warnings;

BEGIN {
$REST::Neo4p::Constraint::RelationshipType::VERSION = '0.4010';
$REST::Neo4p::Constraint::RelationshipType::VERSION = '0.4011';
}

sub new {
Expand Down
5 changes: 2 additions & 3 deletions lib/REST/Neo4p/Entity.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ use v5.10;
package REST::Neo4p::Entity;
use REST::Neo4p::Exceptions;
use Carp qw(croak carp);
use JSON;
use Scalar::Util qw(blessed);
use URI::Escape;
use strict;
use warnings;

# base class for nodes, relationships, indexes...
BEGIN {
$REST::Neo4p::Entity::VERSION = '0.4010';
$REST::Neo4p::Entity::VERSION = '0.4011';
}

our $ENTITY_TABLE = {};
Expand Down Expand Up @@ -465,7 +464,7 @@ use strict;
use warnings;
no warnings qw/once/;
BEGIN {
$REST::Neo4p::Simple::VERSION = '0.4010';
$REST::Neo4p::Simple::VERSION = '0.4011';
}

sub new { $_[1] }
Expand Down
2 changes: 1 addition & 1 deletion lib/REST/Neo4p/Exceptions.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use strict;
use warnings;

BEGIN {
$REST::Neo4p::Exceptions::VERSION = '0.4010';
$REST::Neo4p::Exceptions::VERSION = '0.4011';
}
use Exception::Class (
'REST::Neo4p::Exception',
Expand Down
2 changes: 1 addition & 1 deletion lib/REST/Neo4p/Index.pm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use strict;
use warnings;

BEGIN {
$REST::Neo4p::Index::VERSION = '0.4010';
$REST::Neo4p::Index::VERSION = '0.4011';
}

my $unsafe = "^A-Za-z0-9\-\._\ ~";
Expand Down
3 changes: 1 addition & 2 deletions lib/REST/Neo4p/Node.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ package REST::Neo4p::Node;
use base 'REST::Neo4p::Entity';
use REST::Neo4p::Relationship;
use REST::Neo4p::Exceptions;
use JSON;
use Carp qw(croak carp);
use strict;
use warnings;
BEGIN {
$REST::Neo4p::Node::VERSION = '0.4010';
$REST::Neo4p::Node::VERSION = '0.4011';
}

# creation, deletion and property manipulation are delegated
Expand Down
5 changes: 3 additions & 2 deletions lib/REST/Neo4p/ParseStream.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use strict;
use warnings;

BEGIN {
$REST::Neo4p::ParseStream::VERSION = '0.4010';
$REST::Neo4p::ParseStream::VERSION = '0.4011';
}

our @EXPORT = qw/j_parse/;# j_parse_object j_parse_array /;
Expand All @@ -28,6 +28,7 @@ sub j_parse {
elsif ($j->incr_text =~ s/^\s*{\s*//) {
# object
my $type;
no if $^V ge v5.37, warnings => 'deprecated::smartmatch';
use experimental 'smartmatch';
given ($j->incr_text) {
when (/^\s*"commit"/i) {
Expand Down Expand Up @@ -122,7 +123,6 @@ sub j_parse_object {
my $done;
unless ($current eq 'PENDING') {
my $m;
use experimental 'smartmatch';
eval {
$j->incr_text =~ m/^(?:(\s*"([^"]+)"\s*:\s*)|(\s*}\s*))/; # look ahead
$m = $2||$3;
Expand All @@ -148,6 +148,7 @@ sub j_parse_object {
}
$key = $m;
}
no if $^V ge v5.37, warnings => 'deprecated::smartmatch';
use experimental 'smartmatch';
given ($key) {
when ('columns') {
Expand Down
2 changes: 1 addition & 1 deletion lib/REST/Neo4p/Path.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use Scalar::Util qw(blessed);
use strict;
use warnings;
BEGIN {
$REST::Neo4p::Path::VERSION = '0.4010';
$REST::Neo4p::Path::VERSION = '0.4011';
}

sub new {
Expand Down
Loading
Loading