App-SpreadRevolutionaryDate
view release on metacpan or search on metacpan
lib/App/SpreadRevolutionaryDate/MsgMaker/PromptUser.pm view on Meta::CPAN
#
# This file is part of App-SpreadRevolutionaryDate
#
# This software is Copyright (c) 2019-2026 by Gérald Sédrati.
#
# This is free software, licensed under:
#
# The GNU General Public License, Version 3, June 2007
#
use 5.014;
use utf8;
package App::SpreadRevolutionaryDate::MsgMaker::PromptUser;
$App::SpreadRevolutionaryDate::MsgMaker::PromptUser::VERSION = '0.54';
# ABSTRACT: MsgMaker class for L<App::SpreadRevolutionaryDate> to build message by prompting user
use Moose;
with 'App::SpreadRevolutionaryDate::MsgMaker';
use open qw(:std :encoding(UTF-8));
use IO::Prompt::Hooked;
use File::Spec;
use File::Basename;
use File::Temp qw/tempfile/;
use LWP::UserAgent;
use Locale::TextDomain 'App-SpreadRevolutionaryDate';
use namespace::autoclean;
has 'default' => (
is => 'ro',
isa => 'Str',
required => 1,
default => 'Goodbye old world, hello revolutionary worlds',
);
has 'img_path' => (
is => 'rw',
isa => 'Maybe[Str]',
default => '',
);
has 'img_alt' => (
is => 'rw',
isa => 'Maybe[Str]',
default => '',
);
has 'img_url' => (
is => 'rw',
isa => 'Maybe[Str]',
default => '',
);
around BUILDARGS => sub {
my ($orig, $class, %args) = @_;
if ($args{locale}) {
# Get sure locale has .mo file
my ($volume, $directory, $file) = File::Spec->splitpath(__FILE__);
my $locale_mo = File::Spec->catfile($directory, '..', '..', '..', 'LocaleData', $args{locale}, 'LC_MESSAGES', 'App-SpreadRevolutionaryDate.mo');
$args{locale} = 'en' unless -f $locale_mo;
}
# Do not pass default => undef to force default in attribute definition
delete $args{default}
if exists $args{default} && !defined $args{default};
return $class->$orig(%args);
};
sub compute {
my $self = shift;
my $question = __"Please, enter message to spread";
#TRANSLATORS: initial used in case insensitive context
my $confirm_ok = lc(substr(__("yes"), 0, 1));
#TRANSLATORS: initial used case insensitive context
my $confirm_nok = lc(substr(__("no"), 0, 1));
#TRANSLATORS: initial used in case sensitive context
my $confirm_abort = substr(__("Abort"), 0, 1);
my $confirm_abort_text = __x("or {abort} to abort", abort => $confirm_abort);
my $confirm_intro = __"Spread";
my $confirm_question = __x("confirm ({confirm_ok}/{confirm_nok} {confirm_abort_text})?", confirm_ok => $confirm_ok, confirm_nok => $confirm_nok, confirm_abort_text => $confirm_abort_text);
my $confirm_error = __x("Input must be \"{confirm_ok}\" or \"{confirm_nok}\"\n", confirm_ok => $confirm_ok, confirm_nok => $confirm_nok);
my $abort = __"OK not spreading";
if ($self->img_path) {
( run in 1.176 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )