lib/dsu/support/configuration.rb in dsu-0.1.0.alpha.1 vs lib/dsu/support/configuration.rb in dsu-0.1.0.alpha.2

- old
+ new

@@ -20,11 +20,11 @@ DEFAULT_DSU_OPTIONS = { # The order by which entries should be displayed by default: # asc or desc, ascending or descending, respectively. 'entries_display_order' => 'desc', 'entries_file_name' => '%Y-%m-%d.json', - 'entries_folder' => "#{FolderLocations.root_folder}/dsu/entries", + 'entries_folder' => "#{FolderLocations.root_folder}/dsu/entries" }.freeze # rubocop:enable Style/StringHashKeys def config_file File.join(root_folder, CONFIG_FILENAME) @@ -41,16 +41,22 @@ def delete_config_file! delete_config_file config_file: config_file end + # TODO: Move this to a view (e.g. views/configuration/show.rb) def print_config_file if config_file? say "Config file (#{config_file}) contents:", SUCCESS hash = YAML.safe_load(File.open(config_file)) say hash.to_yaml.gsub("\n-", "\n\n-"), SUCCESS else say "Config file (#{config_file}) does not exist.", WARNING + say '' + say 'The default configuration is being used:' + DEFAULT_DSU_OPTIONS.each_with_index do |config_entry, index| + say "#{index + 1}. #{config_entry[0]}: '#{config_entry[1]}'" + end end end private