buildkit 0.3.0 → 0.4.0

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
  SHA1:
3
- metadata.gz: 67404319e0c2f1dd344c940ff02a896742add552
4
- data.tar.gz: 2fcb6d0775b575a9121d69cac501cf4f436e2bef
3
+ metadata.gz: 0e8e7e8d70271e9586222b477e7945262fbf87e3
4
+ data.tar.gz: 7368c5308d1c8550eef30748fc3bbd69e67fb828
5
5
  SHA512:
6
- metadata.gz: 0a7ef856516716490af7513374f1308d987e42490e8d4e04c8d9a33cc321910fd6778f51176795d206f87584dd3bfa69d5d94e57168fd2a73f1c6228aa5125da
7
- data.tar.gz: 698509103262ee39ffad513a6f8bf69216cbe25ad309a50c277e4fe32c246ec0ba57b1716aa6340c41f34ded8ffb2fc0b77c5fdeff866ef862e8dfa3f551ab59
6
+ metadata.gz: 6555de8adc533b85cb01b4704ffce09daf21e282900926b48eb1dd38346e4367d7f5cf26f4e4c75a59f612ab4563e8439980ab9fc4026d635080208a4d22c885
7
+ data.tar.gz: f6009e1e15930027a2eda79ae5231de977ba0ece624f682eff4b7eb16c27c31818fa5576a3b3acdab00004bbdb6141587f5e8749e066a2b7a291a1a17b4cad11
@@ -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/TrailingComma:
39
+ Style/TrailingCommaInLiteral:
40
+ EnforcedStyleForMultiline: comma
41
+
42
+ Style/TrailingCommaInArguments:
37
43
  EnforcedStyleForMultiline: comma
@@ -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(token:)
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 {#api_endpoint}
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 {#api_endpoint}
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 {#api_endpoint}
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 {#api_endpoint}
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 {#api_endpoint}
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 {#api_endpoint}
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(api_endpoint, sawyer_options) do |http|
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|
@@ -98,12 +98,8 @@ module Buildkit
98
98
  def build_error_message
99
99
  return nil if @response.nil?
100
100
 
101
- message = "#{@response[:method].to_s.upcase} "
102
- message << redact_url(@response[:url].to_s) + ': '
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
@@ -1,3 +1,3 @@
1
1
  module Buildkit
2
- VERSION = '0.3.0'
2
+ VERSION = '0.4.0'.freeze
3
3
  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: 0.3.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-04-19 00:00:00.000000000 Z
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.4.6
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: