Skip to content
This repository has been archived by the owner on Mar 16, 2022. It is now read-only.

Use superclass defaults rather than relying on copied defaults. #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions lib/todotxt/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,23 @@ class Config < ParseConfig
def initialize(options = {})
@options = options

@config_file = options[:config_file] || Config.config_path
# Superclass will flunk if @config_file is set but not readable.
# But we need to be able to handle that situation. Hence we shadow
# the original @config_file and set it manually after initializing.
@try_config_file = options[:config_file] || Config.config_path

if file_exists?
super @config_file
validate
else
# Initialize mandatory values for `ParseConfig`
@params = {}
@groups = []
@splitRegex = '\s*=\s*'
@comments = [';']
super(nil)
end

@config_file = @try_config_file
end

def file_exists?
File.exist? @config_file
File.exists? @config_file || @try_config_file
end

def files
Expand Down