Skip to content

Commit

Permalink
configuration files: support tilde expansion
Browse files Browse the repository at this point in the history
  • Loading branch information
igneus committed Jun 27, 2020
1 parent fe7736b commit d1ce4ed
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ and disabling colours:
--calendar=czech-cs # celebrations common for the whole Czech Republic
--calendar=czech-cechy-cs # Bohemia
--calendar=czech-praha-cs # archdiocese of Prague
--calendar=/home/igneus/calendar_data/local_church.txt # path to a custom calendar file with proper celebrations of the parish where I live (titular feast of the church, dedication)
--calendar=~/calendar_data/local_church.txt # path to a custom calendar file with proper celebrations of the parish where I live (titular feast of the church, dedication)

--no-color # disable colours
```
Expand Down
13 changes: 13 additions & 0 deletions features/configuration_file.feature
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,16 @@ Feature: Configuration file
And the stderr should contain "Error loading '"
And the stderr should contain ".calromrc': invalid option: --unknown-option"
And the stderr should not contain traceback

Scenario: tilde expansion in configuration file
Given a file named "~/calendar.txt" with:
"""
1/11 : St. None, abbot
"""
And a file named "~/.calromrc" with:
"""
--calendar=~/calendar.txt # path with tilde
"""
When I run `calrom 2000-01-11`
Then the exit status should be 0
And the output should contain "St. None, abbot, optional memorial"
6 changes: 4 additions & 2 deletions lib/calrom/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ def build_sanctorale
end

data = @sanctorale.collect do |s|
expanded = File.expand_path s

if s == '-'
CR::SanctoraleLoader.new.load_from_string STDIN.read
elsif File.file? s
CR::SanctoraleLoader.new.load_from_file s
elsif File.file? expanded
CR::SanctoraleLoader.new.load_from_file expanded
elsif CR::Data[s]
CR::Data[s].load
else
Expand Down

0 comments on commit d1ce4ed

Please sign in to comment.