Sha256: 525a3d693665239e484cfbdf79098123b523cc09364b6d49e5439e84b341ccce

Contents?: true

Size: 977 Bytes

Versions: 1

Compression:

Stored size: 977 Bytes

Contents

require 'yaml'

module Gitx
  class Configuration
    CONFIG_FILE = '.gitx.yml'

    attr_reader :config

    def initialize(root_dir)
      @config = Thor::CoreExt::HashWithIndifferentAccess.new
      @config.merge!(load_config(File.join(__dir__, 'defaults.yml')))
      @config.merge!(load_config(File.join(root_dir, CONFIG_FILE)))
    end

    def aggregate_branches
      config[:aggregate_branches]
    end

    def aggregate_branch?(branch)
      aggregate_branches.include?(branch)
    end

    def reserved_branches
      config[:reserved_branches]
    end

    def reserved_branch?(branch)
      reserved_branches.include?(branch)
    end

    def taggable_branches
      config[:taggable_branches]
    end

    def taggable_branch?(branch)
      taggable_branches.include?(branch)
    end

    private

    # load configuration file
    def load_config(path)
      if File.exist?(path)
        ::YAML.load_file(path)
      else
        {}
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gitx-2.14.2.ci.70.1 lib/gitx/configuration.rb