buildkit 1.4.0 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 6bfeb459ca2ab1b4f33f68b3af71c8e5000a3c1d
4
- data.tar.gz: 627be0e606c9781b8a1378630abceb8954ec49ae
2
+ SHA256:
3
+ metadata.gz: b660f3bc437b261aac25d8a7e8dbeb533570924857e17309f31c283d847725f4
4
+ data.tar.gz: 1c3e6d58d5a38377d30b62ba3a98fededa51cfdb121f8371c3801d93e185d234
5
5
  SHA512:
6
- metadata.gz: 7ef6f8e563bccf36437c2def7676473a124a5f7a4a3cb9ef6f8cfaea8bf424d4a72c933c52714756928bbd14aed289cd17afc45aaed6fea1f7ff75502b2d445a
7
- data.tar.gz: 733f57b132f8788603b8e618448769967c5f78daa5524ed8abc5b5e425d2b1199609b5fd62bdd222a313a3874d007da022802edd3026c7548d7402bc8a0399fe
6
+ metadata.gz: 4fbc1cd2171b549376fd0baf0b342b53312d9d2c67deaa349bbeb5dc6e91a8eca3e61dd6a34dedbcc4e6bc47f9c90b8a63aefbbaabfc80de96907f648a8aa95e
7
+ data.tar.gz: 9b88b7ca24fba99297585e26e425dc31d33d9ed89c5e65e6db7d13c11c43b9bce98b65dfe2241c9570ca3cb297c2ebb4b21e46d632c17007c495e46208232961
@@ -1,7 +1,7 @@
1
1
  inherit_from: .rubocop_todo.yml
2
2
 
3
3
  AllCops:
4
- TargetRubyVersion: 2.2
4
+ TargetRubyVersion: 2.3
5
5
 
6
6
  Metrics/LineLength:
7
7
  Max: 120
@@ -39,7 +39,7 @@ Lint/AssignmentInCondition:
39
39
  Style/PerlBackrefs:
40
40
  Enabled: false
41
41
 
42
- Style/SpaceInsideHashLiteralBraces:
42
+ Layout/SpaceInsideHashLiteralBraces:
43
43
  EnforcedStyle: no_space
44
44
 
45
45
  Style/TrailingCommaInArrayLiteral:
@@ -1,6 +1,4 @@
1
1
  sudo: false
2
2
  before_install: gem install bundler
3
3
  rvm:
4
- - '2.2'
5
- - '2.3'
6
-
4
+ - '2.5'
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  gem 'byebug'
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
4
 
3
5
  require 'rspec/core/rake_task'
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'bundler/setup'
4
5
  require 'buildkit'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  lib = File.expand_path('lib', __dir__)
2
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
5
  require 'buildkit/version'
@@ -17,7 +19,7 @@ Gem::Specification.new do |spec|
17
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
20
  spec.require_paths = ['lib']
19
21
 
20
- spec.required_ruby_version = '>= 2.2'
22
+ spec.required_ruby_version = '>= 2.3'
21
23
 
22
24
  spec.add_dependency 'sawyer', '~> 0.6'
23
25
  spec.add_development_dependency 'bundler'
data/dev.yml ADDED
@@ -0,0 +1,13 @@
1
+ name: buildkit
2
+
3
+ type: ruby
4
+
5
+ up:
6
+ - homebrew:
7
+ - openssl
8
+ - ruby: 2.5.5
9
+ - bundler
10
+
11
+ commands:
12
+ test:
13
+ run: bundle exec rake
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'buildkit/version'
2
4
  require 'buildkit/client'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'sawyer'
2
4
  require 'buildkit/client/agents'
3
5
  require 'buildkit/client/builds'
@@ -18,7 +20,7 @@ module Buildkit
18
20
  include Artifacts
19
21
  include HeaderLinkParser
20
22
 
21
- DEFAULT_ENDPOINT = 'https://api.buildkite.com/v2/'.freeze
23
+ DEFAULT_ENDPOINT = 'https://api.buildkite.com/v2/'
22
24
 
23
25
  # Header keys that can be passed in options hash to {#get},{#head}
24
26
  CONVENIENCE_HEADERS = Set.new(%i[accept content_type])
@@ -139,10 +141,15 @@ module Buildkit
139
141
  response = []
140
142
  loop do
141
143
  request method, path, data, options
144
+
145
+ # Paginated API calls always return Arrays.
146
+ return last_response.data unless @last_response.data.is_a?(Array)
147
+
142
148
  response.concat @last_response.data
143
149
 
144
150
  link_header = parse_link_header(@last_response.headers[:link])
145
151
  break if link_header[:next].nil?
152
+
146
153
  path = next_page(link_header[:next])
147
154
  end
148
155
  response
@@ -181,7 +188,7 @@ module Buildkit
181
188
  end
182
189
  query = options.delete(:query)
183
190
  opts = {query: options}
184
- opts[:query].merge!(query) if query && query.is_a?(Hash)
191
+ opts[:query].merge!(query) if query&.is_a?(Hash)
185
192
  opts[:headers] = headers unless headers.empty?
186
193
 
187
194
  opts
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Buildkit
2
4
  class Client
3
5
  # Methods for the Agents API
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Buildkit
2
4
  class Client
3
5
  # Methods for the Artifacts API
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Buildkit
2
4
  class Client
3
5
  # Methods for the Builds API
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Buildkit
2
4
  class Client
3
5
  # Methods for the Jobs API
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Buildkit
2
4
  class Client
3
5
  # Methods for the Organizations API
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Buildkit
2
4
  class Client
3
5
  # Methods for the pipelines API
@@ -31,7 +33,7 @@ module Buildkit
31
33
  # @param org [String] Organization slug.
32
34
  # @see https://buildkite.com/docs/api/pipelines#create-a-pipeline
33
35
  # @example
34
- # Buildkit.create_build('my-great-org', {
36
+ # Buildkit.create_pipeline('my-great-org', {
35
37
  # name: 'My pipeline',
36
38
  # repository: 'git@github.com:acme/pipeline.git',
37
39
  # steps: [
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Buildkit
2
4
  # Custom error class for rescuing from all Buildkite errors
3
5
  class Error < StandardError
@@ -44,7 +46,7 @@ module Buildkit
44
46
  # Array of validation errors
45
47
  # @return [Array<Hash>] Error info
46
48
  def errors
47
- if data && data.is_a?(Hash)
49
+ if data&.is_a?(Hash)
48
50
  data[:errors] || []
49
51
  else
50
52
  []
@@ -98,7 +100,7 @@ module Buildkit
98
100
  def build_error_message
99
101
  return nil if @response.nil?
100
102
 
101
- message = "#{@response[:method].to_s.upcase} #{redact_url(@response[:url].to_s)}: #{@response[:status]} - "
103
+ message = +"#{@response[:method].to_s.upcase} #{redact_url(@response[:url].to_s)}: #{@response[:status]} - "
102
104
  message << "#{response_message}#{response_error}#{response_error_summary}"
103
105
  message << " // See: #{documentation_url}" unless documentation_url.nil?
104
106
  message
@@ -1,26 +1,30 @@
1
- module HeaderLinkParser
2
- module_function
1
+ # frozen_string_literal: true
3
2
 
4
- def parse_link_header(link_header)
5
- {}.tap do |hash_link|
6
- link_header.split(',').each do |link|
7
- link_obj = LinkParser.new(link)
8
- hash_link[link_obj.name] = link_obj.link
3
+ module Buildkit
4
+ module HeaderLinkParser
5
+ module_function
6
+
7
+ def parse_link_header(link_header)
8
+ {}.tap do |hash_link|
9
+ link_header.split(',').each do |link|
10
+ link_obj = LinkParser.new(link)
11
+ hash_link[link_obj.name] = link_obj.link
12
+ end
9
13
  end
10
14
  end
11
- end
12
15
 
13
- class LinkParser
14
- def initialize(value)
15
- @value = value
16
- end
16
+ class LinkParser
17
+ def initialize(value)
18
+ @value = value
19
+ end
17
20
 
18
- def name
19
- @name ||= @value[/rel="(.*)"/, 1].to_sym
20
- end
21
+ def name
22
+ @name ||= @value[/rel="(.*)"/, 1].to_sym
23
+ end
21
24
 
22
- def link
23
- @link ||= @value[/<(.+)>/, 1]
25
+ def link
26
+ @link ||= @value[/<(.+)>/, 1]
27
+ end
24
28
  end
25
29
  end
26
30
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'faraday'
2
4
  require 'buildkit/error'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Buildkit
2
- VERSION = '1.4.0'.freeze
4
+ VERSION = '1.4.1'
3
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: buildkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean Boussier
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-06-12 00:00:00.000000000 Z
11
+ date: 2019-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sawyer
@@ -57,6 +57,7 @@ files:
57
57
  - bin/console
58
58
  - bin/setup
59
59
  - buildkit.gemspec
60
+ - dev.yml
60
61
  - lib/buildkit.rb
61
62
  - lib/buildkit/client.rb
62
63
  - lib/buildkit/client/agents.rb
@@ -81,15 +82,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
81
82
  requirements:
82
83
  - - ">="
83
84
  - !ruby/object:Gem::Version
84
- version: '2.2'
85
+ version: '2.3'
85
86
  required_rubygems_version: !ruby/object:Gem::Requirement
86
87
  requirements:
87
88
  - - ">="
88
89
  - !ruby/object:Gem::Version
89
90
  version: '0'
90
91
  requirements: []
91
- rubyforge_project:
92
- rubygems_version: 2.6.14
92
+ rubygems_version: 3.0.3
93
93
  signing_key:
94
94
  specification_version: 4
95
95
  summary: Ruby toolkit for working with the Buildkite API