summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Data/QRCode.pm47
-rw-r--r--lib/Data/QRCode/Input.pm55
-rw-r--r--lib/Data/QRCode/Result.pm25
-rw-r--r--lib/Data/QRCode/Types.pm2
-rw-r--r--perlcritic.rc2
5 files changed, 127 insertions, 4 deletions
diff --git a/lib/Data/QRCode.pm b/lib/Data/QRCode.pm
index 649e1f9..37cab64 100644
--- a/lib/Data/QRCode.pm
+++ b/lib/Data/QRCode.pm
@@ -8,6 +8,28 @@ use namespace::clean;
# ABSTRACT: qrcodes in C
# VERSION
+=head1 SYNOPSIS
+
+ use Data::QRCode;
+
+ my $qr = Data::QRCode->new('some string');
+
+ my $text_matrix = $qr->map(
+ sub { $_[0]->{color} ? '*' : ' ' }
+ );
+
+ print "$_\n" for map { join '',@{$_} } @{$text_matrix};
+
+=head1 DESCRIPTION
+
+This class exposes a simple interface to the L<<
+C<qrencode>|http://fukuchi.org/works/qrencode/index.html.en >>
+library.
+
+=attr C<error_correction_level>
+
+=cut
+
has error_correction_level => (
is => 'ro',
isa => QRCodeEC,
@@ -15,6 +37,10 @@ has error_correction_level => (
default => Data::QRCode::Input::ECLEVEL_M,
);
+=attr C<mode>
+
+=cut
+
has mode => (
is => 'ro',
isa => QRCodeMode,
@@ -22,12 +48,23 @@ has mode => (
default => Data::QRCode::Input::MODE_8,
);
+=attr C<version>
+
+=cut
+
has version => (
is => 'rwp',
isa => Int,
default => 0,
);
+=attr C<input_data>
+
+=for Pod::Coverage
+BUILDARGS
+
+=cut
+
has input_data => (
is => 'ro',
required => 1,
@@ -49,7 +86,7 @@ has _result => (
handles => [ qw(width data_at) ],
);
-sub _build__result {
+sub _build__result { ## no critic(ProhibitUnusedPrivateSubroutines)
my ($self) = @_;
my $input = Data::QRCode::Input->new();
@@ -63,7 +100,11 @@ sub _build__result {
return $ret;
}
-sub map {
+=method C<map>
+
+=cut
+
+sub map { ## no critic(ProhibitBuiltinHomonyms)
my ($self,$code) = @_;
my $r = $self->_result;
@@ -74,7 +115,7 @@ sub map {
# use the internal function to avoid re-checking the x/y
# bounds
my $raw_data = $r->_data_at($x,$y);
- my $hash_data = Data::QRCode::Result::_data_hash($raw_data);
+ my $hash_data = Data::QRCode::Result::_data_hash($raw_data); ## no critic(ProtectPrivateSubs)
push @{$result[-1]}, $code->($hash_data,$raw_data);
}
diff --git a/lib/Data/QRCode/Input.pm b/lib/Data/QRCode/Input.pm
index 69fd283..937474c 100644
--- a/lib/Data/QRCode/Input.pm
+++ b/lib/Data/QRCode/Input.pm
@@ -10,6 +10,20 @@ use Data::QRCode::Input::Inline C => (
typemaps => 'typemap',
);
+=head1 SYNOPSIS
+
+ use Data::QRCode::Input;
+
+ my $input = Data::QRCode::Input->new();
+
+ $input->version(3);
+ $input->error_correction_level(Data::QRCode::Input::ECLEVEL_M);
+ $input->append(Data::QRCode::Input::MODE_8, 'some data'),
+
+=method C<new>
+
+=cut
+
sub new {
my ($class) = @_;
@@ -18,6 +32,10 @@ sub new {
return $self;
}
+=attr C<version>
+
+=cut
+
sub version {
my $self = shift;
if (@_) {
@@ -28,6 +46,10 @@ sub version {
}
}
+=attr C<error_correction_level>
+
+=cut
+
sub error_correction_level {
my $self = shift;
if (@_) {
@@ -38,6 +60,39 @@ sub error_correction_level {
}
}
+=head2 CONSTANTS
+
+=head3 Error Correction Level
+
+=for :list
+= C<ECLEVEL_L>
+= C<ECLEVEL_M>
+= C<ECLEVEL_Q>
+= C<ECLEVEL_H>
+
+=head3 Data Mode
+
+=for :list
+= C<MODE_NUM>
+= C<MODE_AN>
+= C<MODE_8>
+= C<MODE_KANJI>
+= C<MODE_STRUCTURE>
+= C<MODE_ECI>
+= C<MODE_FNC1FIRST>
+= C<MODE_FNC1SECOND>
+
+=method C<append>
+
+=for Pod::Coverage
+QRinput_getVersion
+QRinput_setVersion
+QRinput_getErrorCorrectionLevel
+QRinput_setErrorCorrectionLevel
+QRinput_new
+
+=cut
+
1;
__DATA__
diff --git a/lib/Data/QRCode/Result.pm b/lib/Data/QRCode/Result.pm
index 10c79d0..9821868 100644
--- a/lib/Data/QRCode/Result.pm
+++ b/lib/Data/QRCode/Result.pm
@@ -10,6 +10,18 @@ use Data::QRCode::Result::Inline C => (
typemaps => 'typemap',
);
+=head1 SYNOPSIS
+
+ use Data::QRCode::Result;
+
+ my $qr = Data::QRCode::Result->new(build_a_qrcode_input());
+
+ print $qr->data_at(1,1);
+
+=method C<new>
+
+=cut
+
sub new {
my ($class, $input) = @_;
my $self = QRcode_encodeInput($input);
@@ -32,6 +44,10 @@ sub _data_hash {
};
}
+=method C<data_at>
+
+=cut
+
sub data_at {
my ($self,$x,$y) = @_;
my $width = $self->width;
@@ -41,6 +57,15 @@ sub data_at {
return _data_hash($self->_data_at($x,$y));
}
+=method C<version>
+
+=method C<width>
+
+=for Pod::Coverage
+QRcode_encodeInput
+
+=cut
+
1;
__DATA__
diff --git a/lib/Data/QRCode/Types.pm b/lib/Data/QRCode/Types.pm
index ac711e2..f0cfbcb 100644
--- a/lib/Data/QRCode/Types.pm
+++ b/lib/Data/QRCode/Types.pm
@@ -8,6 +8,8 @@ use Type::Utils -all;
use Types::Standard qw(Int Str);
use Data::QRCode::Input;
use Carp;
+# ABSTRACT: types
+# VERSION
my %letter_for_ec = (
Data::QRCode::Input::ECLEVEL_L() => 'L',
diff --git a/perlcritic.rc b/perlcritic.rc
index 651ba52..4006213 100644
--- a/perlcritic.rc
+++ b/perlcritic.rc
@@ -36,7 +36,7 @@ severity = 1
# UNIVERSAL::isa
# Don't pass $_ to built-in functions that assume it, or to most filetest operators.
-[BuiltinFunctions::ProhibitUselessTopic]
+[-BuiltinFunctions::ProhibitUselessTopic]
# Don't use `grep' in void contexts.
[BuiltinFunctions::ProhibitVoidGrep]