Sha256: a828e6034c9560e23ea490375b3251f13e6ce2acb6f882f35512b10f9f83ccd6

Contents?: true

Size: 768 Bytes

Versions: 1

Compression:

Stored size: 768 Bytes

Contents

require 'procto'
require_relative 'signature'
require_relative 'tags'

module Signore
  class SigFromStream
    include Procto.call

    def initialize(input, tags: Tags.new)
      @input = input
      @tags  = tags
    end

    def call
      Signature.new(author: params.author, source: params.source,
                    subject: params.subject, tags: tags.required,
                    text: params.text)
    end

    private

    attr_reader :input, :tags

    Params = Struct.new(:text, :author, :subject, :source)

    def get_param(param)
      puts "\n#{param}?"
      separator = param == :text ? "\n\n" : "\n"
      input.gets(separator).strip
    end

    def params
      @params ||= Params.new(*Params.members.map(&method(:get_param)))
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
signore-0.7.0 lib/signore/sig_from_stream.rb