Skip to content

Commit

Permalink
simplified config file processing
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfiestyle committed Apr 12, 2012
1 parent 83333f0 commit ddace2b
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions rnd_ebooks.pl
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@
my $config = Config::Tiny->read("$ENV{HOME}/.rnd-ebooks")
or die("error reading config: " . Config::Tiny->errstr . "\n");

sub cfg_read { $config->{connect_params}->{$_[0]} or die("invalid config: missing $_[0]\n"); }

my $consumer_key = cfg_read('consumer_key');
my $consumer_secret = cfg_read('consumer_secret');
my $access_token_key = cfg_read('access_token_key');
my $access_token_secret = cfg_read('access_token_secret');
foreach (qw/consumer_key consumer_secret access_token_key access_token_secret/)
{
die("invalid config: missing $_\n") unless ($config->{connect_params}->{$_});
}

# pick a random pdf file
my @pdf_list = glob "$pdf_dir/*.pdf";
Expand Down Expand Up @@ -63,9 +61,9 @@
# tweet it
my $api = Net::Twitter->new(
traits => [qw/OAuth API::REST/],
consumer_key => $consumer_key,
consumer_secret => $consumer_secret,
access_token => $access_token_key,
access_token_secret => $access_token_secret,
consumer_key => $config->{connect_params}->{consumer_key},
consumer_secret => $config->{connect_params}->{consumer_secret},
access_token => $config->{connect_params}->{access_token_key},
access_token_secret => $config->{connect_params}->{access_token_secret},
);
$api->update($line_selected);

0 comments on commit ddace2b

Please sign in to comment.