glpl 0.1.0 → 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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/glpl +19 -21
  3. data/lib/glpl.rb +9 -0
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9dda217f7317d692951af87d0e7162f33fbb9f1b
4
- data.tar.gz: 80cbdfaa9b276f685af8ea1971a31a0a7c60fbdd
3
+ metadata.gz: 31cef0efa19e6ef0da7ddcbe28fc9545f0e393be
4
+ data.tar.gz: fc93f4f32e9ede40d6f4d5e86ad3da2f43fb8431
5
5
  SHA512:
6
- metadata.gz: 852efff2121a9cc488359f06a7674a6abcc039a5ab441b1e7ca38f279d5c3615c59b9f5bdcd14ba4db7392d1a1c4e74e795745fd598c125846195e2c8dbb1aa7
7
- data.tar.gz: 54b05ba589e6d824b6dbb0c2d87c546fb42c0f1edf5d6271abcd47f4094167356c2a13da2bf1db89f52c479681732786c365bc80ceaba0b9755c58f8c27472c6
6
+ metadata.gz: 59f365b90d395c9d52b4a91543a3a7b2af1e037ac997953d4151bb6d155dd0aac053bc1671092d52114e8f31cc10b6a5a573ab06ad70125af16f6c267daff687
7
+ data.tar.gz: 5ecc537f9bc2a0b1c127c07d0b2a5c5d9fa25a6f4a186cff31b294f4ec9228d5b7346d2192699c6e72d3355ee2f7b9bfcbe75dd82ec89be0277c2281cefedfad
data/bin/glpl CHANGED
@@ -3,12 +3,15 @@
3
3
  require 'optparse'
4
4
  require 'glpl'
5
5
 
6
+ # Initialize Gitlab's Private Token.
6
7
  private_token = `echo $GITLAB_PRIVATE_TOKEN`.strip()
7
8
  if private_token == "" then
8
9
  puts "Gitlab's Private Token is not defined. Export it to $GITLAB_PRIVATE_TOKEN."
9
10
  exit
10
11
  end
11
12
 
13
+ glpl = GLPL.new(private_token)
14
+
12
15
  if ARGV.length == 0 then
13
16
  puts "Project is not specified. Please specify the project using: $ glpl [PROJECT]."
14
17
  exit
@@ -26,33 +29,28 @@ OptionParser.new do |opts|
26
29
  opts.banner = "Usage: glpl [PROJECT_NAME] [options]"
27
30
 
28
31
  opts.on("-p", "--pipeline ID", Integer, "Pipeline ID") do |pipeline_id|
29
- options[:pipeline_id] = pipeline_id
32
+ for job in glpl.jobs(project_id, pipeline_id) do
33
+ printf("%s %s %s\n",
34
+ job.id.to_s.ljust(10),
35
+ job.name.ljust(60),
36
+ job.status.ljust(10)
37
+ )
38
+ end
39
+ exit
30
40
  end
31
41
 
32
42
  opts.on("-r", "--retry ID", "Retry a given pipeline") do |pipeline_id|
33
- options[:pipeline_id] = pipeline_id
34
- options[:retry] = true
43
+ glpl.retry(project_id, pipeline_id)
44
+ printf("Sucessfully retried Pipeline#%s.\n", pipeline_id)
45
+ exit
35
46
  end
36
- end.parse!
37
47
 
38
- glpl = GLPL.new(private_token)
39
-
40
- if options.key?(:retry) then
41
- glpl.retry(project_id, options[:pipeline_id])
42
- printf("Sucessfully retried Pipeline#%s.\n", options[:pipeline_id])
43
- exit
44
- end
45
-
46
- if options.key?(:pipeline_id) then
47
- for job in glpl.jobs(project_id, options[:pipeline_id]) do
48
- printf("%s %s %s\n",
49
- job.id.to_s.ljust(10),
50
- job.name.ljust(60),
51
- job.status.ljust(10)
52
- )
48
+ opts.on("-c", "--cancel ID", "Cancel a given pipeline") do |pipeline_id|
49
+ glpl.cancel(project_id, pipeline_id)
50
+ printf("Sucessfully canceled Pipeline#%s.\n", pipeline_id)
51
+ exit
53
52
  end
54
- exit
55
- end
53
+ end.parse!
56
54
 
57
55
  for pipeline in glpl.pipelines(project_id) do
58
56
  printf("%s %s %s\n",
@@ -38,6 +38,15 @@ class GLPL
38
38
  GLPL::Pipeline.new(request("/#{project_id}/pipelines/#{pipeline_id}/retry", :post))
39
39
  end
40
40
 
41
+ # Cancels a pipeline.
42
+ #
43
+ # Params:
44
+ # +project_id+:: +Integer+ Gitlab's project ID.
45
+ # +pipeline_id+:: +Integer+ The pipeline's ID.
46
+ def cancel(project_id, pipeline_id)
47
+ GLPL::Pipeline.new(request("/#{project_id}/pipelines/#{pipeline_id}/cancel", :post))
48
+ end
49
+
41
50
  # Makes an HTTP Requests to Gitlab's API and returns the response as JSON.
42
51
  # Params:
43
52
  # +endpoint+:: +String+ which represents the API's endpoint to be contacted.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glpl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dino
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-08 00:00:00.000000000 Z
11
+ date: 2018-10-27 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Gitlab Pipelines on your command line.
14
14
  email: dinojoaocosta@gmail.com