Sha256: d9fc46773fd4058a0e7e2720bf2054d1cafc187b39c701ddf2ec9460bc05b1de

Contents?: true

Size: 593 Bytes

Versions: 1

Compression:

Stored size: 593 Bytes

Contents

require "json"

module Bickle
  class Builds
    BUILDS_URI     = "https://api.travis-ci.org/repos/%s/builds.json"
    DEFAULT_NUMBER = 25

    def initialize(repository, options = {})
      @repository = repository
      @options = options
    end

    def self.for(repository, options = {})
      new(repository, options).for
    end

    def for(client = HttpClient, response_parser = ResponseParser)
      response = client.get(BUILDS_URI % @repository)
      builds   = response_parser.parse(response)

      builds.first(@options["number_of_builds"] || DEFAULT_NUMBER)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bickle-0.0.1 lib/bickle/builds.rb