Sha256: ac436d5cc9d43bd03a4080c5f1c322862a79095efd2d768eb1cd2a95c0c331a2
Contents?: true
Size: 1.18 KB
Versions: 3
Compression:
Stored size: 1.18 KB
Contents
# frozen_string_literal: true require 'yaml' module GFSM module Data class Configuration attr_reader :change_types def initialize(config_path) @change_types = [] configuration = YAML.load_file(config_path) configuration.each do |key, value| if key == "change_types" self.load_change_types(value) end end @change_types.sort_by! { |change_type| change_type.priority }.reverse! end def get_change_type_from_category(category) @change_types.find do |change_type| category.match(change_type.matcher) end end private def load_change_types(change_types_config) change_types_config.each do |key, value| if !value.include?("title") || !value.include?("matcher") || !value.include?("bump") raise "Change type has invalid configuration" end @change_types << GFSM::Data::ChangeType.new( /#{Regexp.quote(value["matcher"])}/i, value["title"], value["bump"].to_sym, value.include?("priority") ? value["priority"] : -100 ) end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
gfsm-0.1.4 | lib/data/configuration.rb |
gfsm-0.1.3 | lib/data/configuration.rb |
gfsm-0.1.2 | lib/data/configuration.rb |