Sha256: 1e19d8fa22935c58f7f9c7aee7e8a9a6ed4b9e2148fa50cb22582b3c0b874584

Contents?: true

Size: 761 Bytes

Versions: 2

Compression:

Stored size: 761 Bytes

Contents

# frozen_string_literal: true

module CircleCIReporter
  # Encapsulate a CircleCI build
  #
  # @attr vcs_revision [String] revision of git
  # @attr build_number [Integer] the ID of the CircleCI build
  Build = Struct.new(:vcs_revision, :build_number) do
    # @param revision [String]
    # @return [Boolean]
    def match?(revision)
      vcs_revision.start_with?(revision)
    end

    # @return [Array<Artifact>]
    def artifacts
      @artifacts ||= CircleCIReporter.client.artifacts(build_number)
    end

    # @param string [String]
    # @param node_index [Integer, nil]
    # @return [Artifact, nil]
    def find_artifact(string, node_index: nil)
      artifacts.find { |artifact| artifact.match?(string, node_index: node_index) }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
circleci_reporter-1.0.1 lib/circleci_reporter/build.rb
circleci_reporter-1.0.0 lib/circleci_reporter/build.rb