Class: Inq::Sources::CI::Travis
- Inherits:
-
Object
- Object
- Inq::Sources::CI::Travis
- Defined in:
- lib/inq/sources/ci/travis.rb
Overview
Fetches metadata about CI builds from travis-ci.org.
Constant Summary collapse
- BadResponseError =
Class.new(StandardError)
Instance Method Summary collapse
-
#builds ⇒ Hash
Returns the builds for the default branch.
-
#default_branch ⇒ String
The default branch name.
-
#initialize(config, start_date, end_date, cache) ⇒ Travis
constructor
A new instance of Travis.
Constructor Details
#initialize(config, start_date, end_date, cache) ⇒ Travis
Returns a new instance of Travis.
21 22 23 24 25 26 27 28 29 |
# File 'lib/inq/sources/ci/travis.rb', line 21 def initialize(config, start_date, end_date, cache) @config = config @cache = cache @repository = config["repository"] raise "Travis.new() got nil repository." if @repository.nil? @start_date = DateTime.parse(start_date) @end_date = DateTime.parse(end_date) @default_branch = Okay.default end |
Instance Method Details
#builds ⇒ Hash
Returns the builds for the default branch.
48 49 50 51 52 53 54 55 |
# File 'lib/inq/sources/ci/travis.rb', line 48 def builds @cache.cached("travis_builds") do raw_builds \ .map(&method(:normalize_build)) \ .select(&method(:in_date_range?)) \ .map(&method(:add_build_urls)) end end |
#default_branch ⇒ String
Returns The default branch name.
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/inq/sources/ci/travis.rb', line 32 def default_branch return @default_branch unless @default_branch == Okay.default response = fetch("branches", {"sort_by" => "default_branch"}) validate_response!(response) branches = response["branches"] validate_branches!(branches) branch = branches.find { |b| b["default_branch"] == true } @default_branch = branch&.fetch("name", nil) end |