buildkit 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +7 -1
- data/lib/buildkit/client.rb +12 -12
- data/lib/buildkit/error.rb +2 -6
- data/lib/buildkit/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e8e7e8d70271e9586222b477e7945262fbf87e3
|
4
|
+
data.tar.gz: 7368c5308d1c8550eef30748fc3bbd69e67fb828
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6555de8adc533b85cb01b4704ffce09daf21e282900926b48eb1dd38346e4367d7f5cf26f4e4c75a59f612ab4563e8439980ab9fc4026d635080208a4d22c885
|
7
|
+
data.tar.gz: f6009e1e15930027a2eda79ae5231de977ba0ece624f682eff4b7eb16c27c31818fa5576a3b3acdab00004bbdb6141587f5e8749e066a2b7a291a1a17b4cad11
|
data/.rubocop.yml
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
inherit_from: .rubocop_todo.yml
|
2
2
|
|
3
|
+
AllCops:
|
4
|
+
TargetRubyVersion: 2.1
|
5
|
+
|
3
6
|
Metrics/LineLength:
|
4
7
|
Max: 120
|
5
8
|
|
@@ -33,5 +36,8 @@ Style/PerlBackrefs:
|
|
33
36
|
Style/SpaceInsideHashLiteralBraces:
|
34
37
|
EnforcedStyle: no_space
|
35
38
|
|
36
|
-
Style/
|
39
|
+
Style/TrailingCommaInLiteral:
|
40
|
+
EnforcedStyleForMultiline: comma
|
41
|
+
|
42
|
+
Style/TrailingCommaInArguments:
|
37
43
|
EnforcedStyleForMultiline: comma
|
data/lib/buildkit/client.rb
CHANGED
@@ -12,6 +12,8 @@ module Buildkit
|
|
12
12
|
include Organizations
|
13
13
|
include Projects
|
14
14
|
|
15
|
+
DEFAULT_ENDPOINT = 'https://api.buildkite.com/v1/'.freeze
|
16
|
+
|
15
17
|
# Header keys that can be passed in options hash to {#get},{#head}
|
16
18
|
CONVENIENCE_HEADERS = Set.new([:accept, :content_type])
|
17
19
|
|
@@ -24,13 +26,15 @@ module Buildkit
|
|
24
26
|
builder.adapter Faraday.default_adapter
|
25
27
|
end
|
26
28
|
|
27
|
-
def initialize(
|
29
|
+
def initialize(endpoint: ENV.fetch('BUILDKITE_API_ENDPOINT', DEFAULT_ENDPOINT),
|
30
|
+
token: ENV.fetch('BUILDKITE_API_TOKEN'))
|
31
|
+
@endpoint = endpoint
|
28
32
|
@token = token
|
29
33
|
end
|
30
34
|
|
31
35
|
# Make a HTTP GET request
|
32
36
|
#
|
33
|
-
# @param url [String] The path, relative to {
|
37
|
+
# @param url [String] The path, relative to {@endpoint}
|
34
38
|
# @param options [Hash] Query and header params for request
|
35
39
|
# @return [Sawyer::Resource]
|
36
40
|
def get(url, options = {})
|
@@ -39,7 +43,7 @@ module Buildkit
|
|
39
43
|
|
40
44
|
# Make a HTTP POST request
|
41
45
|
#
|
42
|
-
# @param url [String] The path, relative to {
|
46
|
+
# @param url [String] The path, relative to {@endpoint}
|
43
47
|
# @param options [Hash] Body and header params for request
|
44
48
|
# @return [Sawyer::Resource]
|
45
49
|
def post(url, options = {})
|
@@ -48,7 +52,7 @@ module Buildkit
|
|
48
52
|
|
49
53
|
# Make a HTTP PUT request
|
50
54
|
#
|
51
|
-
# @param url [String] The path, relative to {
|
55
|
+
# @param url [String] The path, relative to {@endpoint}
|
52
56
|
# @param options [Hash] Body and header params for request
|
53
57
|
# @return [Sawyer::Resource]
|
54
58
|
def put(url, options = {})
|
@@ -57,7 +61,7 @@ module Buildkit
|
|
57
61
|
|
58
62
|
# Make a HTTP PATCH request
|
59
63
|
#
|
60
|
-
# @param url [String] The path, relative to {
|
64
|
+
# @param url [String] The path, relative to {@endpoint}
|
61
65
|
# @param options [Hash] Body and header params for request
|
62
66
|
# @return [Sawyer::Resource]
|
63
67
|
def patch(url, options = {})
|
@@ -66,7 +70,7 @@ module Buildkit
|
|
66
70
|
|
67
71
|
# Make a HTTP DELETE request
|
68
72
|
#
|
69
|
-
# @param url [String] The path, relative to {
|
73
|
+
# @param url [String] The path, relative to {@endpoint}
|
70
74
|
# @param options [Hash] Query and header params for request
|
71
75
|
# @return [Sawyer::Resource]
|
72
76
|
def delete(url, options = {})
|
@@ -75,7 +79,7 @@ module Buildkit
|
|
75
79
|
|
76
80
|
# Make a HTTP HEAD request
|
77
81
|
#
|
78
|
-
# @param url [String] The path, relative to {
|
82
|
+
# @param url [String] The path, relative to {@endpoint}
|
79
83
|
# @param options [Hash] Query and header params for request
|
80
84
|
# @return [Sawyer::Resource]
|
81
85
|
def head(url, options = {})
|
@@ -107,7 +111,7 @@ module Buildkit
|
|
107
111
|
end
|
108
112
|
|
109
113
|
def sawyer_agent
|
110
|
-
@agent ||= Sawyer::Agent.new(
|
114
|
+
@agent ||= Sawyer::Agent.new(@endpoint, sawyer_options) do |http|
|
111
115
|
http.headers[:accept] = 'application/json'
|
112
116
|
http.headers[:content_type] = 'application/json'
|
113
117
|
http.headers[:user_agent] = "Buildkit v#{Buildkit::VERSION}"
|
@@ -122,10 +126,6 @@ module Buildkit
|
|
122
126
|
}
|
123
127
|
end
|
124
128
|
|
125
|
-
def api_endpoint
|
126
|
-
'https://api.buildkite.com/v1/'
|
127
|
-
end
|
128
|
-
|
129
129
|
def parse_query_and_convenience_headers(options)
|
130
130
|
headers = options.fetch(:headers, {})
|
131
131
|
CONVENIENCE_HEADERS.each do |h|
|
data/lib/buildkit/error.rb
CHANGED
@@ -98,12 +98,8 @@ module Buildkit
|
|
98
98
|
def build_error_message
|
99
99
|
return nil if @response.nil?
|
100
100
|
|
101
|
-
message =
|
102
|
-
message <<
|
103
|
-
message << "#{@response[:status]} - "
|
104
|
-
message << "#{response_message}" unless response_message.nil?
|
105
|
-
message << "#{response_error}" unless response_error.nil?
|
106
|
-
message << "#{response_error_summary}" unless response_error_summary.nil?
|
101
|
+
message = "#{@response[:method].to_s.upcase} #{redact_url(@response[:url].to_s)}: #{@response[:status]} - "
|
102
|
+
message << "#{response_message}#{response_error}#{response_error_summary}"
|
107
103
|
message << " // See: #{documentation_url}" unless documentation_url.nil?
|
108
104
|
message
|
109
105
|
end
|
data/lib/buildkit/version.rb
CHANGED
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: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jean Boussier
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sawyer
|
@@ -86,9 +86,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
86
|
version: '0'
|
87
87
|
requirements: []
|
88
88
|
rubyforge_project:
|
89
|
-
rubygems_version: 2.
|
89
|
+
rubygems_version: 2.5.1
|
90
90
|
signing_key:
|
91
91
|
specification_version: 4
|
92
92
|
summary: Ruby toolkit for working with the Buildkite API
|
93
93
|
test_files: []
|
94
|
-
has_rdoc:
|