-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Wikibase::Datatype::Value::Lexeme
- Loading branch information
1 parent
7bd94bf
commit 983a643
Showing
12 changed files
with
278 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
package Wikibase::Datatype::Value::Lexeme; | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use Mo qw(build); | ||
use Wikibase::Datatype::Utils qw(check_lexeme); | ||
|
||
our $VERSION = 0.32; | ||
|
||
extends 'Wikibase::Datatype::Value'; | ||
|
||
sub type { | ||
return 'lexeme'; | ||
} | ||
|
||
sub BUILD { | ||
my $self = shift; | ||
|
||
check_lexeme($self, 'value'); | ||
|
||
return; | ||
} | ||
|
||
1; | ||
|
||
__END__ | ||
=pod | ||
=encoding utf8 | ||
=head1 NAME | ||
Wikibase::Datatype::Value::Lexeme - Wikibase lexeme value datatype. | ||
=head1 SYNOPSIS | ||
use Wikibase::Datatype::Value::Lexeme; | ||
my $obj = Wikibase::Datatype::Value::Lexeme->new(%params); | ||
my $type = $obj->type; | ||
my $value = $obj->value; | ||
=head1 DESCRIPTION | ||
This datatype is item class for representation of wikibase lexeme (e.g. L42284). | ||
=head1 METHODS | ||
=head2 C<new> | ||
my $obj = Wikibase::Datatype::Value::Lexeme->new(%params); | ||
Constructor. | ||
Returns instance of object. | ||
=over 8 | ||
=item * C<value> | ||
Value of instance. | ||
Parameter must be in form /^L\d+$/ (regexp). | ||
Parameter is required. | ||
=back | ||
=head2 C<type> | ||
my $type = $obj->type; | ||
Get type. This is constant 'item'. | ||
Returns string. | ||
=head2 C<value> | ||
my $value = $obj->value; | ||
Get value. | ||
Returns string. | ||
=head1 ERRORS | ||
new(): | ||
From Wikibase::Datatype::Utils::check_entity(): | ||
Parameter 'value' must begin with 'Q' and number after it. | ||
From Wikibase::Datatype::Value::new(): | ||
Parameter 'value' is required. | ||
=head1 EXAMPLE | ||
=for comment filename=create_and_print_value_lexeme.pl | ||
use strict; | ||
use warnings; | ||
use Wikibase::Datatype::Value::Lexeme; | ||
# Object. | ||
my $obj = Wikibase::Datatype::Value::Lexeme->new( | ||
'value' => 'L42284', | ||
); | ||
# Get value. | ||
my $value = $obj->value; | ||
# Get type. | ||
my $type = $obj->type; | ||
# Print out. | ||
print "Type: $type\n"; | ||
print "Value: $value\n"; | ||
# Output: | ||
# Type: item | ||
# Value: L42284 | ||
=head1 DEPENDENCIES | ||
L<Error::Pure>, | ||
L<Mo>, | ||
L<Wikibase::Datatype::Utils>, | ||
L<Wikibase::Datatype::Value>. | ||
=head1 SEE ALSO | ||
=over | ||
=item L<Wikibase::Datatype::Value> | ||
Wikibase datatypes. | ||
=back | ||
=head1 REPOSITORY | ||
L<https://github.com/michal-josef-spacek/Wikibase-Datatype> | ||
=head1 AUTHOR | ||
Michal Josef Špaček L<mailto:skim@cpan.org> | ||
L<http://skim.cz> | ||
=head1 LICENSE AND COPYRIGHT | ||
© 2020-2023 Michal Josef Špaček | ||
BSD 2-Clause License | ||
=head1 VERSION | ||
0.32 | ||
=cut |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use strict; | ||
use warnings; | ||
|
||
use Test::More 'tests' => 3; | ||
use Test::NoWarnings; | ||
|
||
BEGIN { | ||
|
||
# Test. | ||
use_ok('Wikibase::Datatype::Value::Lexeme'); | ||
} | ||
|
||
# Test. | ||
require_ok('Wikibase::Datatype::Value::Lexeme'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
use strict; | ||
use warnings; | ||
|
||
use Test::More 'tests' => 2; | ||
use Test::NoWarnings; | ||
use Wikibase::Datatype::Value::Lexeme; | ||
|
||
# Test. | ||
is($Wikibase::Datatype::Value::Lexeme::VERSION, 0.32, 'Version.'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use strict; | ||
use warnings; | ||
|
||
use English; | ||
use Error::Pure::Utils qw(clean); | ||
use Test::More 'tests' => 4; | ||
use Test::NoWarnings; | ||
use Wikibase::Datatype::Value::Lexeme; | ||
|
||
# Test. | ||
my $obj = Wikibase::Datatype::Value::Lexeme->new( | ||
'value' => 'L42284', | ||
); | ||
isa_ok($obj, 'Wikibase::Datatype::Value::Lexeme'); | ||
|
||
# Test. | ||
eval { | ||
Wikibase::Datatype::Value::Lexeme->new; | ||
}; | ||
is($EVAL_ERROR, "Parameter 'value' is required.\n", | ||
"Parameter 'value' is required."); | ||
clean(); | ||
|
||
# Test. | ||
eval { | ||
Wikibase::Datatype::Value::Lexeme->new( | ||
'value' => 'foo', | ||
); | ||
}; | ||
is($EVAL_ERROR, "Parameter 'value' must begin with 'L' and number after it.\n", | ||
"Bad 'value' parameter."); | ||
clean(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
use strict; | ||
use warnings; | ||
|
||
use Test::More 'tests' => 2; | ||
use Test::NoWarnings; | ||
use Wikibase::Datatype::Value::Lexeme; | ||
|
||
# Test. | ||
my $obj = Wikibase::Datatype::Value::Lexeme->new( | ||
'value' => 'L42284', | ||
); | ||
my $ret = $obj->type; | ||
is($ret, 'lexeme', 'Get type().'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
use strict; | ||
use warnings; | ||
|
||
use Test::More 'tests' => 2; | ||
use Test::NoWarnings; | ||
use Wikibase::Datatype::Value::Lexeme; | ||
|
||
# Test. | ||
my $obj = Wikibase::Datatype::Value::Lexeme->new( | ||
'value' => 'L42284', | ||
); | ||
my $ret = $obj->value; | ||
is($ret, 'L42284', 'Get value().'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use strict; | ||
use warnings; | ||
|
||
use Test::NoWarnings; | ||
use Test::Pod::Coverage 'tests' => 2; | ||
|
||
# Test. | ||
pod_coverage_ok('Wikibase::Datatype::Value::Lexeme', | ||
{ 'also_private' => ['BUILD'] }, | ||
'Wikibase::Datatype::Value::Lexeme is covered.'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use strict; | ||
use warnings; | ||
|
||
use English qw(-no_match_vars); | ||
use File::Object; | ||
use Test::More 'tests' => 2; | ||
use Test::NoWarnings; | ||
|
||
# Test. | ||
SKIP: { | ||
if ($PERL_VERSION lt v5.8.0) { | ||
skip 'Perl version lesser then 5.8.0.', 1; | ||
} | ||
require Test::Pod; | ||
Test::Pod::pod_file_ok(File::Object->new->up(2)->file('lib', 'Wikibase', 'Datatype', 'Value', 'Lexeme.pm')->s); | ||
}; |