Commit ecc6e196 authored by Matthieu Muffato's avatar Matthieu Muffato
Browse files

Factored out stringify_if_needed

lib/version_check.pm is not the best place, but it is loaded in every
script, and I didn't want to create a new module with just one function.
parent e9753a50
......@@ -28,7 +28,6 @@ use Bio::EnsEMBL::Hive::DBSQL::DBAdaptor;
use JSON;
use HTML::Template;
use Data::Dumper;
use lib ("./lib");
use hive_extended;
......@@ -243,18 +242,6 @@ sub template_mappings_PARAMS {
return [$vals];
}
sub stringify_if_needed {
my ($scalar) = @_;
if ((ref $scalar) or ($scalar =~ /^\[.*\]$/) or ($scalar =~ /^{.*}$/)) {
local $Data::Dumper::Indent = 0; # we want everything on one line
local $Data::Dumper::Terse = 1; # and we want it without dummy variable names
local $Data::Dumper::Sortkeys = 1; # make stringification more deterministic
return Dumper($scalar);
}
return $scalar;
}
## build_values creates a range of values given its input
## The input is a hashref where the keys are the steps
## and the values are arrayrefs with the first and final values of that range
......
......@@ -28,7 +28,6 @@ use Bio::EnsEMBL::Hive::DBSQL::DBAdaptor;
use JSON;
use HTML::Template;
use Data::Dumper;
use lib ("./lib");
use msg;
......@@ -235,15 +234,3 @@ sub get_final_clause {
return "ORDER BY $order_by $dir LIMIT $iDisplayLength OFFSET $iDisplayStart"
}
## TODO: There is more than 1 instance of this sub in the scripts. Factor out
sub stringify_if_needed {
my ($scalar) = @_;
if (ref $scalar) {
local $Data::Dumper::Indent = 0; # we want everything on one line
local $Data::Dumper::Terse = 1; # and we want it without dummy variable names
local $Data::Dumper::Sortkeys = 1; # make stringification more deterministic
return Dumper($scalar);
}
return $scalar;
}
......@@ -28,7 +28,6 @@ use Bio::EnsEMBL::Hive::DBSQL::DBAdaptor;
use JSON;
use HTML::Template;
use Data::Dumper;
use lib ("./lib");
use hive_extended;
......@@ -87,16 +86,4 @@ sub template_mappings_PARAMS {
return { 'existing_parameters' => \@existing_parameters };
}
sub stringify_if_needed {
my ($scalar) = @_;
if (ref $scalar) {
local $Data::Dumper::Indent = 0; # we want everything on one line
local $Data::Dumper::Terse = 1; # and we want it without dummy variable names
local $Data::Dumper::Sortkeys = 1; # make stringification more deterministic
return Dumper($scalar);
}
return $scalar;
}
......@@ -23,7 +23,10 @@ package version_check;
use strict;
use warnings;
use Data::Dumper;
use JSON;
use Bio::EnsEMBL::Hive::HivePipeline;
use Bio::EnsEMBL::Hive::DBSQL::SqlSchemaAdaptor;
......@@ -32,7 +35,19 @@ use msg;
use vars qw(@ISA @EXPORT);
@ISA = qw(Exporter);
@EXPORT = qw(get_hive_code_version check_db_versions_match);
@EXPORT = qw(stringify_if_needed get_hive_code_version check_db_versions_match);
# Doesn't fit well in this module. Should be in a more general one
sub stringify_if_needed {
my ($scalar) = @_;
if ((ref $scalar) or ($scalar =~ /^\[.*\]$/) or ($scalar =~ /^{.*}$/)) {
local $Data::Dumper::Indent = 0; # we want everything on one line
local $Data::Dumper::Terse = 1; # and we want it without dummy variable names
local $Data::Dumper::Sortkeys = 1; # make stringification more deterministic
return Dumper($scalar);
}
return $scalar;
}
sub get_hive_code_version {
return Bio::EnsEMBL::Hive::DBSQL::SqlSchemaAdaptor->get_code_sql_schema_version();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment