Skip to content

Commit

Permalink
Support specifying the config file path in ENV
Browse files Browse the repository at this point in the history
  • Loading branch information
hosamaly committed Oct 21, 2022
1 parent 839c56c commit ca5d0a1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
4 changes: 3 additions & 1 deletion lib/pronto/config_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 16 additions & 0 deletions spec/pronto/config_file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down

0 comments on commit ca5d0a1

Please sign in to comment.