Sha256: 5f389b550c0a648bae39ed2fa73e94f342f12f936ecfe6a84ef850c2299f2a4d

Contents?: true

Size: 668 Bytes

Versions: 2

Compression:

Stored size: 668 Bytes

Contents

# frozen_string_literal: true

require 'pathname'
require_relative 'tags'

module Signore
  class Settings
    def initialize(args = [])
      @args = args
    end

    def action
      args.first
    end

    # :reek:UtilityFunction
    def repo_path
      dir = ENV.fetch('XDG_DATA_HOME') { File.expand_path('~/.local/share') }
      Pathname.new("#{dir}/signore/signatures.yml")
    end

    def tags
      negated, required = tag_names.partition { |name| name.start_with?('~') }
      Tags.new(forbidden: negated.map { |neg| neg[1..-1] }, required: required)
    end

    private

    attr_reader :args

    def tag_names
      args[1..-1] or []
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
signore-0.6.0 lib/signore/settings.rb
signore-0.5.0 lib/signore/settings.rb