Sha256: b187c4b27e13c4ae5a75179a2f3c78cae678bcc3f0a27d4f3c8f34b58068c2b3

Contents?: true

Size: 932 Bytes

Versions: 2

Compression:

Stored size: 932 Bytes

Contents

require 'thor'

module SearchKit
  class Events
    class CLI < Thor
      # An extraction of the CLI command, "all".
      #
      class Status
        include Messaging

        attr_reader :client, :id

        def initialize(client, id)
          @client = client
          @id     = id
        end

        def perform
          info "Event #{id} status: #{status}"
        rescue Errors::EventNotFound
          warning "No event found for #{id}"
        rescue Faraday::ConnectionFailed
          warning "Remote events service not found"
        rescue JSON::ParserError => error
          warning "Response unreadable: #{error}"
          error.backtrace.each(&method(:warning))
        end

        private

        def status
          response = client.show(id)

          response
            .fetch(:data, {})
            .fetch(:attributes, {})
            .fetch(:state, '')
        end

      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
search-kit-0.0.2 lib/search_kit/events/cli/status.rb
search-kit-0.0.1 lib/search_kit/events/cli/status.rb