Sha256: 8367800b7b1a594af051a1c8ead29fc37af8e8a47074a9ceab343c2fd8c24cdc

Contents?: true

Size: 701 Bytes

Versions: 4

Compression:

Stored size: 701 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

    private_attr_reader :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

4 entries across 4 versions & 1 rubygems

Version Path
signore-0.4.2 lib/signore/settings.rb
signore-0.4.1 lib/signore/settings.rb
signore-0.4.0 lib/signore/settings.rb
signore-0.3.3 lib/signore/settings.rb