Class: SearchKit::CLI::Events
Instance Method Summary collapse
- #complete(id) ⇒ Object
- #pending(channel = nil) ⇒ Object
- #publish(channel, payload) ⇒ Object
- #status(id) ⇒ Object
Methods inherited from Thor
Instance Method Details
#complete(id) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/search_kit/cli/events.rb', line 22 def complete(id) client.complete(id) .info I18n.t('cli.events.complete.success', id: id) rescue Errors::EventNotFound .not_found rescue Faraday::ConnectionFailed .no_service end |
#pending(channel = nil) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/search_kit/cli/events.rb', line 32 def pending(channel = nil) events = channel ? client.pending(channel) : client.index = %w(cli events pending success) << (channel ? 'filtered' : 'index') << (events.any? ? 'discovered' : 'empty') = I18n.t(.join('.'), channel: channel) .info() events.each { |event| .info(event.to_json) } rescue Errors::BadRequest .bad_request rescue Errors:: . rescue Errors::Unprocessable .unprocessable rescue Faraday::ConnectionFailed .no_service end |
#publish(channel, payload) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/search_kit/cli/events.rb', line 53 def publish(channel, payload) payload = JSON.parse(payload, symbolize_names: true) event = client.publish(channel, payload) = I18n.t('cli.events.publish.success', channel: channel, id: event.id ) .info() rescue Errors::BadRequest .bad_request rescue Errors:: . rescue Errors::Unprocessable .unprocessable rescue Faraday::ConnectionFailed .no_service rescue JSON::ParserError .json_parse_error end |
#status(id) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/search_kit/cli/events.rb', line 76 def status(id) event = client.show(id) status = event.state = I18n.t('cli.events.status.success', id: id, status: status) .info() rescue Errors::EventNotFound .not_found rescue Faraday::ConnectionFailed .no_service end |