labclient 0.4.2 → 0.5.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 +4 -4
- data/lib/labclient/client/helpers.rb +4 -0
- data/lib/labclient/client.rb +1 -2
- data/lib/labclient/feature_flags/list.rb +1 -1
- data/lib/labclient/files/show.rb +5 -5
- data/lib/labclient/http.rb +1 -1
- data/lib/labclient/klass.rb +4 -9
- data/lib/labclient/lab_struct.rb +39 -7
- data/lib/labclient/merge_requests/delete.rb +10 -2
- data/lib/labclient/notifications/update.rb +1 -1
- data/lib/labclient/projects/methods.rb +5 -1
- data/lib/labclient/version.rb +1 -1
- data/lib/labclient.rb +1 -1
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 105ec572236cc556ebab18031557136d5bb1e78a33d39ad00ba9032e831627b2
|
4
|
+
data.tar.gz: 49b836de0a75f9e1ca38cf1620754d824116047c9b944b3c8f81949d07f60162
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1504185ca949dc3dc77eb8266965e2f70d3023a954dcd01eb8194e47086c26a731438310f902f014fd5e63f982ce2a141fda0e37ab55f3a772e46905fb27d46c
|
7
|
+
data.tar.gz: 45c22d9129316bd4dd25558c9184d7a1eb79ed2ddd0dab153f60b39fd7838b4e95388465a617002c787b3f32f4dc62eb9924c3624d4f3ac5e6aab63770012946
|
@@ -101,6 +101,10 @@ module LabClient
|
|
101
101
|
resp.headers['retry-after']&.to_i
|
102
102
|
end
|
103
103
|
|
104
|
+
def retry_debug_headers
|
105
|
+
resp.headers.select { |k, _v| k.include? 'ratelimit' }
|
106
|
+
end
|
107
|
+
|
104
108
|
# Handle Retry Logic
|
105
109
|
# 1. If response merits a retry
|
106
110
|
# 2. Retry is enabled
|
data/lib/labclient/client.rb
CHANGED
@@ -37,7 +37,6 @@ module LabClient
|
|
37
37
|
debug_handler if debug?
|
38
38
|
|
39
39
|
post_request_handlers
|
40
|
-
|
41
40
|
process resp
|
42
41
|
rescue LabClient::Error => e
|
43
42
|
logger.fatal('Request Failed', e.error_details) unless quiet?
|
@@ -46,7 +45,7 @@ module LabClient
|
|
46
45
|
self.retries += 1
|
47
46
|
|
48
47
|
# Assume Retry After by Default
|
49
|
-
logger.debug('Retry After', value: retry_after,
|
48
|
+
logger.debug('Retry After', value: retry_after, retry_debug_headers: retry_debug_headers) if debug?
|
50
49
|
self.delay = retry_after if resp.headers.key? 'retry-after'
|
51
50
|
|
52
51
|
self.delay += delay_factor
|
data/lib/labclient/files/show.rb
CHANGED
@@ -3,11 +3,11 @@ module LabClient
|
|
3
3
|
# Specifics
|
4
4
|
class Files < Common
|
5
5
|
doc 'Show' do
|
6
|
-
desc 'Allows you to receive information about file in repository like name, size, content [Project ID, File Path, Ref (
|
6
|
+
desc 'Allows you to receive information about file in repository like name, size, content [Project ID, File Path, Ref (main default), kind]'
|
7
7
|
example 'client.files.show(264, "README.md")'
|
8
8
|
|
9
9
|
markdown <<~DOC
|
10
|
-
Ref will default to `
|
10
|
+
Ref will default to `main`
|
11
11
|
|
12
12
|
Kind can be left empty or set to either :raw or :blame
|
13
13
|
DOC
|
@@ -15,12 +15,12 @@ module LabClient
|
|
15
15
|
|
16
16
|
doc 'Show' do
|
17
17
|
desc 'Raw Content'
|
18
|
-
example 'client.files.show(264, "README.md", :
|
18
|
+
example 'client.files.show(264, "README.md", :main, :raw)'
|
19
19
|
end
|
20
20
|
|
21
21
|
doc 'Show' do
|
22
22
|
desc 'Blame'
|
23
|
-
example 'client.files.show(264, "README.md", :
|
23
|
+
example 'client.files.show(264, "README.md", :main, :blame)'
|
24
24
|
end
|
25
25
|
|
26
26
|
doc 'Show' do
|
@@ -31,7 +31,7 @@ module LabClient
|
|
31
31
|
DOC
|
32
32
|
end
|
33
33
|
|
34
|
-
def show(project_id, file_path, ref = :
|
34
|
+
def show(project_id, file_path, ref = :main, kind = nil)
|
35
35
|
kind = case kind
|
36
36
|
when :raw
|
37
37
|
'/raw'
|
data/lib/labclient/http.rb
CHANGED
@@ -88,7 +88,7 @@ module Typhoeus
|
|
88
88
|
elsif headers['content-type']&.include? 'text/plain'
|
89
89
|
body
|
90
90
|
else
|
91
|
-
result = Oj.load(body, mode: :compat, object_class: LabClient::LabStruct)
|
91
|
+
result = Oj.load(body, mode: :compat, symbol_keys: true, object_class: LabClient::LabStruct)
|
92
92
|
result.instance_variable_set(:@response, self) if result.instance_of?(LabClient::LabStruct)
|
93
93
|
result
|
94
94
|
end
|
data/lib/labclient/klass.rb
CHANGED
@@ -5,7 +5,7 @@ module LabClient
|
|
5
5
|
include LabClient::Logger
|
6
6
|
include CurlHelper
|
7
7
|
|
8
|
-
attr_reader :client
|
8
|
+
attr_reader :client
|
9
9
|
|
10
10
|
extend Docs
|
11
11
|
|
@@ -105,18 +105,13 @@ module LabClient
|
|
105
105
|
client.quiet?
|
106
106
|
end
|
107
107
|
|
108
|
-
|
109
|
-
|
108
|
+
def initialize(table = nil, response = nil, client = nil)
|
109
|
+
# @table = table unless table.nil?
|
110
110
|
@client = client
|
111
111
|
@response = response
|
112
112
|
|
113
|
-
|
114
|
-
hash&.each_pair do |k, v|
|
115
|
-
k = k.to_sym
|
116
|
-
@table[k] = v
|
117
|
-
end
|
113
|
+
super(table)
|
118
114
|
end
|
119
|
-
# rubocop:enable Lint/MissingSuper
|
120
115
|
|
121
116
|
# Forward response success
|
122
117
|
def success?
|
data/lib/labclient/lab_struct.rb
CHANGED
@@ -1,16 +1,28 @@
|
|
1
|
-
# Extensions for
|
1
|
+
# Extensions for LabStruct specific to LabClient
|
2
2
|
module LabClient
|
3
|
-
# Unique inherited class to not override top level
|
4
|
-
class LabStruct
|
3
|
+
# Unique inherited class to not override top level LabStruct
|
4
|
+
class LabStruct
|
5
5
|
include CurlHelper
|
6
|
-
attr_reader :response
|
6
|
+
attr_reader :response, :table
|
7
|
+
|
8
|
+
def initialize(hash = {})
|
9
|
+
@table = if hash.instance_of?(LabClient::LabStruct)
|
10
|
+
hash.to_h
|
11
|
+
else
|
12
|
+
hash
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_h
|
17
|
+
@table
|
18
|
+
end
|
7
19
|
|
8
20
|
def keys
|
9
|
-
|
21
|
+
@table.keys.sort
|
10
22
|
end
|
11
23
|
|
12
24
|
def inspect
|
13
|
-
|
25
|
+
@table.inspect
|
14
26
|
end
|
15
27
|
|
16
28
|
def as_json(*args)
|
@@ -18,7 +30,7 @@ module LabClient
|
|
18
30
|
end
|
19
31
|
|
20
32
|
def slice(*opts)
|
21
|
-
|
33
|
+
@table.slice(*opts)
|
22
34
|
end
|
23
35
|
|
24
36
|
def client
|
@@ -29,5 +41,25 @@ module LabClient
|
|
29
41
|
def success?
|
30
42
|
@response.success?
|
31
43
|
end
|
44
|
+
|
45
|
+
def method_missing(method, *_args)
|
46
|
+
@table[method] if @table.keys.include?(method)
|
47
|
+
end
|
48
|
+
|
49
|
+
def respond_to_missing?(method_name, include_private = false)
|
50
|
+
@table.keys.include?(method_name) || super
|
51
|
+
end
|
52
|
+
|
53
|
+
def key?(idx)
|
54
|
+
@table.key? idx
|
55
|
+
end
|
56
|
+
|
57
|
+
def []=(name, value)
|
58
|
+
@table[name] = value
|
59
|
+
end
|
60
|
+
|
61
|
+
def [](name)
|
62
|
+
@table[name.to_sym]
|
63
|
+
end
|
32
64
|
end
|
33
65
|
end
|
@@ -13,13 +13,21 @@ module LabClient
|
|
13
13
|
end
|
14
14
|
|
15
15
|
doc 'Delete' do
|
16
|
-
desc 'Delete
|
16
|
+
desc 'Delete via MergeRequest'
|
17
17
|
example <<~DOC
|
18
|
-
mr = client.merge_requests.
|
18
|
+
mr = client.merge_requests.delete(343,2)
|
19
19
|
mr.delete
|
20
20
|
DOC
|
21
21
|
end
|
22
22
|
|
23
|
+
doc 'Delete' do
|
24
|
+
desc 'Via Project'
|
25
|
+
example <<~DOC
|
26
|
+
project = client.projects.show(1)
|
27
|
+
project.merge_requests_delete(12)
|
28
|
+
DOC
|
29
|
+
end
|
30
|
+
|
23
31
|
# Delete
|
24
32
|
def delete(project_id, merge_request_id)
|
25
33
|
project_id = format_id(project_id)
|
@@ -321,7 +321,7 @@ module LabClient
|
|
321
321
|
end
|
322
322
|
|
323
323
|
# Files
|
324
|
-
def file(file_path, ref = :
|
324
|
+
def file(file_path, ref = :main, kind = nil)
|
325
325
|
client.files.show(id, file_path, ref, kind)
|
326
326
|
end
|
327
327
|
|
@@ -647,6 +647,10 @@ module LabClient
|
|
647
647
|
client.merge_requests.create(id, query)
|
648
648
|
end
|
649
649
|
|
650
|
+
def merge_request_delete(merge_request_iid)
|
651
|
+
client.merge_requests.delete(id, merge_request_iid)
|
652
|
+
end
|
653
|
+
|
650
654
|
# Access Requests
|
651
655
|
def request_access
|
652
656
|
client.projects.access_requests.create(id)
|
data/lib/labclient/version.rb
CHANGED
data/lib/labclient.rb
CHANGED
@@ -876,7 +876,7 @@ require 'labclient/generator/generator'
|
|
876
876
|
require 'labclient/generator/wizard'
|
877
877
|
|
878
878
|
# Dynamically Require Templates (Simplify new template creation)
|
879
|
-
Dir["#{File.dirname(__FILE__)}/labclient/generator/templates/*.rb"].
|
879
|
+
Dir["#{File.dirname(__FILE__)}/labclient/generator/templates/*.rb"].each { |file| require file }
|
880
880
|
|
881
881
|
# Load Client Files - I am Very Last!
|
882
882
|
require 'labclient/client/setup'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: labclient
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Davin Walker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -224,16 +224,16 @@ dependencies:
|
|
224
224
|
name: rubocop
|
225
225
|
requirement: !ruby/object:Gem::Requirement
|
226
226
|
requirements:
|
227
|
-
- - "
|
227
|
+
- - ">="
|
228
228
|
- !ruby/object:Gem::Version
|
229
|
-
version: '
|
229
|
+
version: '0'
|
230
230
|
type: :development
|
231
231
|
prerelease: false
|
232
232
|
version_requirements: !ruby/object:Gem::Requirement
|
233
233
|
requirements:
|
234
|
-
- - "
|
234
|
+
- - ">="
|
235
235
|
- !ruby/object:Gem::Version
|
236
|
-
version: '
|
236
|
+
version: '0'
|
237
237
|
- !ruby/object:Gem::Dependency
|
238
238
|
name: rubocop-minitest
|
239
239
|
requirement: !ruby/object:Gem::Requirement
|
@@ -943,7 +943,8 @@ files:
|
|
943
943
|
homepage: https://gitlab.com/labclient/labclient
|
944
944
|
licenses:
|
945
945
|
- MIT
|
946
|
-
metadata:
|
946
|
+
metadata:
|
947
|
+
rubygems_mfa_required: 'true'
|
947
948
|
post_install_message:
|
948
949
|
rdoc_options: []
|
949
950
|
require_paths:
|
@@ -959,7 +960,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
959
960
|
- !ruby/object:Gem::Version
|
960
961
|
version: '0'
|
961
962
|
requirements: []
|
962
|
-
rubygems_version: 3.
|
963
|
+
rubygems_version: 3.2.32
|
963
964
|
signing_key:
|
964
965
|
specification_version: 4
|
965
966
|
summary: Gitlab API Client
|