A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://rubydoc.info/github/piotrmurach/github/master/Github/Response below:

Response – Documentation for piotrmurach/github (master) – RubyDoc.info

Class: Github::Response
Inherits:
Faraday::Response::Middleware show all
Defined in:
lib/github_api/response.rb,
lib/github_api/response/header.rb
Overview

Contains methods and attributes that act on the response returned from the request

Defined Under Namespace

Classes: AtomParser, FollowRedirects, Header, Jsonize, Mashify, RaiseError, Xmlize

Constant Summary collapse
CONTENT_TYPE =
'Content-Type'.freeze
Class Attribute Summary collapse Class Method Summary collapse Instance Method Summary collapse Constructor Details #initialize(app, options = {}) ⇒ Response

Returns a new instance of Response.

19
20
21
22
# File 'lib/github_api/response.rb', line 19

def initialize(app, options = {})
  super(app)
  @content_types = Array(options[:content_type])
end
Class Attribute Details .parser ⇒ Object

Returns the value of attribute parser.

12
13
14
# File 'lib/github_api/response.rb', line 12

def parser
  @parser
end
Class Method Details .define_parser(&block) ⇒ Object
15
16
17
# File 'lib/github_api/response.rb', line 15

def self.define_parser(&block)
  @parser = block
end
Instance Method Details #parse_body?(env) ⇒ Boolean
28
29
30
# File 'lib/github_api/response.rb', line 28

def parse_body?(env)
  parse_response_type?(response_type(env)) and parse_response?(env)
end
#parse_response?(env) ⇒ Boolean
44
45
46
# File 'lib/github_api/response.rb', line 44

def parse_response?(env)
  env[:body].respond_to?(:to_str)
end
#parse_response_type?(type) ⇒ Boolean
38
39
40
41
42
# File 'lib/github_api/response.rb', line 38

def parse_response_type?(type)
  @content_types.empty? || @content_types.any? { |pattern|
    pattern.is_a?(Regexp) ? type =~ pattern : type == pattern
  }
end
#process_body(env) ⇒ Object
24
25
26
# File 'lib/github_api/response.rb', line 24

def process_body(env)
  env[:body] = parse(env[:body])
end
#response_type(env) ⇒ Object
32
33
34
35
36
# File 'lib/github_api/response.rb', line 32

def response_type(env)
  type = env[:response_headers][CONTENT_TYPE].to_s
  type = type.split(';', 2).first if type.index(';')
  type
end

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4