Sha256: b3f80c92ce674db53f38e35dc58bc6e8946201c59b4ad3eee10930dc417a166b
Contents?: true
Size: 818 Bytes
Versions: 3
Compression:
Stored size: 818 Bytes
Contents
# frozen_string_literal: true require 'httpx/adapters/faraday' require 'faraday' require 'faraday/retry' require_relative 'api' module DroneCI class Client include API def initialize(**options) @api = options.fetch(:client) do server = options.fetch(:server) { ENV.fetch('DRONE_SERVER') } token = options.fetch(:token) { ENV.fetch('DRONE_TOKEN') } Faraday.new(server) do |client| client.adapter :httpx client.headers = { 'Authorization' => "Bearer #{token}" }.merge(options.fetch(:headers, {})) client.path_prefix = '/api' client.request :json client.request :retry client.response :json yield client if block_given? end end end attr_reader :api end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
drone-ci-0.2.0 | lib/drone-ci/client.rb |
drone-ci-0.1.1 | lib/drone-ci/client.rb |
drone-ci-0.1.0 | lib/drone-ci/client.rb |