labclient 0.1.5 → 0.2.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.rb +1 -2
- data/lib/labclient/access_levels.rb +24 -30
- data/lib/labclient/client.rb +5 -4
- data/lib/labclient/docs.rb +4 -4
- data/lib/labclient/generator/template_helper.rb +0 -1
- data/lib/labclient/groups/group.rb +1 -1
- data/lib/labclient/issues/issue.rb +10 -0
- data/lib/labclient/issues/update.rb +20 -2
- data/lib/labclient/jobs/delete.rb +1 -1
- data/lib/labclient/jobs/keep.rb +1 -1
- data/lib/labclient/jobs/play.rb +1 -1
- data/lib/labclient/jobs/trace.rb +2 -2
- data/lib/labclient/klass.rb +3 -1
- data/lib/labclient/overview.rb +16 -0
- data/lib/labclient/paginated_response.rb +2 -0
- data/lib/labclient/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a76c9e9a1408f2c357f82a955359b36b16341f2c83cdd4d3224a90fea884acf
|
4
|
+
data.tar.gz: 8348d2cf615d5b3911ce71f77f71830ba5020015a02d43e4bac6c572105131be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1072af5523d2a6773e329d6674a35f3122eadc488b0961b90b38e9c7b79b5f6cfe516909b16a54f3ad39e227c0a920462cc2b0353b9bd95dbd1e4ce216c8b15b
|
7
|
+
data.tar.gz: e4917da6a4d9d202604fc11b54d6d36f0ec675b2faef38ebbcf9529d9cfb56d883d64508b538dcf3cfb7d8c0c82434ad33fc5a7d3570a2bc7ecc961e64946191
|
data/lib/labclient.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# Public Gems
|
2
2
|
require 'oj'
|
3
|
-
require 'pry'
|
4
3
|
require 'typhoeus'
|
5
4
|
require 'active_support/all'
|
6
5
|
require 'amazing_print'
|
@@ -860,7 +859,7 @@ require 'labclient/generator/generator'
|
|
860
859
|
require 'labclient/generator/wizard'
|
861
860
|
|
862
861
|
# Dynamically Require Templates (Simplify new template creation)
|
863
|
-
Dir[File.dirname(__FILE__)
|
862
|
+
Dir["#{File.dirname(__FILE__)}/labclient/generator/templates/*.rb"].sort.each { |file| require file }
|
864
863
|
|
865
864
|
# I am Very Last
|
866
865
|
require 'labclient/client'
|
@@ -2,46 +2,40 @@
|
|
2
2
|
module LabClient
|
3
3
|
# Shared Methods
|
4
4
|
module AccessLevel
|
5
|
+
HUMAN_ACCESS_LEVELS = {
|
6
|
+
0 => :none,
|
7
|
+
10 => :guest,
|
8
|
+
20 => :reporter,
|
9
|
+
30 => :developer,
|
10
|
+
40 => :maintainer,
|
11
|
+
50 => :owner,
|
12
|
+
60 => :admin
|
13
|
+
}.freeze
|
14
|
+
|
15
|
+
MACHINE_ACCESS_LEVELS = {
|
16
|
+
none: 0,
|
17
|
+
guest: 10,
|
18
|
+
reporter: 20,
|
19
|
+
developer: 30,
|
20
|
+
maintainer: 40,
|
21
|
+
owner: 50,
|
22
|
+
admin: 60
|
23
|
+
}.freeze
|
24
|
+
|
5
25
|
def human_access_level(level = 10)
|
6
|
-
|
7
|
-
when 0 then :none
|
8
|
-
when 10 then :guest
|
9
|
-
when 20 then :reporter
|
10
|
-
when 30 then :developer
|
11
|
-
when 40 then :maintainer
|
12
|
-
when 50 then :owner
|
13
|
-
when 60 then :admin
|
14
|
-
end
|
26
|
+
HUMAN_ACCESS_LEVELS[level]
|
15
27
|
end
|
16
28
|
|
17
29
|
def machine_access_level(level = :developer)
|
18
|
-
|
19
|
-
when :none then 0
|
20
|
-
when :guest then 10
|
21
|
-
when :reporter then 20
|
22
|
-
when :developer then 30
|
23
|
-
when :maintainer then 40
|
24
|
-
when :owner then 50
|
25
|
-
when :admin then 60
|
26
|
-
end
|
30
|
+
MACHINE_ACCESS_LEVELS[level]
|
27
31
|
end
|
28
32
|
|
29
33
|
def machine_protected_access_level(level = :developer)
|
30
|
-
|
31
|
-
when :none then 0
|
32
|
-
when :developer then 30
|
33
|
-
when :maintainer then 40
|
34
|
-
when :admin then 60
|
35
|
-
end
|
34
|
+
MACHINE_ACCESS_LEVELS[level]
|
36
35
|
end
|
37
36
|
|
38
37
|
def human_protected_access_level(level = 10)
|
39
|
-
|
40
|
-
when 0 then :none
|
41
|
-
when 30 then :developer
|
42
|
-
when 40 then :maintainer
|
43
|
-
when 60 then :admin
|
44
|
-
end
|
38
|
+
HUMAN_ACCESS_LEVELS[level]
|
45
39
|
end
|
46
40
|
end
|
47
41
|
end
|
data/lib/labclient/client.rb
CHANGED
@@ -111,22 +111,23 @@ module LabClient
|
|
111
111
|
|
112
112
|
def prompt_for_url
|
113
113
|
print 'Enter GitLab URL (e.g. https://gitlab.com): '
|
114
|
-
@settings[:url] =
|
114
|
+
@settings[:url] = $stdin.gets.chomp
|
115
115
|
raise 'LabClient Error - Missing URL!' if @settings[:url].blank?
|
116
116
|
end
|
117
117
|
|
118
118
|
def prompt_for_token
|
119
119
|
print 'Enter Personal Access Token: '
|
120
|
-
@settings[:token] =
|
120
|
+
@settings[:token] = $stdin.gets.chomp
|
121
121
|
end
|
122
122
|
|
123
123
|
def unspecified_defaults
|
124
124
|
@settings[:paginate] = true if @settings[:paginate].nil?
|
125
125
|
@settings[:ssl_verify] = true if @settings[:ssl_verify].nil?
|
126
|
+
@settings[:quiet] = false if @settings[:quiet].nil?
|
126
127
|
end
|
127
128
|
|
128
129
|
def home_file
|
129
|
-
ENV['HOME']
|
130
|
+
"#{ENV['HOME']}/.gitlab-labclient"
|
130
131
|
end
|
131
132
|
|
132
133
|
# Easier Profile Name Access
|
@@ -173,7 +174,7 @@ module LabClient
|
|
173
174
|
|
174
175
|
process resp
|
175
176
|
rescue LabClient::Error => e
|
176
|
-
puts e.message
|
177
|
+
puts e.message unless settings[:quiet]
|
177
178
|
resp
|
178
179
|
end
|
179
180
|
|
data/lib/labclient/docs.rb
CHANGED
@@ -26,11 +26,11 @@ module LabClient
|
|
26
26
|
# ---------------------------------
|
27
27
|
|
28
28
|
# Klass Helper
|
29
|
-
def help
|
29
|
+
def help(&block)
|
30
30
|
# require 'active_support/inflector'
|
31
31
|
@group_name ||= group_name.pluralize
|
32
32
|
doc 'Reference' do
|
33
|
-
|
33
|
+
block.call
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
@@ -85,10 +85,10 @@ module LabClient
|
|
85
85
|
subnav = subgroup.gsub(' ', '_')
|
86
86
|
|
87
87
|
# Title
|
88
|
-
subnav +=
|
88
|
+
subnav += "_#{@result[:title].gsub(' ', '_')}" if @result.key? :title
|
89
89
|
|
90
90
|
@result[:nav] = nav
|
91
|
-
@result[:nav] +=
|
91
|
+
@result[:nav] += "-#{subnav}" if subnav
|
92
92
|
end
|
93
93
|
|
94
94
|
def doc(subgroup)
|
@@ -42,7 +42,7 @@ module LabClient
|
|
42
42
|
|
43
43
|
def projects(query = {})
|
44
44
|
# Details Query Includes Projects
|
45
|
-
if query.empty? && !@table
|
45
|
+
if query.empty? && !@table[:projects].blank?
|
46
46
|
@table[:projects].map { |project| LabClient::Project.new(project, response, client) }
|
47
47
|
else
|
48
48
|
client.groups.projects(id, query)
|
@@ -14,6 +14,16 @@ module LabClient
|
|
14
14
|
# User Fields
|
15
15
|
user_attrs %i[closed_by author assignee]
|
16
16
|
|
17
|
+
# Via State Events
|
18
|
+
def close
|
19
|
+
client.issues.update(project_id, iid, state_event: :close)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Via State Events
|
23
|
+
def reopen
|
24
|
+
client.issues.update(project_id, iid, state_event: :reopen)
|
25
|
+
end
|
26
|
+
|
17
27
|
def update(query)
|
18
28
|
client.issues.update(project_id, iid, query)
|
19
29
|
end
|
@@ -18,19 +18,37 @@ module LabClient
|
|
18
18
|
|-------------------------------------------|----------------|----------|--------------|
|
19
19
|
| title | string | no | The title of an issue |
|
20
20
|
| description | string | no | The description of an issue. Limited to 1,048,576 characters. |
|
21
|
+
|
22
|
+
|
21
23
|
DOC
|
22
24
|
end
|
23
25
|
|
24
26
|
doc 'Update' do
|
25
|
-
|
27
|
+
title 'Close / Reopen'
|
28
|
+
markdown <<~DOC
|
29
|
+
Closing/Reopening of issues is handled via state_events. Either :close, or :reopen. The issue objects themselves also have helpers `reopen` `close`.
|
30
|
+
DOC
|
31
|
+
|
26
32
|
example 'client.issues.update(5, 1, state_event: :close)'
|
27
33
|
end
|
28
34
|
|
35
|
+
doc 'Update' do
|
36
|
+
example 'client.issues.update(5, 1, state_event: :reopen)'
|
37
|
+
end
|
38
|
+
|
39
|
+
doc 'Update' do
|
40
|
+
desc 'Through Issue Object'
|
41
|
+
example <<~DOC
|
42
|
+
issue = client.issues.show(5,1)
|
43
|
+
issue.close
|
44
|
+
DOC
|
45
|
+
end
|
46
|
+
|
29
47
|
doc 'Update' do
|
30
48
|
desc 'Through Issue Object'
|
31
49
|
example <<~DOC
|
32
50
|
issue = client.issues.show(5,1)
|
33
|
-
issue.
|
51
|
+
issue.reopen
|
34
52
|
DOC
|
35
53
|
end
|
36
54
|
|
data/lib/labclient/jobs/keep.rb
CHANGED
data/lib/labclient/jobs/play.rb
CHANGED
data/lib/labclient/jobs/trace.rb
CHANGED
@@ -20,14 +20,14 @@ module LabClient
|
|
20
20
|
desc 'via Job'
|
21
21
|
example <<~DOC
|
22
22
|
job = client.jobs.show(264,1)
|
23
|
-
job.trace
|
23
|
+
job.trace #=> String
|
24
24
|
DOC
|
25
25
|
end
|
26
26
|
|
27
27
|
def trace(project_id, job_id)
|
28
28
|
job_id = format_id(job_id)
|
29
29
|
project_id = format_id(project_id)
|
30
|
-
|
30
|
+
client.request(:get, "projects/#{project_id}/jobs/#{job_id}/trace")
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
data/lib/labclient/klass.rb
CHANGED
@@ -31,7 +31,7 @@ module LabClient
|
|
31
31
|
next unless (opt[:name] + opt[:text]).include? help_filter.to_s
|
32
32
|
end
|
33
33
|
|
34
|
-
puts
|
34
|
+
puts " #{opt[:name]}"
|
35
35
|
puts " #{opt[:text]}\n"
|
36
36
|
end
|
37
37
|
end
|
@@ -97,6 +97,7 @@ module LabClient
|
|
97
97
|
self
|
98
98
|
end
|
99
99
|
|
100
|
+
# rubocop:disable Lint/MissingSuper
|
100
101
|
def initialize(hash = nil, response = nil, client = nil)
|
101
102
|
@client = client
|
102
103
|
@response = response
|
@@ -107,6 +108,7 @@ module LabClient
|
|
107
108
|
@table[k] = v
|
108
109
|
end
|
109
110
|
end
|
111
|
+
# rubocop:enable Lint/MissingSuper
|
110
112
|
|
111
113
|
# Forward response success
|
112
114
|
def success?
|
data/lib/labclient/overview.rb
CHANGED
@@ -291,6 +291,22 @@ module LabClient
|
|
291
291
|
DOC
|
292
292
|
end
|
293
293
|
|
294
|
+
doc 'Other' do
|
295
|
+
title 'Quiet'
|
296
|
+
desc 'Error messages by default are printed to STDOUT. This can be supressed via the :quiet setting'
|
297
|
+
|
298
|
+
example <<~DOC
|
299
|
+
client = LabClient::Client.new(
|
300
|
+
url: 'https://gitlab.labclient',
|
301
|
+
token: 'gitlab api token',
|
302
|
+
quiet: true
|
303
|
+
)
|
304
|
+
|
305
|
+
# Or after the init
|
306
|
+
client.settings[:quiet] = true
|
307
|
+
DOC
|
308
|
+
end
|
309
|
+
|
294
310
|
doc 'Other' do
|
295
311
|
title 'Curl'
|
296
312
|
desc 'Sometimes you just wana have a curl example to test or send someone'
|
@@ -40,7 +40,9 @@ module LabClient
|
|
40
40
|
DOC
|
41
41
|
end
|
42
42
|
|
43
|
+
# rubocop:disable Lint/MissingSuper
|
43
44
|
def respond_to_missing?(method_name, include_private = false); end
|
45
|
+
# rubocop:enable Lint/MissingSuper
|
44
46
|
|
45
47
|
def each_page(&block)
|
46
48
|
yield @array # This will eventually be the whole list
|
data/lib/labclient/version.rb
CHANGED
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.2.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: 2020-08-
|
11
|
+
date: 2020-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|