The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
package Woothee::Util;

use strict;
use warnings;
use Carp;

use Woothee::DataSet;

our $VERSION = "1.5.0";

our (@ISA, @EXPORT_OK);
BEGIN {
    require Exporter;
    our @ISA = qw(Exporter);
    our @EXPORT_OK = qw(update_map update_category update_version update_os update_os_version);
}

sub update_map {
    my ($target,$source) = @_;
    foreach my $key (%$source) {
        next if $key eq Woothee::DataSet->const('KEY_LABEL') or $key eq Woothee::DataSet->const('KEY_TYPE');
        if (defined($source->{$key}) and length($source->{$key}) > 0) {
            $target->{$key} = $source->{$key};
        }
    }
}

sub update_category {
    my ($target,$category) = @_;
    $target->{Woothee::DataSet->const('ATTRIBUTE_CATEGORY')} = $category;
}

sub update_version {
    my ($target,$version) = @_;
    $target->{Woothee::DataSet->const('ATTRIBUTE_VERSION')} = $version;
}

sub update_os {
    my ($target,$os) = @_;
    $target->{Woothee::DataSet->const('ATTRIBUTE_OS')} = $os;
}

sub update_os_version {
    my ($target,$os_version) = @_;
    $target->{Woothee::DataSet->const('ATTRIBUTE_OS_VERSION')} = $os_version;
}

1;

__END__

=head1 NAME

Woothee::Util - part of Woothee

For Woothee, see L<https://github.com/woothee/woothee>

=head1 DESCRIPTION

This module doesn't have any public interfaces. To parse user-agent strings, see module 'Woothee'.

=head1 AUTHOR

TAGOMORI Satoshi E<lt>tagomoris {at} gmail.comE<gt>

=head1 LICENSE

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.

=cut