Sha256: 961b4ecc5854b4f46c31ce30928f386b325eed21b4fe35f4063a6a2f8ec35314
Contents?: true
Size: 1.38 KB
Versions: 1
Compression:
Stored size: 1.38 KB
Contents
# frozen_string_literal: true require 'yaml' module BigFiles # Load configuration from files class ConfigFileParser attr_reader :project_config_filename def initialize(project_config_filename = '.bigfiles.yml', yaml_class: YAML, file_class: File) @project_config_filename = project_config_filename @yaml_class = yaml_class @file_class = file_class end def parse_config_files config = {} project_config = parse_project_config config.merge(project_config) end private def item(raw_project_config, section, key) raw_project_config.fetch('bigfiles', {}).fetch(section, {}).fetch(key, nil) end def top_item(raw_project_config, key) raw_project_config.fetch('bigfiles', {}).fetch(key, nil) end def parse_project_config return {} unless @file_class.file? project_config_filename project_config = {} raw_project_config = @yaml_class.load_file(project_config_filename) exclude = item(raw_project_config, 'exclude', 'glob') project_config[:exclude] = exclude unless exclude.nil? glob = item(raw_project_config, 'include', 'glob') project_config[:glob] = glob unless glob.nil? num_files = top_item(raw_project_config, 'num_files') project_config[:num_files] = num_files unless num_files.nil? project_config end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bigfiles-0.3.0 | lib/bigfiles/config_file_parser.rb |