JavaScript-Const-Exporter

 view release on metacpan or  search on metacpan

lib/JavaScript/Const/Exporter.pm  view on Meta::CPAN

package JavaScript::Const::Exporter;

# ABSTRACT: Convert exported Perl constants to JavaScript

use v5.10;

use Moo 1.002000;
use MooX::Options
    protect_argv => 0,
    usage_string => '%c %o [output-filename]';

use Carp;
use JSON::MaybeXS ();
use Module::Load qw/ load /;
use Package::Stash;
use Ref::Util qw/ is_scalarref /;
use Sub::Identify 0.06 qw/ is_sub_constant /;
use Types::Common::String qw/ NonEmptySimpleStr /;
use Types::Standard qw/ ArrayRef Bool HashRef InstanceOf /;

# RECOMMEND PREREQ: Cpanel::JSON::XS
# RECOMMEND PREREQ: Package::Stash::XS
# RECOMMEND PREREQ: Ref::Util::XS
# RECOMMEND PREREQ: Type::Tiny::XS

use namespace::autoclean;

our $VERSION = 'v0.1.7';


option use_var => (
    is        => 'ro',
    isa       => Bool,
    default   => 0,
    negatable => 0,
    short     => 'u',
    doc       => 'use var instead of const',
);


option module => (
    is       => 'ro',
    isa      => NonEmptySimpleStr,
    required => 1,
    format   => 's',
    short    => 'm',
    doc      => 'module name to extract constants from',
);


option constants => (
    is         => 'ro',
    isa        => ArrayRef [NonEmptySimpleStr],
    predicate  => 1,
    format     => 's',
    repeatable => 1,
    short      => 'c',
    doc        => 'constants or export tags to extract',
);


option include => (
    is         => 'ro',
    isa        => ArrayRef [NonEmptySimpleStr],
    predicate  => 1,
    short      => 'I',
    format     => 's',
    repeatable => 1,
    doc        => 'paths to include',
);


option pretty => (
    is        => 'ro',
    isa       => Bool,
    default   => 0,
    short     => 'p',
    doc       => 'enable pretty printed JSON',
);


has stash => (
    is      => 'lazy',



( run in 1.156 second using v1.01-cache-2.11-cpan-39bf76dae61 )