Skip to content

Commit

Permalink
Swap out some modules.
Browse files Browse the repository at this point in the history
  • Loading branch information
oalders committed Feb 11, 2014
1 parent a2dd763 commit 05f5aa3
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 14 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,4 @@ t/conf/apache_test_config.pm
t/conf/extra.conf
t/conf/httpd.conf
t/conf/mime.types
t/htdocs/index.html
t/logs
3 changes: 2 additions & 1 deletion cpanfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
requires 'Apache::Test';
requires 'Apache::TestRequest';
requires 'Cpanel::JSON::XS';
requires 'Data::Printer';
requires 'Data::Validate::IP';
requires 'Encode';
requires 'File::Slurp';
requires 'Hash::Flatten';
requires 'JSON::XS';
requires 'List::AllUtils', '0.07';
requires 'List::Util', '>= 1.38';
requires 'Net::Works::Network';
8 changes: 4 additions & 4 deletions lib/Apache/TestModMaxMindDB.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ $Apache::TestModMaxMindDB::VERSION = '0.1';
use strict;
use warnings;

use Cpanel::JSON::XS qw( decode_json );
use Path::Tiny qw( path );
use File::Slurp qw( read_file );
use JSON::XS qw( decode_json );
use Moo;

has city_source_data => (
Expand All @@ -17,8 +17,8 @@ has city_source_data => (

sub _build_city_source_data {
my $self = shift;
my $json = Cpanel::JSON::XS->new;
my @lines = path('maxmind-db/source-data/GeoIP2-City-Test.json')->lines;
my $json = JSON::XS->new;
my @lines = read_file('maxmind-db/source-data/GeoIP2-City-Test.json');

# hashref keyed on IP ranges
return { map { my $record = decode_json($_); shift @{$record} => $record->[0] }
Expand Down
6 changes: 2 additions & 4 deletions t/cgi-bin/valid-db/json-env
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
use strict;
use warnings;

#use utf8::all;

use Encode qw( decode );
use Cpanel::JSON::XS;
use JSON::XS;

my %env = map { $_ => decode( 'UTF-8', $ENV{$_} ) } keys %ENV;

print "Content-type: application/json; charset=UTF-8\n\n";
print Cpanel::JSON::XS->new->utf8->ascii->pretty->encode( \%env );
print JSON::XS->new->utf8->ascii->pretty->encode( \%env );

1 change: 1 addition & 0 deletions t/htdocs/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
foo
2 changes: 1 addition & 1 deletion t/localhost.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use warnings FATAL => 'all';

use Apache::Test qw(-withtestmore);
use Apache::TestRequest;
use Cpanel::JSON::XS qw( decode_json );
use JSON::XS qw( decode_json );

my $url = '/cgi-bin/valid-db/json-env';

Expand Down
5 changes: 2 additions & 3 deletions t/x-forwarded-for.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ use warnings;
use Apache::Test qw(-withtestmore);
use Apache::TestModMaxMindDB;
use Apache::TestRequest;
use Cpanel::JSON::XS;
use Data::Validate::IP;
use DDP;
use Encode qw( decode_utf8 );
use Hash::Flatten;
use JSON::XS;
use Net::Works::Network;

my $builder = Test::More->builder;
Expand All @@ -26,7 +25,7 @@ my $get_with_xff_c = sub {
# Allow request to be redirected.
my $res = GET $url, 'X-Forwarded-For' => $xff_ip;
ok( $res, '$res is defined' );
my $srv_env = Cpanel::JSON::XS->new->decode( $res->content );
my $srv_env = JSON::XS->new->decode( $res->content );

$code->( $res, $srv_env, $xff_ip );
}
Expand Down

0 comments on commit 05f5aa3

Please sign in to comment.