Sha256: 6808000f248ffade88479bc715d26e4cad839845124368719eee3a6b77772e79

Contents?: true

Size: 1.02 KB

Versions: 21

Compression:

Stored size: 1.02 KB

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

    def after_release_scripts
      config[:after_release]
    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

21 entries across 21 versions & 1 rubygems

Version Path
gitx-2.20.0 lib/gitx/configuration.rb
gitx-2.20.0.ci.117.1 lib/gitx/configuration.rb
gitx-2.19.0.ci.114.1 lib/gitx/configuration.rb
gitx-2.19.0.ci.112.1 lib/gitx/configuration.rb
gitx-2.19.0 lib/gitx/configuration.rb
gitx-2.18.0.ci.106.1 lib/gitx/configuration.rb
gitx-2.18.0 lib/gitx/configuration.rb
gitx-2.18.0.pre.ci.104.1 lib/gitx/configuration.rb
gitx-2.18.0.pre lib/gitx/configuration.rb
gitx-2.17.0.pre.ci.101.1 lib/gitx/configuration.rb
gitx-2.17.0.pre lib/gitx/configuration.rb
gitx-2.17.0.pre.ci.98.1 lib/gitx/configuration.rb
gitx-2.16.0.ci.91.1 lib/gitx/configuration.rb
gitx-2.16.0 lib/gitx/configuration.rb
gitx-2.16.0.ci.89.1 lib/gitx/configuration.rb
gitx-2.16.0.pre.ci.88.1 lib/gitx/configuration.rb
gitx-2.16.0.pre.ci.85.1 lib/gitx/configuration.rb
gitx-2.16.0.pre lib/gitx/configuration.rb
gitx-2.16.0.pre.ci.81.1 lib/gitx/configuration.rb
gitx-2.15.0 lib/gitx/configuration.rb