Class: Inq::Sources::CI::Appveyor

Inherits:
Object
  • Object
show all
Defined in:
lib/inq/sources/ci/appveyor.rb

Overview

Fetches metadata about CI builds from appveyor.com.

Instance Method Summary collapse

Constructor Details

#initialize(config, start_date, end_date, cache) ⇒ Appveyor

Returns a new instance of Appveyor.

Parameters:

  • repository (String)

    GitHub repository name, of the format user/repo.

  • start_date (String)

    Start date for the report being generated.

  • end_date (String)

    End date for the report being generated.

  • cache (Cacheable)

    Instance of Inq::Cacheable to cache API calls



19
20
21
22
23
24
25
26
# File 'lib/inq/sources/ci/appveyor.rb', line 19

def initialize(config, start_date, end_date, cache)
  @config = config
  @cache = cache
  @repository = config["repository"]
  @start_date = DateTime.parse(start_date)
  @end_date = DateTime.parse(end_date)
  @default_branch = Okay.default
end

Instance Method Details

#buildsHash

Fetches builds for the default branch.

Returns:

  • (Hash)

    Builds for the default branch.



40
41
42
43
44
45
46
47
48
# File 'lib/inq/sources/ci/appveyor.rb', line 40

def builds
  @builds ||=
    fetch_builds["builds"] \
      .map(&method(:normalize_build)) \
      .select(&method(:in_date_range?))
rescue Net::HTTPServerException
  # It's not elegant, but it works™.
  []
end

#default_branchString

Returns The default branch name.

Returns:

  • (String)

    The default branch name.



29
30
31
32
33
34
35
# File 'lib/inq/sources/ci/appveyor.rb', line 29

def default_branch
  return @default_branch unless @default_branch.nil?

  contributions = Sources::GitHub::Contributions.new(@config, nil, nil)

  @default_branch = contributions.default_branch
end