Skip to content

Commit

Permalink
Be private func
Browse files Browse the repository at this point in the history
  • Loading branch information
bayashi committed Jul 14, 2024
1 parent aadc408 commit 3c897e9
Show file tree
Hide file tree
Showing 67 changed files with 215 additions and 231 deletions.
24 changes: 4 additions & 20 deletions lib/Duadua.pm
Original file line number Diff line number Diff line change
Expand Up @@ -212,19 +212,19 @@ sub version {
shift->_result->{version} || '';
}

sub contain_mozilla {
sub _contain_mozilla {
return 1 if shift->{_contain_mozilla}
}

sub contain_mozilla_top {
sub _contain_mozilla_top {
return 1 if shift->{_contain_mozilla_top}
}

sub prefix {
sub _prefix {
return 1 if index(shift->{_ua}, shift) == 0;
}

sub contain {
sub _contain {
return 1 if index(shift->{_ua}, shift) != -1;
}

Expand Down Expand Up @@ -377,22 +377,6 @@ Returns version from user agent string
The list of User Agent Parser
=item prefix
Returns true value if the User-Agent contains $str on the top.
=item contain($str)
Returns true value if the User-Agent contains $str.
=item contain_mozilla
Returns true value if the User-Agent contains 'Mozilla'.
=item contain_mozilla_top
Returns true value if the User-Agent contains 'Mozilla' on the top of User-Agent.
=back
Expand Down
6 changes: 3 additions & 3 deletions lib/Duadua/Parser.pm
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ sub parse {
sub _detect_general_browser {
my ($class, $d) = @_;

if ( index($d->ua, 'rowser') > 0 && $d->prefix('Mozilla/') ) {
if ( index($d->ua, 'rowser') > 0 && $d->_prefix('Mozilla/') ) {
if ( $d->ua =~ m![^a-zA-Z]([a-zA-Z]+[bB]rowser)/([\d.]+)! ) {
my %h = %{$BLANK_UA};
($h{name}, $h{version}) = ($1, $2);
Expand All @@ -57,9 +57,9 @@ sub _detect_general_bot {

my %h = %{$BLANK_UA};

if ( $d->contain('https://') || $d->contain('http://') ) {
if ( $d->_contain('https://') || $d->_contain('http://') ) {
$h{is_bot} = 1;
if ( !$d->contain('Mozilla/') && $d->ua =~ m!^([^/;]+)/(v?[\d.]+)! ) {
if ( !$d->_contain('Mozilla/') && $d->ua =~ m!^([^/;]+)/(v?[\d.]+)! ) {
my ($name, $version) = ($1, $2);
$h{name} = $name;
$h{version} = $version;
Expand Down
10 changes: 5 additions & 5 deletions lib/Duadua/Parser/Bot/AdIdxBot.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use warnings;
sub try {
my ($class, $d) = @_;

if ( $d->contain('adidxbot/')
&& $d->contain('+http://www.bing.com/bingbot.htm')
&& $d->contain_mozilla ) {
if ( $d->_contain('adidxbot/')
&& $d->_contain('+http://www.bing.com/bingbot.htm')
&& $d->_contain_mozilla ) {
my $h = _set_property($d, 'AdIdxBot');

if ($d->opt_version) {
Expand All @@ -27,10 +27,10 @@ sub _set_property {
is_bot => 1,
};

if ( $d->contain('Windows') ) {
if ( $d->_contain('Windows') ) {
$h->{is_windows} = 1;
}
elsif ( $d->contain('iPhone') ) {
elsif ( $d->_contain('iPhone') ) {
$h->{is_ios} = 1;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Duadua/Parser/Bot/AdstxtCom.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use Duadua::Util qw//;
sub try {
my ($class, $d) = @_;

if ( $d->contain('adstxt.com/') ) {
if ( $d->_contain('adstxt.com/') ) {
my $h = {
name => 'adstxt.com',
is_bot => 1,
Expand Down
2 changes: 1 addition & 1 deletion lib/Duadua/Parser/Bot/Applebot.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use warnings;
sub try {
my ($class, $d) = @_;

if ( $d->contain('(Applebot/') ) {
if ( $d->_contain('(Applebot/') ) {
my $h = {
name => 'Applebot',
is_bot => 1,
Expand Down
2 changes: 1 addition & 1 deletion lib/Duadua/Parser/Bot/Baiduspider.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use warnings;
sub try {
my ($class, $d) = @_;

if ( $d->contain('Baiduspider') ) {
if ( $d->_contain('Baiduspider') ) {
my $h = {
name => 'Baiduspider',
is_bot => 1,
Expand Down
2 changes: 1 addition & 1 deletion lib/Duadua/Parser/Bot/Barkrowler.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use Duadua::Util qw//;
sub try {
my ($class, $d) = @_;

if ( $d->contain('Barkrowler/') ) {
if ( $d->_contain('Barkrowler/') ) {
my $h = {
name => 'Barkrowler',
is_bot => 1,
Expand Down
6 changes: 3 additions & 3 deletions lib/Duadua/Parser/Bot/BingPreview.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use warnings;
sub try {
my ($class, $d) = @_;

if ( $d->contain('BingPreview/')
&& $d->contain_mozilla ) {
if ( $d->_contain('BingPreview/')
&& $d->_contain_mozilla ) {
my $h = _set_property($d, 'BingPreview');

if ($d->opt_version) {
Expand All @@ -26,7 +26,7 @@ sub _set_property {
is_bot => 1,
};

if ( $d->contain('Windows') ) {
if ( $d->_contain('Windows') ) {
$h->{is_windows} = 1;
}

Expand Down
10 changes: 5 additions & 5 deletions lib/Duadua/Parser/Bot/Bingbot.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use warnings;
sub try {
my ($class, $d) = @_;

if ( $d->contain('bingbot/')
&& $d->contain('+http://www.bing.com/bingbot.htm')
&& $d->contain_mozilla ) {
if ( $d->_contain('bingbot/')
&& $d->_contain('+http://www.bing.com/bingbot.htm')
&& $d->_contain_mozilla ) {
my $h = _set_property($d, 'Bingbot');

if ($d->opt_version) {
Expand All @@ -27,10 +27,10 @@ sub _set_property {
is_bot => 1,
};

if ( $d->contain('Windows') ) {
if ( $d->_contain('Windows') ) {
$h->{is_windows} = 1;
}
elsif ( $d->contain('iPhone') ) {
elsif ( $d->_contain('iPhone') ) {
$h->{is_ios} = 1;
}

Expand Down
32 changes: 16 additions & 16 deletions lib/Duadua/Parser/Bot/BotMisc.pm
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ sub try {
is_bot => 1,
};
}
elsif ( $d->contain('Yeti/')
&& $d->contain('+http://') && $d->contain('naver.') ) {
elsif ( $d->_contain('Yeti/')
&& $d->_contain('+http://') && $d->_contain('naver.') ) {
$h = {
name => 'Naver Yeti',
is_bot => 1,
Expand All @@ -26,13 +26,13 @@ sub try {
$h->{version} = $version if $version;
}
}
elsif ( $d->contain(' proximic;') ) {
elsif ( $d->_contain(' proximic;') ) {
$h = {
name => 'Comscore crawler',
is_bot => 1,
};
}
elsif ( $d->contain(' Daum/') ) {
elsif ( $d->_contain(' Daum/') ) {
$h = {
name => 'Daum',
is_bot => 1,
Expand All @@ -45,7 +45,7 @@ sub try {

$h = Duadua::Util->set_os($d, $h);
}
elsif ( $d->contain('MixnodeCache/') ) {
elsif ( $d->_contain('MixnodeCache/') ) {
$h = {
name => 'mixnode.com',
is_bot => 1,
Expand All @@ -56,13 +56,13 @@ sub try {
$h->{version} = $version if $version;
}
}
elsif ( $d->contain('SearchAtlas.com ') ) {
elsif ( $d->_contain('SearchAtlas.com ') ) {
$h = {
name => 'SearchAtlas.com',
is_bot => 1,
};
}
elsif ( $d->contain('ltx71') ) {
elsif ( $d->_contain('ltx71') ) {
$h = {
name => 'ltx71',
is_bot => 1,
Expand All @@ -74,7 +74,7 @@ sub try {
is_bot => 1,
};
}
elsif ( $d->contain(' FlipboardProxy/') ) {
elsif ( $d->_contain(' FlipboardProxy/') ) {
$h = {
name => 'FlipboardProxy',
is_bot => 1,
Expand All @@ -85,7 +85,7 @@ sub try {
$h->{version} = $version if $version;
}
}
elsif ( $d->contain(' BuiltWith/') ) {
elsif ( $d->_contain(' BuiltWith/') ) {
$h = {
name => 'BuiltWith',
is_bot => 1,
Expand All @@ -98,7 +98,7 @@ sub try {

$h = Duadua::Util->set_os($d, $h);
}
elsif ( $d->contain(' zgrab/') ) {
elsif ( $d->_contain(' zgrab/') ) {
$h = {
name => 'ZGrab',
is_bot => 1,
Expand All @@ -111,7 +111,7 @@ sub try {

$h = Duadua::Util->set_os($d, $h);
}
elsif ( $d->contain(' RyowlEngine/') ) {
elsif ( $d->_contain(' RyowlEngine/') ) {
$h = {
name => 'RyowlEngine',
is_bot => 1,
Expand All @@ -124,7 +124,7 @@ sub try {

$h = Duadua::Util->set_os($d, $h);
}
elsif ( $d->contain(' DataXu/') ) {
elsif ( $d->_contain(' DataXu/') ) {
$h = {
name => 'DataXu',
is_bot => 1,
Expand All @@ -137,7 +137,7 @@ sub try {

$h = Duadua::Util->set_os($d, $h);
}
elsif ( $d->contain('istellabot/') ) {
elsif ( $d->_contain('istellabot/') ) {
$h = {
name => 'istellabot',
is_bot => 1,
Expand All @@ -150,7 +150,7 @@ sub try {

$h = Duadua::Util->set_os($d, $h);
}
elsif ( $d->contain(' Cincraw/') ) {
elsif ( $d->_contain(' Cincraw/') ) {
$h = {
name => 'Cincraw',
is_bot => 1,
Expand All @@ -161,13 +161,13 @@ sub try {
$h->{version} = $version if $version;
}
}
elsif ( $d->contain('KOCMOHABT ') ) {
elsif ( $d->_contain('KOCMOHABT ') ) {
$h = {
name => 'KOCMOHABT',
is_bot => 1,
};
}
elsif ( $d->contain('Hexometer') ) {
elsif ( $d->_contain('Hexometer') ) {
$h = {
name => 'Hexometer',
is_bot => 1,
Expand Down
2 changes: 1 addition & 1 deletion lib/Duadua/Parser/Bot/Bytespider.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use Duadua::Util qw//;
sub try {
my ($class, $d) = @_;

if ( $d->contain('Bytespider;') && $d->contain('bytedance.com') ) {
if ( $d->_contain('Bytespider;') && $d->_contain('bytedance.com') ) {
my $h = {
name => 'Bytespider',
is_bot => 1,
Expand Down
2 changes: 1 addition & 1 deletion lib/Duadua/Parser/Bot/CentroAdsCrawler.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use Duadua::Util qw//;
sub try {
my ($class, $d) = @_;

if ( $d->prefix('Centro Ads.txt Crawler/') ) {
if ( $d->_prefix('Centro Ads.txt Crawler/') ) {
my $h = {
name => 'Centro Ads Crawler',
is_bot => 1,
Expand Down
6 changes: 3 additions & 3 deletions lib/Duadua/Parser/Bot/ChatGPTUser.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use warnings;
sub try {
my ($class, $d) = @_;

if ( $d->contain('ChatGPT-User/')
&& $d->contain('+https://openai.com/bot')
&& $d->contain_mozilla_top ) {
if ( $d->_contain('ChatGPT-User/')
&& $d->_contain('+https://openai.com/bot')
&& $d->_contain_mozilla_top ) {
my $h = _set_property($d, 'ChatGPT-User');

if ($d->opt_version) {
Expand Down
6 changes: 3 additions & 3 deletions lib/Duadua/Parser/Bot/ClaudeBot.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use warnings;
sub try {
my ($class, $d) = @_;

if ( $d->contain('ClaudeBot/')
&& $d->contain('[email protected]')
&& $d->contain_mozilla ) {
if ( $d->_contain('ClaudeBot/')
&& $d->_contain('[email protected]')
&& $d->_contain_mozilla ) {
my $h = {
name => 'ClaudeBot',
is_bot => 1,
Expand Down
2 changes: 1 addition & 1 deletion lib/Duadua/Parser/Bot/DuckDuckBot.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use Duadua::Util;
sub try {
my ($class, $d) = @_;

if ( $d->contain('DuckDuck') && $d->contain('://duckduckgo.com') ) {
if ( $d->_contain('DuckDuck') && $d->_contain('://duckduckgo.com') ) {
my $h = {
name => 'DuckDuckGo Bot',
is_bot => 1,
Expand Down
2 changes: 1 addition & 1 deletion lib/Duadua/Parser/Bot/FacebookCrawler.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use warnings;
sub try {
my ($class, $d) = @_;

if ( $d->contain('facebookexternalhit/') ) {
if ( $d->_contain('facebookexternalhit/') ) {
my $h = {
name => 'Facebook Crawler',
is_bot => 1,
Expand Down
2 changes: 1 addition & 1 deletion lib/Duadua/Parser/Bot/Fastladder.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use Duadua::Util qw//;
sub try {
my ($class, $d) = @_;

if ( $d->contain('Fastladder ') ) {
if ( $d->_contain('Fastladder ') ) {
my $h = {
name => 'Fastladder',
is_bot => 1,
Expand Down
2 changes: 1 addition & 1 deletion lib/Duadua/Parser/Bot/Feedbin.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use Duadua::Util qw//;
sub try {
my ($class, $d) = @_;

if ( $d->contain('Feedbin feed-id') ) {
if ( $d->_contain('Feedbin feed-id') ) {
return {
name => 'Feedbin',
is_bot => 1,
Expand Down
2 changes: 1 addition & 1 deletion lib/Duadua/Parser/Bot/Feedeen.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use warnings;
sub try {
my ($class, $d) = @_;

if ( $d->contain('Mozilla/5.0 Feedeen ') ) {
if ( $d->_contain('Mozilla/5.0 Feedeen ') ) {
return {
name => 'Feedeen',
is_bot => 1,
Expand Down
Loading

0 comments on commit 3c897e9

Please sign in to comment.