Class: Gitloggl::Connection
- Inherits:
-
Object
- Object
- Gitloggl::Connection
- Defined in:
- lib/gitloggl/connection.rb
Constant Summary collapse
- USER_AGENT =
'Gitloggl bot'
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#verbose ⇒ Object
readonly
Returns the value of attribute verbose.
Instance Method Summary collapse
- #default_headers ⇒ Object
-
#initialize(url, headers: {}, verbose: false) {|_self| ... } ⇒ Connection
constructor
A new instance of Connection.
- #transport ⇒ Object
Constructor Details
#initialize(url, headers: {}, verbose: false) {|_self| ... } ⇒ Connection
Returns a new instance of Connection.
9 10 11 12 13 14 15 |
# File 'lib/gitloggl/connection.rb', line 9 def initialize(url, headers: {}, verbose: false) @url = url @headers = headers @verbose = verbose yield(self) if block_given? end |
Instance Attribute Details
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
5 6 7 |
# File 'lib/gitloggl/connection.rb', line 5 def headers @headers end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
5 6 7 |
# File 'lib/gitloggl/connection.rb', line 5 def url @url end |
#verbose ⇒ Object (readonly)
Returns the value of attribute verbose.
5 6 7 |
# File 'lib/gitloggl/connection.rb', line 5 def verbose @verbose end |
Instance Method Details
#default_headers ⇒ Object
27 28 29 30 31 |
# File 'lib/gitloggl/connection.rb', line 27 def default_headers @default_headers ||= { 'User-Agent' => USER_AGENT } end |
#transport ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/gitloggl/connection.rb', line 17 def transport @transport ||= Faraday.new(url: url, headers: default_headers.merge(headers)) do |conn| conn.use Faraday::Request::UrlEncoded conn.use Faraday::Response::RaiseError conn.response :json conn.use Faraday::Response::Logger, self, bodies: true if verbose conn.adapter :typhoeus end end |