Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support specifying the config file path in an environment variable #435

Merged
merged 1 commit into from
Nov 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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