diff --git a/Gemfile.lock b/Gemfile.lock index bdde65e..2442a3f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - gitea-client (0.5.0) + gitea-client (0.6.0) rest-client (~> 2.1.0) GEM diff --git a/lib/gitea/api/exception.rb b/lib/gitea/api/exception.rb index caaac5f..633c30a 100644 --- a/lib/gitea/api/exception.rb +++ b/lib/gitea/api/exception.rb @@ -1,3 +1,4 @@ +require "json" module Gitea module Api class ServerError < Common::Exception @@ -5,11 +6,11 @@ module Gitea def initialize(response) @http_code = response.code - - puts response + @attrs = JSON.parse(response.body) rescue {} end def to_s + @attrs.delete('documentation_url') @attrs.merge({'HTTPCode' => @http_code}).map do |k, v| [k, v].join(": ") end.join(", ") diff --git a/lib/gitea/api/http.rb b/lib/gitea/api/http.rb index 194a5e6..4617bce 100644 --- a/lib/gitea/api/http.rb +++ b/lib/gitea/api/http.rb @@ -1,4 +1,5 @@ require 'base64' +require 'json' module Gitea module Api @@ -99,7 +100,7 @@ module Gitea response.return! end - response + JSON.parse(response) end def get_user_agent diff --git a/lib/gitea/version.rb b/lib/gitea/version.rb index 6e4cb40..68224dc 100644 --- a/lib/gitea/version.rb +++ b/lib/gitea/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Gitea - VERSION = "0.5.0" + VERSION = "0.6.0" end