Skip to content
This repository has been archived by the owner on May 10, 2018. It is now read-only.

fix for https://github.com/splunk/splunk-sdk-ruby/issues/28 #44

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion lib/splunk-sdk-ruby/resultsreader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,14 @@ def initialize()
@concatenate = false
@is_preview = nil
@state = :base
@msg_type = nil
@states = {
# Toplevel state.
:base => {
:start_element => lambda do |name, attributes|
if name == "results"
if name == "response"
@state = :response
elsif name == "results"
if !@concatenate
@is_preview = attributes["preview"] == "1"
Fiber.yield(@is_preview)
Expand Down Expand Up @@ -314,6 +317,29 @@ def initialize()
end
end
},
:response => {
:start_element => lambda do |name, attributes|
if name == 'messages'
@state = :response_messages
end
end,
},
:response_messages => {
:start_element => lambda do |name, attributes|
if name == "msg"
case attributes['type']
when 'ERROR', 'FATAL'
@state = :response_messages_msg
@msg_type = attributes['type']
end
end
end,
},
:response_messages_msg => {
:characters => lambda do |text|
raise "#{@msg_type}: #{text}"
end,
},
# Inside a `fieldOrder` element. Recognizes only
# the `field` element, and returns to the `:base` state
# when it encounters `</fieldOrder>`.
Expand Down