Class: NexusResponse
- Inherits:
-
Object
- Object
- NexusResponse
- Defined in:
- lib/conan/application_helper.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
Returns the value of attribute code.
-
#json ⇒ Object
Returns the value of attribute json.
-
#raw_json ⇒ Object
Returns the value of attribute raw_json.
Instance Method Summary collapse
-
#initialize(code, raw_json) ⇒ NexusResponse
constructor
A new instance of NexusResponse.
Constructor Details
#initialize(code, raw_json) ⇒ NexusResponse
Returns a new instance of NexusResponse.
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/conan/application_helper.rb', line 90 def initialize(code, raw_json) @code = code begin @json = OpenStruct.new(JSON.parse(Zlib::GzipReader.new(StringIO.new(raw_json)).read)) @raw_json = Zlib::GzipReader.new(StringIO.new(raw_json)).read rescue Zlib::Error begin @json = OpenStruct.new(JSON.parse(raw_json)) @raw_json = raw_json rescue JSON::ParserError puts "NexusResponse - could not parse following JSON:\n#{raw_json}" @json = OpenStruct.new(JSON.parse("{ \"status\" : \"error\", \"errorMessage\" : \"Previous call likely returned a Stackato HTML error page\" }")) @raw_json = raw_json end rescue Zlib::GzipFile::Error begin @json = OpenStruct.new(JSON.parse(raw_json)) @raw_json = raw_json rescue JSON::ParserError puts "NexusResponse - could not parse following JSON:\n#{raw_json}" @json = OpenStruct.new(JSON.parse("{ \"status\" : \"error\", \"errorMessage\" : \"Previous call likely returned a Stackato HTML error page\" }")) @raw_json = raw_json end rescue JSON::ParserError puts "NexusResponse - could not parse following JSON:\n#{raw_json}" @json = OpenStruct.new(JSON.parse("{ \"status\" : \"error\", \"errorMessage\" : \"Previous call likely returned a Stackato HTML error page\" }")) @raw_json = raw_json end end |
Instance Attribute Details
#code ⇒ Object
Returns the value of attribute code.
86 87 88 |
# File 'lib/conan/application_helper.rb', line 86 def code @code end |
#json ⇒ Object
Returns the value of attribute json.
87 88 89 |
# File 'lib/conan/application_helper.rb', line 87 def json @json end |
#raw_json ⇒ Object
Returns the value of attribute raw_json.
88 89 90 |
# File 'lib/conan/application_helper.rb', line 88 def raw_json @raw_json end |