lib/clickatell/response.rb in clickatell-0.6.0 vs lib/clickatell/response.rb in clickatell-0.7.0
- old
+ new
@@ -13,10 +13,18 @@
return { 'OK' => 'session_id' } if API.test_mode
if http_response.body.scan(/ERR/).any?
raise Clickatell::API::Error.parse(http_response.body)
end
- YAML.load(http_response.body.scan(PARSE_REGEX).join("\n"))
+ results = http_response.body.split("\n").map do |line|
+ # YAML.load converts integer strings that have leading zeroes into integers
+ # using octal rather than decimal. This isn't what we want, so we'll strip out any
+ # leading zeroes in numbers here.
+ response_fields = line.scan(PARSE_REGEX)
+ response_fields = response_fields.collect { |field| field.gsub(/\b0+(\d+)\b/, '\1') }
+ YAML.load(response_fields.join("\n"))
+ end
+ results.length == 1 ? results.first : results
end
end
end
\ No newline at end of file