Sha256: 383655e98dd13641156e18a1c4de6760ff6c8c929f00cf47744e49a1ad6e2bd4

Contents?: true

Size: 783 Bytes

Versions: 4

Compression:

Stored size: 783 Bytes

Contents

require 'yaml'
module GherkinLint
  # gherkin_lint configuration object
  class Configuration
    attr_reader :config

    def initialize(path)
      @path = path
      @config = load_configuration || ''
      load_user_configuration
    end

    def configuration_path
      @path
    end

    def load_configuration
      YAML.load_file configuration_path || '' if File.exist? configuration_path
    end

    def load_user_configuration
      config_file = Dir.glob(File.join(Dir.pwd, '**', '.gherkin_lint.yml')).first
      merge_config(config_file) if !config_file.nil? && File.exist?(config_file)
    end

    private

    def merge_config(config_file)
      @config.merge!(YAML.load_file(config_file)) { |_k, old, new| old.merge!(new) } unless @config.empty?
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gherkin_lint-1.2.2 lib/gherkin_lint/configuration.rb
gherkin_lint-1.2.1 lib/gherkin_lint/configuration.rb
gherkin_lint-1.1.0 lib/gherkin_lint/configuration.rb
gherkin_lint-1.0.0 lib/gherkin_lint/configuration.rb