From: Dylan William Hardison Date: Wed, 10 Apr 2019 15:48:37 +0000 (-0400) Subject: no bug - allow changing the doctype X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e60e0f473b359c856093447c355a21e39a25abc7;p=thirdparty%2Fbugzilla.git no bug - allow changing the doctype --- diff --git a/Bugzilla/App/Command/report_ping.pm b/Bugzilla/App/Command/report_ping.pm index ca3277955..c423bf384 100644 --- a/Bugzilla/App/Command/report_ping.pm +++ b/Bugzilla/App/Command/report_ping.pm @@ -9,12 +9,13 @@ package Bugzilla::App::Command::report_ping; ## no critic (Capitalization) use Mojo::Base 'Mojolicious::Command'; use Bugzilla::Constants; -use JSON::MaybeXS; use Cwd qw(cwd); +use JSON::MaybeXS; +use Module::Runtime 'require_module'; use Mojo::File 'path'; use Mojo::Util 'getopt'; use PerlX::Maybe 'maybe'; -use Module::Runtime 'require_module'; +use Try::Tiny; has description => 'send a report ping to a url'; has usage => sub { shift->extract_usage }; @@ -23,9 +24,9 @@ sub run { my ($self, @args) = @_; my $json = JSON::MaybeXS->new(convert_blessed => 1, canonical => 1, pretty => 1); - my $report_type = 'Simple'; + my $class = 'Simple'; my $working_dir = cwd(); - my ($namespace, $page, $rows, $base_url, $test, $dump_schema, $dump_documents); + my ($namespace, $doctype, $page, $rows, $base_url, $test, $dump_schema, $dump_documents); Bugzilla->usage_mode(USAGE_MODE_CMDLINE); getopt \@args, @@ -34,22 +35,35 @@ sub run { 'rows|r=i' => \$rows, 'dump-schema' => \$dump_schema, 'dump-documents' => \$dump_documents, - 'report-type=s' => \$report_type, - 'namespace|ns=s' => \$namespace, + 'class|c=s' => \$class, + 'namespace|n=s' => \$namespace, + 'doctype|d=s' => \$doctype, 'workdir|C=s' => \$working_dir, 'test' => \$test; $base_url = 'http://localhost' if $dump_schema || $dump_documents || $test; die $self->usage unless $base_url; - my $report_class = "Bugzilla::Report::Ping::$report_type"; - require_module($report_class); - my $report = $report_class->new( + unless ($class =~ /::/) { + $class = "Bugzilla::Report::Ping::$class"; + } + try { + require_module($class); + } + catch { + say "Failed to load $class."; + unless ($_ =~ /^Can't locate \S+ in \@INC/) { + say "Error: $_"; + } + exit 1; + }; + my $report = $class->new( model => Bugzilla->dbh->model, base_url => $base_url, maybe rows => $rows, maybe page => $page, maybe namespace => $namespace, + maybe doctype => $doctype, ); if ($dump_schema) { @@ -126,7 +140,7 @@ Bugzilla::App::Command::report_ping - descriptionsend a report ping to a url'; -u, --base-url URL to send the json documents to. -r, --rows num (Optional) Number of requests to send at once. Default: 10. -p, --page num (Optional) Page to start on. Default: 1 - --report-type word (Optional) Report class to use. Default: Simple + --class word (Optional) Report class to use. Default: Simple --test Validate the json documents against the json schema. --dump-schema Print the json schema. diff --git a/Bugzilla/Report/Ping.pm b/Bugzilla/Report/Ping.pm index 7cecb961d..8ea553e08 100644 --- a/Bugzilla/Report/Ping.pm +++ b/Bugzilla/Report/Ping.pm @@ -74,7 +74,7 @@ sub _build_namespace { return 'bugzilla'; } -has 'doctype' => (is => 'lazy', init_arg => undef, isa => Str); +has 'doctype' => (is => 'lazy', isa => Str); sub _build_doctype { my ($self) = @_; diff --git a/Bugzilla/Report/Ping/Simple.pm b/Bugzilla/Report/Ping/Simple.pm index eac6ba009..d63553c7c 100644 --- a/Bugzilla/Report/Ping/Simple.pm +++ b/Bugzilla/Report/Ping/Simple.pm @@ -53,7 +53,6 @@ sub _build_validator { schema => Mojo::JSON::Pointer->new($schema->compile)); } - sub _build_resultset { my ($self) = @_; my $bugs = $self->model->resultset('Bug');