trav3 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c5b7f9b00d0891a4baef42f3001d0d213e3fabc8a12c04d1d9c011ff3be1c55e
4
- data.tar.gz: c4236a392320c3e7e54cae05dfb8cf16ae32d3f32fe102d8725ae74fe887abd5
3
+ metadata.gz: ec72696776f9747858b7651d1995adae3f75846de1078f79d166dceb9cebd3aa
4
+ data.tar.gz: 2640ff730d6fe51bd4898f1f62690a24b48230dea7e03c6eda122a358fb66c62
5
5
  SHA512:
6
- metadata.gz: f99540fcc00032b646f42c371e7a72c27b93b20ecbaf533f2ae87ded0baaea75eb99ee94a8edabd043bd4ea08fbccb4c08dcaffc007418d23afc3c735cf5c5f1
7
- data.tar.gz: 0256075e0a45c631429ef676c5a730b888001c5266aee7216abba0c6f27ecb8934f980fc0fbe41156aa1e7c72bdd796cf65a3f98d2776bedf17ee1a524d8f562
6
+ metadata.gz: 3cb082ad8b24ca68f5e03c76a92de944e61dfe46fcf66f631cfc5cf4c6ed4b6f2e5613021a09628e8ff0f9af95cf614cdc9d076b78424b6ce876a5a019bb02ca
7
+ data.tar.gz: a5a282d39eeaa1d12e14179a91d53ee49396ed04e55fa65153468fa2fc8defead7fd3f085d9dda510d9d324e5f9431db07e2fb8d2e9dc5b592097a1ff47ea72f
@@ -17,6 +17,7 @@ before_script:
17
17
  script:
18
18
  - bundle exec rake
19
19
  - bundle exec rubocop
20
+ - bundle exec yard | if grep warn; then exit 1; else exit 0; fi
20
21
 
21
22
  after_script:
22
23
  - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
data/Gemfile CHANGED
@@ -12,4 +12,5 @@ group :test do
12
12
  gem 'simplecov', require: false
13
13
  gem 'vcr', '~> 4.0'
14
14
  gem 'webmock', '~> 3.5'
15
+ gem 'yard', require: false
15
16
  end
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
  [![Build Status](https://travis-ci.org/danielpclark/trav3.svg?branch=master)](https://travis-ci.org/danielpclark/trav3)
3
3
  [![Maintainability](https://api.codeclimate.com/v1/badges/1ed07a4baea3832b6207/maintainability)](https://codeclimate.com/github/danielpclark/trav3/maintainability)
4
4
  [![Test Coverage](https://api.codeclimate.com/v1/badges/1ed07a4baea3832b6207/test_coverage)](https://codeclimate.com/github/danielpclark/trav3/test_coverage)
5
- [![Red The Docs](https://img.shields.io/badge/Read-the%20docs-blue.svg)](https://www.rubydoc.info/github/danielpclark/trav3/0af161/Trav3/Travis)
5
+ [![Red The Docs](https://img.shields.io/badge/Read-the%20docs-blue.svg)](http://danielpclark.github.io/trav3/Trav3/Travis.html)
6
6
  [![SayThanks.io](https://img.shields.io/badge/SayThanks.io-%E2%98%BC-1EAEDB.svg)](https://saythanks.io/to/danielpclark)
7
7
 
8
8
  # Trav3
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # rubocop:disable Metrics/ClassLength
3
4
  require 'trav3/version'
4
5
  require 'trav3/pagination'
5
6
  require 'trav3/options'
@@ -21,7 +22,6 @@ module Trav3
21
22
  # @return [Options] Request options object
22
23
  # @!attribute [r] headers
23
24
  # @return [Headers] Request headers object
24
- # rubocop:disable Metrics/ClassLength
25
25
  class Travis
26
26
  API_ENDPOINT = API_ROOT
27
27
  attr_reader :api_endpoint
@@ -133,7 +133,7 @@ module Trav3
133
133
  #
134
134
  # Example:GET /repo/rails%2Frails/branch/master
135
135
  #
136
- # @param id [String] the branch name for the current repository
136
+ # @param name [String] the branch name for the current repository
137
137
  # @return [Success, RequestError]
138
138
  def branch(name)
139
139
  get("#{with_repo}/branch/#{name}#{opts}")
@@ -1173,6 +1173,52 @@ module Trav3
1173
1173
  end
1174
1174
  end
1175
1175
 
1176
+ # A list of stages.
1177
+ #
1178
+ # Currently this is nested within a build.
1179
+ #
1180
+ # ## Attributes
1181
+ #
1182
+ # Name Type Description
1183
+ # stages [Stage] List of stages.
1184
+ #
1185
+ # **Collection Items**
1186
+ #
1187
+ # Each entry in the stages array has the following attributes:
1188
+ #
1189
+ # Name Type Description
1190
+ # id Integer Value uniquely identifying the stage.
1191
+ # number Integer Incremental number for a stage.
1192
+ # name String The name of the stage.
1193
+ # state String Current state of the stage.
1194
+ # started_at String When the stage started.
1195
+ # finished_at String When the stage finished.
1196
+ # jobs [Job] The jobs of a stage.
1197
+ #
1198
+ # ## Actions
1199
+ #
1200
+ # **Find**
1201
+ #
1202
+ # This returns a list of stages belonging to an individual build.
1203
+ #
1204
+ # GET <code>/build/{build.id}/stages</code>
1205
+ #
1206
+ # Template Variable Type Description
1207
+ # build.id Integer Value uniquely identifying the build.
1208
+ # Query Parameter Type Description
1209
+ # include [String] List of attributes to eager load.
1210
+ #
1211
+ # Example:GET /build/86601346/stages
1212
+ #
1213
+ # @param build_id [String, Integer] build id
1214
+ # @raise [TypeError] if given build id is not a number
1215
+ # @return [Success, RequestError]
1216
+ def stages(build_id)
1217
+ raise TypeError, 'Integer expected for build id' unless /^\d+$/.match? build_id.to_s
1218
+
1219
+ get("#{without_repo}/build/#{build_id}/stages")
1220
+ end
1221
+
1176
1222
  # An individual user.
1177
1223
  #
1178
1224
  # ## Attributes
@@ -1307,5 +1353,5 @@ module Trav3
1307
1353
  api_endpoint
1308
1354
  end
1309
1355
  end
1310
- # rubocop:enable Metrics/ClassLength
1311
1356
  end
1357
+ # rubocop:enable Metrics/ClassLength
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # rubocop:disable Metrics/MethodLength
3
4
  require 'net/http'
4
5
  require 'uri'
5
6
  require 'json'
6
7
 
7
8
  module Trav3
8
9
  module GET
9
- # rubocop:disable Metrics/MethodLength
10
10
  def self.call(travis, url, raw_reply = false)
11
11
  uri = URI(url)
12
12
  req = Net::HTTP::Get.new(uri.request_uri)
@@ -25,6 +25,6 @@ module Trav3
25
25
  RequestError.new(travis, response)
26
26
  end
27
27
  end
28
- # rubocop:enable Metrics/MethodLength
29
28
  end
30
29
  end
30
+ # rubocop:enable Metrics/MethodLength
@@ -26,13 +26,10 @@ module Trav3
26
26
  def remove(key)
27
27
  return_value = nil
28
28
 
29
- @opts = @opts.keep_if do |item, value|
30
- if entry_match?(key, item)
31
- return_value = value
32
- false
33
- else
34
- true
35
- end
29
+ @opts = @opts.delete_if do |item|
30
+ head, tail = split.call item
31
+
32
+ return_value = tail if head == key.to_s
36
33
  end
37
34
 
38
35
  return_value
@@ -55,13 +52,13 @@ module Trav3
55
52
  end
56
53
 
57
54
  def to_h
58
- @opts.map { |item| item.split('=') }.to_h
55
+ @opts.map(&split).to_h
59
56
  end
60
57
 
61
58
  private
62
59
 
63
- def entry_match?(entry, item)
64
- /^#{entry}=/.match? item.to_s
60
+ def split
61
+ ->(entry) { entry.split('=') }
65
62
  end
66
63
  end
67
64
  end
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # rubocop:disable Metrics/MethodLength
3
4
  require 'net/http'
4
5
  require 'uri'
5
6
  require 'json'
6
7
 
7
8
  module Trav3
8
9
  module POST
9
- # rubocop:disable Metrics/MethodLength
10
10
  def self.call(travis, url, **fields)
11
11
  uri = URI( url.sub(/\?.*$/, '') )
12
12
  req = Net::HTTP::Post.new(uri.request_uri)
@@ -26,6 +26,6 @@ module Trav3
26
26
  RequestError.new(travis, response)
27
27
  end
28
28
  end
29
- # rubocop:enable Metrics/MethodLength
30
29
  end
31
30
  end
31
+ # rubocop:enable Metrics/MethodLength
@@ -1,3 +1,3 @@
1
1
  module Trav3
2
- VERSION = '0.2.1'.freeze
2
+ VERSION = '0.2.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trav3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel P. Clark