From 6fb81f9a1055a50a04818371efe8143d3fc1ab04 Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Thu, 18 Jun 2015 20:07:38 +0300 Subject: [PATCH] Rename init to dbinit and export it --- lib/Gruntmaster/App.pm | 2 +- lib/Gruntmaster/Data.pm | 4 ++-- t/Gruntmaster-Data.t | 2 +- t/tools.t | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/Gruntmaster/App.pm b/lib/Gruntmaster/App.pm index f61d145..f206928 100644 --- a/lib/Gruntmaster/App.pm +++ b/lib/Gruntmaster/App.pm @@ -21,7 +21,7 @@ sub global_opt_spec { sub table { shift->global_options->{table} } -Gruntmaster::Data::init $ENV{GRUNTMASTER_DSN} // 'dbi:Pg:'; +dbinit $ENV{GRUNTMASTER_DSN} // 'dbi:Pg:'; 1; __END__ diff --git a/lib/Gruntmaster/Data.pm b/lib/Gruntmaster/Data.pm index 1558e46..bcc0085 100644 --- a/lib/Gruntmaster/Data.pm +++ b/lib/Gruntmaster/Data.pm @@ -4,7 +4,7 @@ use warnings; use parent qw/Exporter/; our $VERSION = '5999.000_013'; -our @EXPORT = qw/purge db user_list user_entry problem_list problem_entry contest_list contest_entry contest_has_problem job_list job_entry create_job standings update_status rerun_job take_job finish_job/; ## no critic (ProhibitAutomaticExportation) +our @EXPORT = qw/dbinit purge db user_list user_entry problem_list problem_entry contest_list contest_entry contest_has_problem job_list job_entry create_job standings update_status rerun_job take_job finish_job/; ## no critic (ProhibitAutomaticExportation) use JSON::MaybeXS qw/decode_json/; use HTTP::Tiny; @@ -42,7 +42,7 @@ my %statements = ( our $db; sub db () { $db } -sub init { +sub dbinit { $db = DBIx::Simple->new(@_); $db->keep_statements = 100; }; diff --git a/t/Gruntmaster-Data.t b/t/Gruntmaster-Data.t index 6d381ea..ff39701 100644 --- a/t/Gruntmaster-Data.t +++ b/t/Gruntmaster-Data.t @@ -8,7 +8,7 @@ use Test::More; BEGIN { eval { - Gruntmaster::Data::init 'dbi:Pg:dbname=gmtest'; 1; + dbinit 'dbi:Pg:dbname=gmtest'; 1; } or plan skip_all => 'Cannot connect to test database. Create it by running createdb gmtest before running this test. '. "Error: $@"; plan tests => 33; } diff --git a/t/tools.t b/t/tools.t index f871ad0..59ed755 100644 --- a/t/tools.t +++ b/t/tools.t @@ -8,7 +8,7 @@ use App::Cmd::Tester; BEGIN { eval { - Gruntmaster::Data::init 'dbi:Pg:dbname=gmtest'; 1; + dbinit 'dbi:Pg:dbname=gmtest'; 1; } or plan skip_all => 'Cannot connect to test database. Create it by running make_test_db.sh before running this test. '. "Error: $@"; plan tests => 30; } -- 2.39.2