class LetItCrash::Reporters::Upload

Constants

TOKEN_HEADER

Attributes

endpoint[R]
token[R]

Public Class Methods

from_env() click to toggle source
# File lib/letitcrash/reporters/upload.rb, line 10
def self.from_env
  endpoint = ENV.fetch(
    'LETITCRASH_COVERAGE_ENDPOINT',
    'https://notify.letitcrash.io/coverage/ruby',
  )
  new(endpoint: endpoint, token: ENV.fetch('LETITCRASH_COVERAGE_TOKEN'))
end
new(endpoint:, token:) click to toggle source
# File lib/letitcrash/reporters/upload.rb, line 18
def initialize(endpoint:, token:)
  @endpoint = endpoint
  @token = token
end

Public Instance Methods

report(input) click to toggle source
# File lib/letitcrash/reporters/upload.rb, line 23
def report(input)
  blockers_off
  RestClient.post(endpoint, input.to_json, headers)
  blockers_on
end

Private Instance Methods

blockers_off() click to toggle source

This method reeks of :reek:UtilityFunction.

# File lib/letitcrash/reporters/upload.rb, line 34
def blockers_off
  WebMock.disable! if defined?(WebMock)
  VCR.turn_off!(ignore_cassettes: true) if defined?(VCR)
end
blockers_on() click to toggle source

This method reeks of :reek:UtilityFunction.

# File lib/letitcrash/reporters/upload.rb, line 40
def blockers_on
  WebMock.enable! if defined?(WebMock)
  VCR.turn_on! if defined?(VCR)
end
headers() click to toggle source
# File lib/letitcrash/reporters/upload.rb, line 45
def headers
  {
    content_type: :json,
    accept: :json,
    TOKEN_HEADER => token
  }
end