Class: ResultIO

Inherits:
Object
  • Object
show all
Defined in:
app/models/result_io.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeResultIO

Returns a new instance of ResultIO.



4
5
6
7
8
9
10
11
12
13
14
15
# File 'app/models/result_io.rb', line 4

def initialize
  @debugIO = StringIO.new
  @resultIO = StringIO.new
  @messageIO = StringIO.new
  @errorIO = StringIO.new
  @appInfoIO = StringIO.new
  @data = ""
  @exitcode = 0
  @cart_commands = []
  @cart_properties = {}
  @hasUserActionableError = false
end

Instance Attribute Details

#appInfoIOObject

Returns the value of attribute appInfoIO.



2
3
4
# File 'app/models/result_io.rb', line 2

def appInfoIO
  @appInfoIO
end

#cart_commandsObject

Returns the value of attribute cart_commands.



2
3
4
# File 'app/models/result_io.rb', line 2

def cart_commands
  @cart_commands
end

#cart_propertiesObject

Returns the value of attribute cart_properties.



2
3
4
# File 'app/models/result_io.rb', line 2

def cart_properties
  @cart_properties
end

#dataObject

Returns the value of attribute data.



2
3
4
# File 'app/models/result_io.rb', line 2

def data
  @data
end

#debugIOObject

Returns the value of attribute debugIO.



2
3
4
# File 'app/models/result_io.rb', line 2

def debugIO
  @debugIO
end

#errorIOObject

Returns the value of attribute errorIO.



2
3
4
# File 'app/models/result_io.rb', line 2

def errorIO
  @errorIO
end

#exitcodeObject

Returns the value of attribute exitcode.



2
3
4
# File 'app/models/result_io.rb', line 2

def exitcode
  @exitcode
end

#hasUserActionableErrorObject

Returns the value of attribute hasUserActionableError.



2
3
4
# File 'app/models/result_io.rb', line 2

def hasUserActionableError
  @hasUserActionableError
end

#messageIOObject

Returns the value of attribute messageIO.



2
3
4
# File 'app/models/result_io.rb', line 2

def messageIO
  @messageIO
end

#resultIOObject

Returns the value of attribute resultIO.



2
3
4
# File 'app/models/result_io.rb', line 2

def resultIO
  @resultIO
end

Instance Method Details

#append(resultIO) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/models/result_io.rb', line 17

def append(resultIO)
  self.debugIO << resultIO.debugIO.string
  self.resultIO << resultIO.resultIO.string
  self.messageIO << resultIO.messageIO.string
  self.errorIO << resultIO.errorIO.string
  self.appInfoIO << resultIO.appInfoIO.string
  self.cart_commands += resultIO.cart_commands
  self.cart_properties = resultIO.cart_properties.merge(self.cart_properties)
  self.exitcode = resultIO.exitcode
  self.data += resultIO.data

  if resultIO.exitcode != 0
    if resultIO.hasUserActionableError
      unless (!self.hasUserActionableError) && self.exitcode != 0
        self.hasUserActionableError = true
      end
    else
      self.hasUserActionableError = false
    end
  end

  self
end

#to_json(*args) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'app/models/result_io.rb', line 54

def to_json(*args)
  reply = LegacyReply.new
  reply.debug = @debugIO.string
  reply.messages = @messageIO.string
  if !@errorIO.string.empty?
    reply.result = @errorIO.string
  else
    reply.result = @resultIO.string
  end
  reply.data = @data
  reply.exit_code = @exitcode
  reply.to_json(*args)
end

#to_sObject



41
42
43
44
45
46
47
48
49
50
51
52
# File 'app/models/result_io.rb', line 41

def to_s
  str = "--DEBUG--\n#{@debugIO.string}\n" +
        "--RESULT--\n#{@resultIO.string}\n" +
        "--MESSAGE--\n#{@messageIO.string}\n" +
        "--ERROR--\n#{@errorIO.string}\n" +
        "--APP INFO--\n#{@appInfoIO.string}\n" +
        "--CART COMMANDS--\n#{@cart_commands.join("\n")}\n" +
        "--CART PROPERTIES--\n#{@cart_properties.inspect}\n" +
        "--DATA--\n#{@data}\n" +
        "--EXIT CODE--\n#{@exitcode}\n" +          
        "--USER ACTIONABLE--\n#{@hasUserActionableError}\n"
end