class MergetrainCheck::Checker

Public Class Methods

new(host, token, id) click to toggle source
# File lib/mergetrain_check/checker.rb, line 14
def initialize(host, token, id)
  @host = host
  @token = token
  @id = id
  @max_count = 10
end

Public Instance Methods

check() click to toggle source
# File lib/mergetrain_check/checker.rb, line 21
def check
  Net::HTTP.start(active_uri.host, active_uri.port, :use_ssl => active_uri.scheme == 'https') do |http|
    get_and_parse(http, active_uri) + get_and_parse(http, completed_uri)
  end
end
max_completed=(value) click to toggle source
# File lib/mergetrain_check/checker.rb, line 10
def max_completed=(value)
  @max_completed = value
end
max_count() click to toggle source
# File lib/mergetrain_check/checker.rb, line 6
def max_count
  @max_count
end

Private Instance Methods

active_uri() click to toggle source
# File lib/mergetrain_check/checker.rb, line 41
def active_uri
  URI("https://#{@host}/api/v4/projects/#{@id}/merge_trains?per_page=100&scope=active&sort=asc")
end
completed_uri() click to toggle source
# File lib/mergetrain_check/checker.rb, line 37
def completed_uri
  URI("https://#{@host}/api/v4/projects/#{@id}/merge_trains?per_page=#{@max_completed}&scope=complete")
end
get_and_parse(http, uri) click to toggle source
# File lib/mergetrain_check/checker.rb, line 29
def get_and_parse(http, uri)
  request = Net::HTTP::Get.new uri
  request['PRIVATE-TOKEN'] = @token

  response = http.request request
  JSON.parse response.body
end