logo

ap-client

CLI-based client / toolbox for ActivityPub Client-to-Servergit clone https://hacktivis.me/git/ap-client.git
commit: ac0795804edb2c14e24ae96fc8b1ee89638756c7
parent fe7e0ff1ee4e3d4e2dc58b54b27f1f0f8fb0e66a
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Tue,  4 Apr 2023 17:45:49 +0200

Makefile.PL: Rename to App::ActivityPubClient

Diffstat:

MMakefile.PL2+-
Dlib/ActivityPub/PrettyPrint.pm66------------------------------------------------------------------
Alib/App/ActivityPubClient.pm66++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mscript/ap-fetch2+-
Mscript/ap-represent2+-
Mt/pleroma.t2+-
6 files changed, 70 insertions(+), 70 deletions(-)

diff --git a/Makefile.PL b/Makefile.PL @@ -7,7 +7,7 @@ use warnings; use ExtUtils::MakeMaker; WriteMakefile( - NAME => 'App::ApClient', + NAME => 'App::ActivityPubClient', ABSTRACT => 'CLI-based client / toolbox for ActivityPub Client-to-Server', AUTHOR => 'Haelwenn (lanodan) Monnier <contact+ap-client@hacktivis.me>', LICENSE => 'bsd', diff --git a/lib/ActivityPub/PrettyPrint.pm b/lib/ActivityPub/PrettyPrint.pm @@ -1,66 +0,0 @@ -#!/usr/bin/env perl -# AP-Client: CLI-based client / toolbox for ActivityPub -# Copyright © 2020-2023 AP-Client Authors <https://hacktivis.me/git/ap-client/> -# SPDX-License-Identifier: BSD-3-Clause -package ActivityPub::PrettyPrint; -our $VERSION = 'v0.1.1'; -use strict; -use utf8; -use open ":std", ":encoding(UTF-8)"; - -use Scalar::Util qw(reftype); - -use Exporter 'import'; - -our @EXPORT_OK = qw(print_object); - -sub print_object_key { - my ($indent, $object, $key) = @_; - - if ($object->{$key}) { - print_ref($indent, $object->{$key}, $key); - } -} - -sub print_object { - my ($indent, $object) = @_; - - my @regular_keys = - qw{url subtitleLanguage context inbox outbox prev next published updated summary content bcc bto cc to object attachment tag orderedItems mediaType}; - - printf "%*s %s", $indent, '⇒', $object->{"type"}; - printf ' id:<%s>', $object->{"id"} if $object->{"id"}; - printf ' href:<%s>', $object->{"href"} if $object->{"href"}; - printf ' “%s”', $object->{"name"} if $object->{"name"}; - printf ' @%s', $object->{"preferredUsername"} - if $object->{"preferredUsername"}; - printf ' ⚠' if ($object->{"sensitive"} eq JSON->true); - foreach (@regular_keys) { - print_object_key($indent, $object, $_); - } -} - -sub print_ref { - my ($indent, $object, $name) = @_; - - my $ref_type = reftype($object); - - if ($ref_type eq 'HASH') { - printf "\n%*s%s: \n", $indent, ' ', $name; - print_object($indent + 4, $object); - } elsif ($ref_type eq 'ARRAY') { - printf "\n%*s%s: ", $indent, ' ', $name if @{$object}; - foreach (@{$object}) { - if (reftype($_) eq 'HASH') { - print "\n"; - print_object($indent + 4, $_); - } else { - printf "%s ; ", $_; - } - } - } else { - printf "\n%*s%s: %s", $indent, ' ', $name, $object; - } -} - -1; diff --git a/lib/App/ActivityPubClient.pm b/lib/App/ActivityPubClient.pm @@ -0,0 +1,66 @@ +#!/usr/bin/env perl +# AP-Client: CLI-based client / toolbox for ActivityPub +# Copyright © 2020-2023 AP-Client Authors <https://hacktivis.me/git/ap-client/> +# SPDX-License-Identifier: BSD-3-Clause +package App::ActivityPubClient; +our $VERSION = 'v0.1.1'; +use strict; +use utf8; +use open ":std", ":encoding(UTF-8)"; + +use Scalar::Util qw(reftype); + +use Exporter 'import'; + +our @EXPORT_OK = qw(print_object); + +sub print_object_key { + my ($indent, $object, $key) = @_; + + if ($object->{$key}) { + print_ref($indent, $object->{$key}, $key); + } +} + +sub print_object { + my ($indent, $object) = @_; + + my @regular_keys = + qw{url subtitleLanguage context inbox outbox prev next published updated summary content bcc bto cc to object attachment tag orderedItems mediaType}; + + printf "%*s %s", $indent, '⇒', $object->{"type"}; + printf ' id:<%s>', $object->{"id"} if $object->{"id"}; + printf ' href:<%s>', $object->{"href"} if $object->{"href"}; + printf ' “%s”', $object->{"name"} if $object->{"name"}; + printf ' @%s', $object->{"preferredUsername"} + if $object->{"preferredUsername"}; + printf ' ⚠' if ($object->{"sensitive"} eq JSON->true); + foreach (@regular_keys) { + print_object_key($indent, $object, $_); + } +} + +sub print_ref { + my ($indent, $object, $name) = @_; + + my $ref_type = reftype($object); + + if ($ref_type eq 'HASH') { + printf "\n%*s%s: \n", $indent, ' ', $name; + print_object($indent + 4, $object); + } elsif ($ref_type eq 'ARRAY') { + printf "\n%*s%s: ", $indent, ' ', $name if @{$object}; + foreach (@{$object}) { + if (reftype($_) eq 'HASH') { + print "\n"; + print_object($indent + 4, $_); + } else { + printf "%s ; ", $_; + } + } + } else { + printf "\n%*s%s: %s", $indent, ' ', $name, $object; + } +} + +1; diff --git a/script/ap-fetch b/script/ap-fetch @@ -11,7 +11,7 @@ use Getopt::Std; use LWP::UserAgent; use HTTP::Request::Common; use JSON; -use ActivityPub::PrettyPrint qw(print_object); +use App::ActivityPubClient qw(print_object); =head1 NAME diff --git a/script/ap-represent b/script/ap-represent @@ -8,7 +8,7 @@ use open ":std", ":encoding(UTF-8)"; our $VERSION = 'v0.1.1'; use JSON; -use ActivityPub::PrettyPrint qw(print_object); +use App::ActivityPubClient qw(print_object); =head1 NAME diff --git a/t/pleroma.t b/t/pleroma.t @@ -10,7 +10,7 @@ use Test::More tests => 1; use Test::Output; use JSON; -use ActivityPub::PrettyPrint qw(print_object); +use App::ActivityPubClient qw(print_object); # Read whole files undef $/;