ARGV-JSON
view release on metacpan or search on metacpan
use CPAN::Meta::Prereqs;
my %args = (
license => 'perl',
dynamic_config => 0,
configure_requires => {
'Module::Build' => 0.38,
},
name => 'ARGV-JSON',
module_name => 'ARGV::JSON',
allow_pureperl => 0,
script_files => [glob('script/*'), glob('bin/*')],
c_source => [qw()],
PL_files => {},
test_files => ((-d '.git' || $ENV{RELEASE_TESTING}) && -d 'xt') ? 't/ xt/' : 't/',
recursive_test_files => 1,
Revision history for Perl extension ARGV-JSON
0.01 2013-12-18T01:23:44Z
- original version
Build.PL
Changes
LICENSE
META.json
README.md
cpanfile
lib/ARGV/JSON.pm
minil.toml
t/00_compile.t
t/01_argv.t
t/data/01.json
META.yml
MANIFEST
{
"abstract" : "Parses @ARGV for accessing JSON via C<< <> >>",
"author" : [
"motemen <motemen@gmail.com>"
],
"dynamic_config" : 0,
"generated_by" : "Minilla/v0.11.0",
"license" : [
"perl_5"
],
"meta-spec" : {
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
"version" : "2"
},
"name" : "ARGV-JSON",
"no_index" : {
"directory" : [
"t",
"xt",
"inc",
"share",
"eg",
"examples",
"author",
"builder"
"develop" : {
"requires" : {
"Test::CPAN::Meta" : "0",
"Test::MinimumVersion" : "0.10108",
"Test::Pod" : "1.41",
"Test::Spellunker" : "v0.2.7"
}
},
"runtime" : {
"requires" : {
"JSON" : "0",
"Tie::Handle" : "0",
"parent" : "0",
"perl" : "5.008005"
}
},
"test" : {
"requires" : {
"Test::More" : "0.98"
}
}
},
"provides" : {
"ARGV::JSON" : {
"file" : "lib/ARGV/JSON.pm",
"version" : "0.01"
}
},
"release_status" : "stable",
"resources" : {
"bugtracker" : {
"web" : "https://github.com/motemen/perl5-ARGV-JSON/issues"
},
"homepage" : "https://github.com/motemen/perl5-ARGV-JSON",
"repository" : {
"url" : "git://github.com/motemen/perl5-ARGV-JSON.git",
"web" : "https://github.com/motemen/perl5-ARGV-JSON"
}
},
"version" : "0.01"
}
---
abstract: 'Parses @ARGV for accessing JSON via C<< <> >>'
author:
- 'motemen <motemen@gmail.com>'
build_requires:
Test::More: 0.98
configure_requires:
CPAN::Meta: 0
CPAN::Meta::Prereqs: 0
Module::Build: 0.38
dynamic_config: 0
generated_by: 'Minilla/v0.11.0, CPAN::Meta::Converter version 2.120921'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
name: ARGV-JSON
no_index:
directory:
- t
- xt
- inc
- share
- eg
- examples
- author
- builder
provides:
ARGV::JSON:
file: lib/ARGV/JSON.pm
version: 0.01
requires:
JSON: 0
Tie::Handle: 0
parent: 0
perl: 5.008005
resources:
bugtracker: https://github.com/motemen/perl5-ARGV-JSON/issues
homepage: https://github.com/motemen/perl5-ARGV-JSON
repository: git://github.com/motemen/perl5-ARGV-JSON.git
version: 0.01
# NAME
ARGV::JSON - Parses @ARGV for accessing JSON via `<>`
# SYNOPSIS
use ARGV::JSON;
while (<>) {
# $_ is a decoded JSON here!
}
Or in one-liner:
perl -MARGV::JSON -anal -E 'say $_->{foo}->{bar}' a.json b.json
# DESCRIPTION
ARGV::JSON parses each input from `@ARGV` and enables to access
the JSON data structures via `<>`.
Each `readline` call to `<>` (or `<ARGV>`) returns a
hashref or arrayref or something that the input serializes in the
JSON format.
# SEE ALSO
[ARGV::URL](https://metacpan.org/pod/ARGV::URL).
# LICENSE
Copyright (C) motemen.
This library is free software; you can redistribute it and/or modify
requires 'perl', '5.008001';
requires 'parent';
requires 'JSON';
requires 'Tie::Handle';
on 'test' => sub {
requires 'Test::More', '0.98';
};
lib/ARGV/JSON.pm view on Meta::CPAN
package ARGV::JSON;
use 5.008005;
use strict;
use warnings;
use JSON;
our $VERSION = '0.01';
our $JSON = JSON->new->utf8;
our @Data;
sub import {
local $/;
while (local $_ = <>) {
$JSON->incr_parse($_);
while (my $datum = $JSON->incr_parse) {
push @Data, $datum;
}
}
tie *ARGV, 'ARGV::JSON::Handle';
}
package
ARGV::JSON::Handle;
use Tie::Handle;
use parent -norequire => 'Tie::StdHandle';
sub READLINE {
if (wantarray) {
return splice @ARGV::JSON::Data;
} else {
return shift @ARGV::JSON::Data;
}
}
1;
__END__
=encoding utf-8
=head1 NAME
ARGV::JSON - Parses @ARGV for accessing JSON via C<< <> >>
=head1 SYNOPSIS
use ARGV::JSON;
while (<>) {
# $_ is a decoded JSON here!
}
Or in one-liner:
perl -MARGV::JSON -anal -E 'say $_->{foo}->{bar}' a.json b.json
=head1 DESCRIPTION
ARGV::JSON parses each input from C<< @ARGV >> and enables to access
the JSON data structures via C<< <> >>.
Each C<< readline >> call to C<< <> >> (or C<< <ARGV> >>) returns a
hashref or arrayref or something that the input serializes in the
JSON format.
=head1 SEE ALSO
L<ARGV::URL>.
=head1 LICENSE
Copyright (C) motemen.
This library is free software; you can redistribute it and/or modify
name = "ARGV-JSON"
# badges = ["travis"]
t/00_compile.t view on Meta::CPAN
use strict;
use warnings;
use Test::More;
require_ok $_ for qw(
ARGV::JSON
);
done_testing;
t/01_argv.t view on Meta::CPAN
use strict;
use warnings;
use Test::More;
use File::Spec;
use File::Basename;
BEGIN {
@ARGV = File::Spec->catfile(dirname(__FILE__), 'data', '01.json')
}
use ARGV::JSON;
is_deeply [ @ARGV::JSON::Data ], [
{
'bar' => {
'baz' => undef
},
'foo' => [
1,
2,
3
]
},
( run in 0.744 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )