Sha256: c42740c8d8857017cbd1f43f9ee7552c1e648aae82403e3b3a6ac9fe3f8658e5

Contents?: true

Size: 715 Bytes

Versions: 1

Compression:

Stored size: 715 Bytes

Contents

require 'pathname'
require_relative 'tags'

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

    def action
      args.first
    end

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

    def tags
      Tags.new(forbidden: forbidden, required: required)
    end

    attr_reader :args
    private     :args

    private

    def forbidden
      tag_names.select { |tag| tag.start_with?('~') }.map { |tag| tag[1..-1] }
    end

    def required
      tag_names.reject { |tag| tag.start_with?('~') }
    end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
signore-0.3.2 lib/signore/settings.rb