getv 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/exe/getv +89 -118
  3. data/lib/getv/version.rb +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d3f1afae07aeb895e7cac0ef722a2a0c12008681ee09bfa724cdfc692accba75
4
- data.tar.gz: 67ea05289cee910c2c53db2fa337cc6a20bc2459d407bf5bf995d01b5cea41a5
3
+ metadata.gz: 76b665201a4d7f1ecdaa9047121a3b4fece0805d5de821b9acf636cc9f82a506
4
+ data.tar.gz: 620003975f2b25a1d6df14edfda536e7710cfbcbd6ab4f329c710c4ee820a281
5
5
  SHA512:
6
- metadata.gz: e33576d51b5d6a32d39f54421e87d458542b3ce38a52f2e8b5182d4c38d54257b5e4a75469f96d15df8ab34c0546e03a153e7133138dd5d2dd9b63258d0eaa02
7
- data.tar.gz: da5ed58b41e029f1979147c6d3d614bdc9841f267fc56e37f9b4775b7f7c8dc1836141f57e477156876b03b2daa9ac518445364386f4e85802728e0981a7577e
6
+ metadata.gz: 61f05289eca59aab2435330d79d849876cf2e3d160d214899a4644c11cba109a4337a5b9bac8c905a54e020b06362201befe63302a5d513efe4f07e82c2fc6fb
7
+ data.tar.gz: 56c9e45f319a0bd94bd27b15053f782731b0f08d6b94c55fbfc8d449b80a3fb8deb96af6fd7e51403305b4875f0231986bb114834b069e243027df56a4f671aa
data/exe/getv CHANGED
@@ -7,26 +7,16 @@ require 'gli'
7
7
  module Getv
8
8
  # cli class
9
9
  class Cli
10
- def self.output(package, latest: false, json: false) # rubocop:disable Metrics/MethodLength
11
- if latest
12
- if json
13
- require 'json'
14
- puts({
15
- 'name' => package.name,
16
- 'latest_version' => package.latest_version
17
- }.to_json)
18
- else
19
- puts package.latest_version
20
- end
21
- elsif json
10
+ def self.output(package, latest: false, json: false)
11
+ key = latest ? 'latest_version' : 'versions'
12
+ result = package.send(key)
13
+
14
+ if json
22
15
  require 'json'
23
- puts({
24
- 'name' => package.name,
25
- 'versions' => package.versions
26
- }.to_json)
27
- else
28
- puts package.versions
16
+ result = { 'name' => package.name, key => result }.to_json
29
17
  end
18
+
19
+ puts result
30
20
  end
31
21
  end
32
22
  end
@@ -47,7 +37,7 @@ class App # rubocop:disable Metrics/ClassLength
47
37
 
48
38
  desc 'Get package versions from a Docker or OCI container image registry'
49
39
  arg_name 'package_name'
50
- command :docker do |c| # rubocop:disable Metrics/BlockLength
40
+ command :docker do |c|
51
41
  defaults = (Getv::Package.new 'name', type: c.name.to_s).opts
52
42
  c.flag %i[select_search], desc: 'Regex version selection search', default_value: defaults[:select_search]
53
43
  c.flag %i[select_replace], desc: 'Regex version selection replace', default_value: defaults[:select_replace]
@@ -61,18 +51,16 @@ class App # rubocop:disable Metrics/ClassLength
61
51
  default_value: "'<repo>' if package_name is in format '<owner>/<repo>', otherwise just package_name" # rubocop:disable Layout/LineLength
62
52
  c.flag %i[url], desc: 'URL', default_value: defaults[:url]
63
53
  c.action do |global_options, options, args|
64
- if args.size == 1
65
- opts = global_options.merge(options)
66
- opts = opts.slice :select_search, :select_replace, :reject, :semantic_only, :semantic_select, :owner, :repo,
67
- :url
68
- opts = opts.delete_if { |k, v| v.nil? || v == c.flags[k].default_value }
69
- opts[:semantic_only] = !options[:invalid_versions]
70
- opts[:semantic_select] = opts[:semantic_select].split(',') unless opts.fetch(:semantic_select, nil).nil?
71
- package = Getv::Package.new args[0], { type: c.name.to_s }.merge(opts)
72
- Getv::Cli.output(package, latest: global_options[:latest], json: global_options[:json])
73
- else
74
- help_now!
75
- end
54
+ help_now! unless args.size == 1
55
+
56
+ opts = global_options.merge(options)
57
+ opts = opts.slice :select_search, :select_replace, :reject, :semantic_only, :semantic_select, :owner, :repo,
58
+ :url
59
+ opts = opts.delete_if { |k, v| v.nil? || v == c.flags[k].default_value }
60
+ opts[:semantic_only] = !options[:invalid_versions]
61
+ opts[:semantic_select] = opts[:semantic_select].split(',') unless opts.fetch(:semantic_select, nil).nil?
62
+ package = Getv::Package.new args[0], { type: c.name.to_s }.merge(opts)
63
+ Getv::Cli.output(package, latest: global_options[:latest], json: global_options[:json])
76
64
  end
77
65
  end
78
66
 
@@ -87,17 +75,15 @@ class App # rubocop:disable Metrics/ClassLength
87
75
  c.flag %i[semantic_select], desc: 'Semantic version selection (comma delimited)',
88
76
  default_value: defaults[:semantic_select]
89
77
  c.action do |global_options, options, args|
90
- if args.size == 1
91
- opts = global_options.merge(options)
92
- opts = opts.slice :select_search, :select_replace, :reject, :semantic_only, :semantic_select
93
- opts = opts.delete_if { |k, v| v.nil? || v == c.flags[k].default_value }
94
- opts[:semantic_only] = !options[:invalid_versions]
95
- opts[:semantic_select] = opts[:semantic_select].split(',') unless opts.fetch(:semantic_select, nil).nil?
96
- package = Getv::Package.new args[0], { type: c.name.to_s }.merge(opts)
97
- Getv::Cli.output(package, latest: global_options[:latest], json: global_options[:json])
98
- else
99
- help_now!
100
- end
78
+ help_now! unless args.size == 1
79
+
80
+ opts = global_options.merge(options)
81
+ opts = opts.slice :select_search, :select_replace, :reject, :semantic_only, :semantic_select
82
+ opts = opts.delete_if { |k, v| v.nil? || v == c.flags[k].default_value }
83
+ opts[:semantic_only] = !options[:invalid_versions]
84
+ opts[:semantic_select] = opts[:semantic_select].split(',') unless opts.fetch(:semantic_select, nil).nil?
85
+ package = Getv::Package.new args[0], { type: c.name.to_s }.merge(opts)
86
+ Getv::Cli.output(package, latest: global_options[:latest], json: global_options[:json])
101
87
  end
102
88
  end
103
89
 
@@ -113,17 +99,14 @@ class App # rubocop:disable Metrics/ClassLength
113
99
  default_value: defaults[:semantic_select]
114
100
  c.flag %i[url], desc: 'URL', default_value: defaults[:url]
115
101
  c.action do |global_options, options, args|
116
- if args.size == 1
117
- opts = global_options.merge(options)
118
- opts = opts.slice :select_search, :select_replace, :reject, :semantic_only, :semantic_select, :url
119
- opts = opts.delete_if { |k, v| v.nil? || v == c.flags[k].default_value }
120
- opts[:semantic_only] = !options[:invalid_versions]
121
- opts[:semantic_select] = opts[:semantic_select].split(',') unless opts.fetch(:semantic_select, nil).nil?
122
- package = Getv::Package.new args[0], { type: c.name.to_s }.merge(opts)
123
- Getv::Cli.output(package, latest: global_options[:latest], json: global_options[:json])
124
- else
125
- help_now!
126
- end
102
+ help_now! unless args.size == 1
103
+
104
+ opts = opts.slice :select_search, :select_replace, :reject, :semantic_only, :semantic_select, :url
105
+ opts = opts.delete_if { |k, v| v.nil? || v == c.flags[k].default_value }
106
+ opts[:semantic_only] = !options[:invalid_versions]
107
+ opts[:semantic_select] = opts[:semantic_select].split(',') unless opts.fetch(:semantic_select, nil).nil?
108
+ package = Getv::Package.new args[0], { type: c.name.to_s }.merge(opts)
109
+ Getv::Cli.output(package, latest: global_options[:latest], json: global_options[:json])
127
110
  end
128
111
  end
129
112
 
@@ -140,15 +123,13 @@ class App # rubocop:disable Metrics/ClassLength
140
123
  default_value: "'<repo>' if package_name is in format '<owner>/<repo>', otherwise just package_name" # rubocop:disable Layout/LineLength
141
124
  c.flag %i[branch], desc: 'Repository branch', default_value: defaults[:branch]
142
125
  c.action do |global_options, options, args|
143
- if args.size == 1
144
- opts = global_options.merge(options)
145
- opts = opts.slice :select_search, :select_replace, :reject, :owner, :repo, :branch
146
- opts = opts.delete_if { |k, v| v.nil? || v == c.flags[k].default_value }
147
- package = Getv::Package.new args[0], { type: c.name.to_s }.merge(opts)
148
- Getv::Cli.output(package, latest: global_options[:latest], json: global_options[:json])
149
- else
150
- help_now!
151
- end
126
+ help_now! unless args.size == 1
127
+
128
+ opts = global_options.merge(options)
129
+ opts = opts.slice :select_search, :select_replace, :reject, :owner, :repo, :branch
130
+ opts = opts.delete_if { |k, v| v.nil? || v == c.flags[k].default_value }
131
+ package = Getv::Package.new args[0], { type: c.name.to_s }.merge(opts)
132
+ Getv::Cli.output(package, latest: global_options[:latest], json: global_options[:json])
152
133
  end
153
134
  end
154
135
 
@@ -167,17 +148,15 @@ class App # rubocop:disable Metrics/ClassLength
167
148
  c.flag %i[repo], desc: 'Repository name',
168
149
  default_value: "'<repo>' if package_name is in format '<owner>/<repo>', otherwise just package_name" # rubocop:disable Layout/LineLength
169
150
  c.action do |global_options, options, args|
170
- if args.size == 1
171
- opts = global_options.merge(options)
172
- opts = opts.slice :select_search, :select_replace, :reject, :semantic_only, :semantic_select, :owner, :repo
173
- opts = opts.delete_if { |k, v| v.nil? || v == c.flags[k].default_value }
174
- opts[:semantic_only] = !options[:invalid_versions]
175
- opts[:semantic_select] = opts[:semantic_select].split(',') unless opts.fetch(:semantic_select, nil).nil?
176
- package = Getv::Package.new args[0], { type: c.name.to_s }.merge(opts)
177
- Getv::Cli.output(package, latest: global_options[:latest], json: global_options[:json])
178
- else
179
- help_now!
180
- end
151
+ help_now! unless args.size == 1
152
+
153
+ opts = global_options.merge(options)
154
+ opts = opts.slice :select_search, :select_replace, :reject, :semantic_only, :semantic_select, :owner, :repo
155
+ opts = opts.delete_if { |k, v| v.nil? || v == c.flags[k].default_value }
156
+ opts[:semantic_only] = !options[:invalid_versions]
157
+ opts[:semantic_select] = opts[:semantic_select].split(',') unless opts.fetch(:semantic_select, nil).nil?
158
+ package = Getv::Package.new args[0], { type: c.name.to_s }.merge(opts)
159
+ Getv::Cli.output(package, latest: global_options[:latest], json: global_options[:json])
181
160
  end
182
161
  end
183
162
 
@@ -196,17 +175,15 @@ class App # rubocop:disable Metrics/ClassLength
196
175
  c.flag %i[repo], desc: 'Repository name',
197
176
  default_value: "'<repo>' if package_name is in format '<owner>/<repo>', otherwise just package_name" # rubocop:disable Layout/LineLength
198
177
  c.action do |global_options, options, args|
199
- if args.size == 1
200
- opts = global_options.merge(options)
201
- opts = opts.slice :select_search, :select_replace, :reject, :semantic_only, :semantic_select, :owner, :repo
202
- opts = opts.delete_if { |k, v| v.nil? || v == c.flags[k].default_value }
203
- opts[:semantic_only] = !options[:invalid_versions]
204
- opts[:semantic_select] = opts[:semantic_select].split(',') unless opts.fetch(:semantic_select, nil).nil?
205
- package = Getv::Package.new args[0], { type: c.name.to_s }.merge(opts)
206
- Getv::Cli.output(package, latest: global_options[:latest], json: global_options[:json])
207
- else
208
- help_now!
209
- end
178
+ help_now! unless args.size == 1
179
+
180
+ opts = global_options.merge(options)
181
+ opts = opts.slice :select_search, :select_replace, :reject, :semantic_only, :semantic_select, :owner, :repo
182
+ opts = opts.delete_if { |k, v| v.nil? || v == c.flags[k].default_value }
183
+ opts[:semantic_only] = !options[:invalid_versions]
184
+ opts[:semantic_select] = opts[:semantic_select].split(',') unless opts.fetch(:semantic_select, nil).nil?
185
+ package = Getv::Package.new args[0], { type: c.name.to_s }.merge(opts)
186
+ Getv::Cli.output(package, latest: global_options[:latest], json: global_options[:json])
210
187
  end
211
188
  end
212
189
 
@@ -224,18 +201,16 @@ class App # rubocop:disable Metrics/ClassLength
224
201
  c.switch %i[link_value], desc: 'Use the value (target) of links rather than the content (display text)',
225
202
  negatable: false, default_value: false
226
203
  c.action do |global_options, options, args|
227
- if args.size == 1
228
- opts = global_options.merge(options)
229
- opts = opts.slice :select_search, :select_replace, :reject, :semantic_only, :semantic_select, :url
230
- opts = opts.delete_if { |k, v| v.nil? || v == c.flags[k].default_value }
231
- opts[:link] == 'value' if options[:link_value]
232
- opts[:semantic_only] = !options[:invalid_versions]
233
- opts[:semantic_select] = opts[:semantic_select].split(',') unless opts.fetch(:semantic_select, nil).nil?
234
- package = Getv::Package.new args[0], { type: c.name.to_s }.merge(opts)
235
- Getv::Cli.output(package, latest: global_options[:latest], json: global_options[:json])
236
- else
237
- help_now!
238
- end
204
+ help_now! unless args.size == 1
205
+
206
+ opts = global_options.merge(options)
207
+ opts = opts.slice :select_search, :select_replace, :reject, :semantic_only, :semantic_select, :url
208
+ opts = opts.delete_if { |k, v| v.nil? || v == c.flags[k].default_value }
209
+ opts[:link] == 'value' if options[:link_value]
210
+ opts[:semantic_only] = !options[:invalid_versions]
211
+ opts[:semantic_select] = opts[:semantic_select].split(',') unless opts.fetch(:semantic_select, nil).nil?
212
+ package = Getv::Package.new args[0], { type: c.name.to_s }.merge(opts)
213
+ Getv::Cli.output(package, latest: global_options[:latest], json: global_options[:json])
239
214
  end
240
215
  end
241
216
 
@@ -250,17 +225,15 @@ class App # rubocop:disable Metrics/ClassLength
250
225
  c.flag %i[semantic_select], desc: 'Semantic version selection (comma delimited)',
251
226
  default_value: defaults[:semantic_select]
252
227
  c.action do |global_options, options, args|
253
- if args.size == 1
254
- opts = global_options.merge(options)
255
- opts = opts.slice :select_search, :select_replace, :reject, :semantic_only, :semantic_select
256
- opts = opts.delete_if { |k, v| v.nil? || v == c.flags[k].default_value }
257
- opts[:semantic_only] = !options[:invalid_versions]
258
- opts[:semantic_select] = opts[:semantic_select].split(',') unless opts.fetch(:semantic_select, nil).nil?
259
- package = Getv::Package.new args[0], { type: c.name.to_s }.merge(opts)
260
- Getv::Cli.output(package, latest: global_options[:latest], json: global_options[:json])
261
- else
262
- help_now!
263
- end
228
+ help_now! unless args.size == 1
229
+
230
+ opts = global_options.merge(options)
231
+ opts = opts.slice :select_search, :select_replace, :reject, :semantic_only, :semantic_select
232
+ opts = opts.delete_if { |k, v| v.nil? || v == c.flags[k].default_value }
233
+ opts[:semantic_only] = !options[:invalid_versions]
234
+ opts[:semantic_select] = opts[:semantic_select].split(',') unless opts.fetch(:semantic_select, nil).nil?
235
+ package = Getv::Package.new args[0], { type: c.name.to_s }.merge(opts)
236
+ Getv::Cli.output(package, latest: global_options[:latest], json: global_options[:json])
264
237
  end
265
238
  end
266
239
 
@@ -275,17 +248,15 @@ class App # rubocop:disable Metrics/ClassLength
275
248
  c.flag %i[semantic_select], desc: 'Semantic version selection (comma delimited)',
276
249
  default_value: defaults[:semantic_select]
277
250
  c.action do |global_options, options, args|
278
- if args.size == 1
279
- opts = global_options.merge(options)
280
- opts = opts.slice :select_search, :select_replace, :reject, :semantic_only, :semantic_select
281
- opts = opts.delete_if { |k, v| v.nil? || v == c.flags[k].default_value }
282
- opts[:semantic_only] = !options[:invalid_versions]
283
- opts[:semantic_select] = opts[:semantic_select].split(',') unless opts.fetch(:semantic_select, nil).nil?
284
- package = Getv::Package.new args[0], { type: c.name.to_s }.merge(opts)
285
- Getv::Cli.output(package, latest: global_options[:latest], json: global_options[:json])
286
- else
287
- help_now!
288
- end
251
+ help_now! unless args.size == 1
252
+
253
+ opts = global_options.merge(options)
254
+ opts = opts.slice :select_search, :select_replace, :reject, :semantic_only, :semantic_select
255
+ opts = opts.delete_if { |k, v| v.nil? || v == c.flags[k].default_value }
256
+ opts[:semantic_only] = !options[:invalid_versions]
257
+ opts[:semantic_select] = opts[:semantic_select].split(',') unless opts.fetch(:semantic_select, nil).nil?
258
+ package = Getv::Package.new args[0], { type: c.name.to_s }.merge(opts)
259
+ Getv::Cli.output(package, latest: global_options[:latest], json: global_options[:json])
289
260
  end
290
261
  end
291
262
 
data/lib/getv/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Getv
4
- VERSION = '1.3.0'
4
+ VERSION = '1.3.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: getv
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - harbottle
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-26 00:00:00.000000000 Z
11
+ date: 2022-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gli