Sha256: 03c759cd35e8722adab245bc2d01ff4b7bd83de1969b00911df769953e782ca8

Contents?: true

Size: 719 Bytes

Versions: 3

Compression:

Stored size: 719 Bytes

Contents

require 'pathname'
require_relative 'tags'

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

    def action
      args.first
    end

    def db_path
      db_dir = ENV.fetch('XDG_DATA_HOME') { File.expand_path('~/.local/share') }
      Pathname.new("#{db_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

3 entries across 3 versions & 1 rubygems

Version Path
signore-0.3.1 lib/signore/settings.rb
signore-0.3.0 lib/signore/settings.rb
signore-0.2.4 lib/signore/settings.rb