labclient 0.1.5 → 0.2.0

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
2
  SHA256:
3
- metadata.gz: 6891782100fb734939767870fa735c9a0f34127582767b4b67c47bdad1f64646
4
- data.tar.gz: 503518a6a45eba73b86bf44c8997d969cd78396210943753c59e330fe06b3be4
3
+ metadata.gz: 8a76c9e9a1408f2c357f82a955359b36b16341f2c83cdd4d3224a90fea884acf
4
+ data.tar.gz: 8348d2cf615d5b3911ce71f77f71830ba5020015a02d43e4bac6c572105131be
5
5
  SHA512:
6
- metadata.gz: b8f5c439041953cf54681ead1caddc945e913d397cfb3b5b12d3abe81415bcebe0878c5cf13f4c541c1bc7481035d490144d429ac0e37adb82f02da21199f906
7
- data.tar.gz: d160894003a7d1e48fbc952a6f3e8c27de913816162938b4b77bb67114e3294e04ce46ef866e08ca0696e6cbbb4f2762d7f811cee6721f6b8c4c447fc22e6c85
6
+ metadata.gz: 1072af5523d2a6773e329d6674a35f3122eadc488b0961b90b38e9c7b79b5f6cfe516909b16a54f3ad39e227c0a920462cc2b0353b9bd95dbd1e4ce216c8b15b
7
+ data.tar.gz: e4917da6a4d9d202604fc11b54d6d36f0ec675b2faef38ebbcf9529d9cfb56d883d64508b538dcf3cfb7d8c0c82434ad33fc5a7d3570a2bc7ecc961e64946191
@@ -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__) + '/labclient/generator/templates/*.rb'].sort.each { |file| require 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
- case level
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
- case level
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
- case level
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
- case level
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
@@ -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] = STDIN.gets.chomp
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] = STDIN.gets.chomp
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'] + '/.gitlab-labclient'
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
 
@@ -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
- yield
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 += '_' + @result[:title].gsub(' ', '_') if @result.key? :title
88
+ subnav += "_#{@result[:title].gsub(' ', '_')}" if @result.key? :title
89
89
 
90
90
  @result[:nav] = nav
91
- @result[:nav] += '-' + subnav if subnav
91
+ @result[:nav] += "-#{subnav}" if subnav
92
92
  end
93
93
 
94
94
  def doc(subgroup)
@@ -74,7 +74,6 @@ module LabClient
74
74
 
75
75
  def generate_group
76
76
  @group = client.groups.create(name: group_name, path: group_path)
77
- # puts "#{@group.name} - #{@group.web_url}"
78
77
  raise 'Unable to Create Group' unless @group.success?
79
78
  end
80
79
  end
@@ -42,7 +42,7 @@ module LabClient
42
42
 
43
43
  def projects(query = {})
44
44
  # Details Query Includes Projects
45
- if query.empty? && !@table.dig(:projects).blank?
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
- desc 'Close Ticket'
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.update(title: "Dew it!")
51
+ issue.reopen
34
52
  DOC
35
53
  end
36
54
 
@@ -3,7 +3,7 @@ module LabClient
3
3
  # Specifics
4
4
  class Jobs < Common
5
5
  doc 'Update' do
6
- title 'Retry'
6
+ title 'Delete'
7
7
  desc 'Delete artifacts of a job. [Project ID, Job ID]'
8
8
  example 'client.jobs.delete(264, 14)'
9
9
  end
@@ -3,7 +3,7 @@ module LabClient
3
3
  # Specifics
4
4
  class Jobs < Common
5
5
  doc 'Update' do
6
- title 'Retry'
6
+ title 'Keep'
7
7
  desc 'Prevents artifacts from being deleted when expiration is set. [Project ID, Job ID]'
8
8
  example 'client.jobs.keep(264, 14)'
9
9
  end
@@ -3,7 +3,7 @@ module LabClient
3
3
  # Specifics
4
4
  class Jobs < Common
5
5
  doc 'Update' do
6
- title 'Retry'
6
+ title 'Play'
7
7
  desc 'Triggers a manual action to start a job. [Project ID, Job ID]'
8
8
  example 'client.jobs.play(264, 14)'
9
9
  end
@@ -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
- puts client.request(:get, "projects/#{project_id}/jobs/#{job_id}/trace")
30
+ client.request(:get, "projects/#{project_id}/jobs/#{job_id}/trace")
31
31
  end
32
32
  end
33
33
  end
@@ -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 ' ' + opt[:name]
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?
@@ -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
@@ -1,3 +1,3 @@
1
1
  module LabClient
2
- VERSION = '0.1.5'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
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.1.5
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-14 00:00:00.000000000 Z
11
+ date: 2020-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport