| 1 | package Finance::CoinbasePro::API::CLI::Util::Config; | ||
| 2 | use strict; | ||
| 3 | |||
| 4 | use File::HomeDir; # my $home = File::HomeDir->my_home; | ||
| 5 | use File::Spec::Functions qw(catfile); | ||
| 6 | use Config::INI::Reader; | ||
| 7 | use List::Util qw(first); | ||
| 8 | |||
| 9 | use base qw(Exporter); | ||
| 10 | our @EXPORT_OK = qw( get_config_filename get_config ); | ||
| 11 | |||
| 12 | sub get_config_filename { | ||
| 13 | my $user_config = catfile( File::HomeDir->my_home(), ".coinbasepro" ); | ||
| 14 | my $etc_config = catfile( "/etc/", ".coinbasepro" ); | ||
| 15 | my $config = first { -f $_ } ( $user_config, $etc_config ); | ||
| 16 | } | ||
| 17 | |||
| 18 | sub get_config { | ||
| 19 | my $filename = shift; | ||
| 20 | my $config_hash = Config::INI::Reader->read_file( $filename ); | ||
| 21 | return $config_hash; | ||
| 22 | } | ||
| 23 | |||
| 24 | 1; | ||
| 25 | |||
| 26 | |||
| 27 | |||
| 28 | |||
| 29 | #################### pod generated by Pod::Autopod - keep this line to make pod updates possible #################### | ||
| 30 | |||
| 31 | =head1 NAME | ||
| 32 | |||
| 33 | Finance::CoinbasePro::API::CLI::Util::Config | ||
| 34 | |||
| 35 | |||
| 36 | =head1 DESCRIPTION | ||
| 37 | |||
| 38 | pod generated by Pod::Autopod - keep this line to make pod updates possible #################### | ||
| 39 | |||
| 40 | |||
| 41 | =head1 REQUIRES | ||
| 42 | |||
| 43 | L<List::Util> | ||
| 44 | |||
| 45 | L<Config::INI::Reader> | ||
| 46 | |||
| 47 | L<File::Spec::Functions> | ||
| 48 | |||
| 49 | L<File::HomeDir> my $home = File::HomeDir->my_home; | ||
| 50 | |||
| 51 | |||
| 52 | =head1 IMPLEMENTS | ||
| 53 | |||
| 54 | L<Exporter> | ||
| 55 | |||
| 56 | |||
| 57 | =head1 METHODS | ||
| 58 | |||
| 59 | =head2 get_config | ||
| 60 | |||
| 61 | $self->get_config(); | ||
| 62 | |||
| 63 | =head2 get_config_filename | ||
| 64 | |||
| 65 | $self->get_config_filename(); | ||
| 66 | |||
| 67 | =cut | ||
| 68 |