diff --git a/README.md b/README.md index ac51e09e..4ba7368d 100644 --- a/README.md +++ b/README.md @@ -261,7 +261,14 @@ $ PRONTO_BITBUCKET_USERNAME=user PRONTO_BITBUCKET_PASSWORD=pass pronto run -f bi ## Configuration The behavior of Pronto can be controlled via the `.pronto.yml` configuration -file. It must be placed in your project directory. +file. It can either be placed in the working directory (*) or specified using +the environment variable `PRONTO_CONFIG_FILE`. + +(*) The working directory is where you run the command from, which is typically +your project directory. + +If this file cannot be found, then the default configuration in +[Pronto::ConfigFile::EMPTY](lib/pronto/config_file.rb) applies. The file has the following format: diff --git a/lib/pronto/config_file.rb b/lib/pronto/config_file.rb index c1c682e7..21d41e29 100644 --- a/lib/pronto/config_file.rb +++ b/lib/pronto/config_file.rb @@ -40,7 +40,9 @@ class ConfigFile 'format' => DEFAULT_MESSAGE_FORMAT }.freeze - def initialize(path = '.pronto.yml') + attr_reader :path + + def initialize(path = ENV.fetch('PRONTO_CONFIG_FILE', '.pronto.yml')) @path = path end diff --git a/spec/pronto/config_file_spec.rb b/spec/pronto/config_file_spec.rb index 906ae0a9..8f8233f5 100644 --- a/spec/pronto/config_file_spec.rb +++ b/spec/pronto/config_file_spec.rb @@ -2,6 +2,22 @@ module Pronto describe ConfigFile do let(:config_file) { described_class.new } + describe '#path' do + subject { config_file.path } + + it { should eq '.pronto.yml' } + + context 'when specified by the environment variable' do + let(:file_path) { '/etc/pronto-config.yml' } + + before do + stub_const('ENV', 'PRONTO_CONFIG_FILE' => file_path) + end + + it { should eq file_path } + end + end + describe '#to_h' do subject { config_file.to_h }