Commit 0550d9ea authored by Leo Gordon's avatar Leo Gordon
Browse files

A personal ~/.hive_config.json will be merged in by default (overriding system defaults)

parent f1202d7c
#!/usr/bin/env perl
package Bio::EnsEMBL::Hive::Utils::Config;
use JSON;
sub default_config_files { # a class method, returns a list
my $system_config = $ENV{'ENSEMBL_CVS_ROOT_DIR'}.'/ensembl-hive/hive_config.json';
my $user_config = $ENV{'HOME'}.'/.hive_config.json';
return ($system_config, (-r $user_config) ? ($user_config) : ());
}
sub new {
my $class = shift @_;
my $self = bless {}, $class;
$self->config_hash( {} );
foreach my $cfg_file (@_) {
foreach my $cfg_file ( scalar(@_) ? @_ : $self->default_config_files ) {
if(my $cfg_hash = $self->load_from_json($cfg_file)) {
$self->merge($cfg_hash);
}
......
......@@ -28,18 +28,16 @@ $Author: lg4 $
=head1 VERSION
$Revision: 1.13 $
$Revision: 1.14 $
=cut
use strict;
use warnings;
use Bio::EnsEMBL::Hive::Utils::GraphViz;
use Bio::EnsEMBL::Utils::Argument qw(rearrange);
use Bio::EnsEMBL::Utils::Exception qw(throw);
use Bio::EnsEMBL::Utils::Scalar qw(check_ref assert_ref);
use Bio::EnsEMBL::Hive::Utils::GraphViz;
use Bio::EnsEMBL::Hive::Utils::Config;
......@@ -57,10 +55,12 @@ use Bio::EnsEMBL::Hive::Utils::Config;
=cut
sub new {
my ($class, $dba, $config) = @_;
my ($class, $dba, $config_file) = @_;
my $self = bless({}, ref($class) || $class);
$self->dba($dba);
my $config = Bio::EnsEMBL::Hive::Utils::Config->new( $config_file ? $config_file : () );
$self->config($config);
return $self;
......
......@@ -11,7 +11,6 @@ use Pod::Usage;
use Bio::EnsEMBL::Hive::URLFactory;
use Bio::EnsEMBL::Hive::DBSQL::DBAdaptor;
use Bio::EnsEMBL::Hive::Utils::Graph;
use Bio::EnsEMBL::Hive::Utils::Config;
my $self = bless({}, __PACKAGE__);
......@@ -96,9 +95,7 @@ sub _process_options {
sub _write_graph {
my ($self) = @_;
my $config = Bio::EnsEMBL::Hive::Utils::Config->new( $ENV{'ENSEMBL_CVS_ROOT_DIR'}.'/ensembl-hive/hive_config.json' );
my $graph = Bio::EnsEMBL::Hive::Utils::Graph->new( $self->{dba}, $config );
my $graph = Bio::EnsEMBL::Hive::Utils::Graph->new( $self->{dba} );
my $graphviz = $graph->build();
my $call = q{as_}.$self->{format};
......@@ -207,7 +204,7 @@ $Author: lg4 $
=head1 VERSION
$Revision: 1.8 $
$Revision: 1.9 $
=head1 REQUIREMENTS
......
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