zypper-onlinesearch 1.0.0 → 1.1.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/.rubocop.yml +81 -0
- data/Gemfile +12 -2
- data/Gemfile.lock +36 -5
- data/LICENSE +674 -0
- data/README.md +8 -104
- data/Rakefile +7 -1
- data/lib/zypper/onlinesearch/cache.rb +20 -23
- data/lib/zypper/onlinesearch/cli.rb +63 -61
- data/lib/zypper/onlinesearch/data.rb +116 -106
- data/lib/zypper/onlinesearch/release.rb +13 -12
- data/lib/zypper/onlinesearch/request.rb +62 -54
- data/lib/zypper/onlinesearch/utils.rb +64 -26
- data/lib/zypper/onlinesearch/version.rb +3 -1
- data/lib/zypper/onlinesearch/view.rb +188 -155
- data/lib/zypper/onlinesearch.rb +69 -90
- data/zypper-onlinesearch.gemspec +20 -23
- metadata +12 -56
- data/.gitignore +0 -11
- data/.travis.yml +0 -5
- data/bin/console +0 -14
- data/bin/setup +0 -8
@@ -1,223 +1,255 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Zypper
|
2
4
|
module Onlinesearch
|
3
|
-
|
4
5
|
module View
|
5
|
-
|
6
|
-
TYPE_COLORS = { experimental: :yellow, supported: :green, community: :red }
|
6
|
+
TYPE_COLORS = { experimental: :yellow, supported: :green, community: :red, unsupported: :bg_red }.freeze
|
7
7
|
SEPARATOR_LENGTH = 100
|
8
8
|
|
9
|
-
|
9
|
+
#
|
10
|
+
# Cache clean view.
|
11
|
+
#
|
10
12
|
class CacheClean
|
11
13
|
def self.reset(size)
|
12
|
-
puts "Cache cleared!
|
14
|
+
puts "Cache cleared! #{size.to_f.to_human.bold.red} freed."
|
13
15
|
end
|
14
16
|
end
|
15
17
|
|
16
|
-
|
17
18
|
module Search
|
18
|
-
|
19
|
+
#
|
20
|
+
# Common methods for the search operation.
|
21
|
+
#
|
19
22
|
class Common
|
20
|
-
|
21
23
|
def self.separator
|
22
|
-
puts
|
24
|
+
puts "-" * SEPARATOR_LENGTH
|
23
25
|
end
|
24
26
|
|
25
27
|
def self.no_packages
|
26
|
-
puts
|
27
|
-
|
28
|
+
puts "#{" " * 3} - | No packages found!"
|
29
|
+
separator
|
28
30
|
end
|
29
31
|
|
30
32
|
def self.no_compatible_packages
|
31
|
-
puts
|
32
|
-
|
33
|
+
puts "#{" " * 3} - | No compatible packages found!"
|
34
|
+
separator
|
33
35
|
end
|
34
36
|
|
35
37
|
def self.parameters(args)
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
38
|
+
engine = args[:engine].bold.red
|
39
|
+
query = args[:query].bold
|
40
|
+
cache = if args[:refresh]
|
41
|
+
"Off".bold
|
42
|
+
elsif args[:cache_time]
|
43
|
+
"#{"On".bold.yellow} (#{args[:cache_time].strftime("%Y-%m-%d %H:%M")})"
|
44
|
+
else
|
45
|
+
"#{"On".bold.yellow} (Now)"
|
46
|
+
end
|
47
|
+
|
48
|
+
puts ""
|
49
|
+
puts "=" * SEPARATOR_LENGTH
|
50
|
+
puts "#{"Parameters:".bold} Engine: #{engine} | Query: #{query} | Cache: #{cache}"
|
51
|
+
puts "=" * SEPARATOR_LENGTH
|
42
52
|
end
|
43
53
|
end
|
44
54
|
|
55
|
+
#
|
56
|
+
# Report view for the search operation.
|
57
|
+
#
|
45
58
|
class Report < Common
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
self.separator
|
59
|
+
def self.header(_args)
|
60
|
+
puts "#{" " * 3} # | Info"
|
61
|
+
separator
|
50
62
|
end
|
51
63
|
|
52
64
|
def self.package(args)
|
53
65
|
name = args[:name]
|
54
|
-
name =
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
66
|
+
name = if name =~ / /
|
67
|
+
name.split.map.with_index do |x, i|
|
68
|
+
x = x.bold if i.zero?
|
69
|
+
x
|
70
|
+
end.join " "
|
71
|
+
else
|
72
|
+
name.bold
|
73
|
+
end
|
74
|
+
|
75
|
+
puts "#{" " * (5 - args[:num].to_s.length)}#{args[:num]} | Page: #{name}"
|
76
|
+
puts "#{" " * 5} | Description: #{args[:description]}"
|
77
|
+
separator
|
59
78
|
end
|
60
79
|
end
|
61
80
|
|
62
|
-
|
81
|
+
#
|
82
|
+
# Table view for search operation.
|
83
|
+
#
|
63
84
|
class Table < Common
|
64
|
-
|
65
85
|
def self.header(args)
|
66
86
|
@@first_col = args[:first_col]
|
67
|
-
|
87
|
+
nl = (args[:first_col] - 4) / 2
|
68
88
|
|
69
|
-
puts
|
70
|
-
|
71
|
-
' | Description '
|
72
|
-
self.separator
|
89
|
+
puts "#{" " * 4}# | #{" " * nl} Page#{" " * nl} | Description"
|
90
|
+
separator
|
73
91
|
end
|
74
92
|
|
75
93
|
def self.package(args)
|
76
94
|
name = args[:name]
|
77
|
-
name =
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
95
|
+
name = if name =~ / /
|
96
|
+
name.split.map.with_index do |x, i|
|
97
|
+
x = x.bold if i.zero?
|
98
|
+
x
|
99
|
+
end.join " "
|
100
|
+
else
|
101
|
+
name.bold
|
102
|
+
end
|
103
|
+
|
104
|
+
nl = 5 - args[:num].to_s.length
|
105
|
+
fl = @@first_col - args[:name].length
|
106
|
+
puts "#{" " * nl}#{args[:num]} | #{name}#{" " * fl} | #{args[:description]}"
|
107
|
+
separator
|
83
108
|
end
|
84
|
-
|
85
109
|
end
|
86
110
|
|
87
111
|
class Urls < Table
|
88
|
-
|
89
112
|
end
|
90
|
-
|
91
113
|
end
|
92
114
|
|
93
|
-
|
94
115
|
module Page
|
95
|
-
|
116
|
+
#
|
117
|
+
# Common view elements for page operation.
|
118
|
+
#
|
96
119
|
class Common
|
97
|
-
|
98
120
|
def self.separator
|
99
|
-
puts
|
121
|
+
puts "-" * SEPARATOR_LENGTH
|
100
122
|
end
|
101
123
|
|
102
124
|
def self.general(args)
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
125
|
+
engine = args[:engine].bold.red
|
126
|
+
distro = args[:distro].bold.blue
|
127
|
+
arch = PageData::FORMATS[args[:architecture]].bold
|
128
|
+
cache = if args[:refresh]
|
129
|
+
"Off".bold
|
130
|
+
elsif args[:cache_time]
|
131
|
+
"#{"On".bold.yellow} (#{args[:cache_time].strftime("%Y-%m-%d %H:%M")})"
|
132
|
+
else
|
133
|
+
"#{"On".bold.yellow} (Now)"
|
134
|
+
end
|
135
|
+
|
136
|
+
puts ""
|
137
|
+
puts "=" * SEPARATOR_LENGTH
|
138
|
+
puts "#{"Parameters: ".bold} Engine: #{engine} | OS: #{distro} | Architecture: #{arch} | Cache: #{cache}"
|
139
|
+
puts "=" * SEPARATOR_LENGTH
|
140
|
+
puts "#{"Name: ".bold}#{args[:name]}"
|
141
|
+
puts "#{"Summary: ".bold}#{args[:short_description]}" if args[:short_description]
|
142
|
+
puts "#{"Description: ".bold}#{args[:description].chomp}" if args[:description]
|
115
143
|
end
|
116
144
|
|
117
145
|
def self.no_packages(compatible)
|
118
|
-
|
119
|
-
puts
|
120
|
-
|
146
|
+
separator
|
147
|
+
puts "#{" " * 3} - | No #{compatible ? "compatible" : ""} packages found!"
|
148
|
+
separator
|
121
149
|
end
|
122
150
|
|
123
151
|
def self.no_item(num)
|
124
|
-
|
125
|
-
puts
|
152
|
+
separator
|
153
|
+
puts "#{" " * 3} - | Invalid item number #{num}"
|
126
154
|
end
|
127
155
|
end
|
128
156
|
|
129
|
-
|
157
|
+
#
|
158
|
+
# Table view for page operation.
|
159
|
+
#
|
130
160
|
class Table < Common
|
131
|
-
|
132
161
|
def self.header(args)
|
133
162
|
@@first_col = args[:first_col]
|
134
163
|
@@second_col = args[:second_col]
|
135
|
-
first_col = ((args[:first_col] - 4) / 2)
|
136
|
-
second_col = (args[:second_col] > 0) ? ((args[:second_col] - 6) / 2) : 0
|
137
164
|
|
138
|
-
|
139
|
-
|
140
|
-
|
165
|
+
first_col = (args[:first_col] - 4) / 2
|
166
|
+
second_col = args[:second_col].positive? ? ((args[:second_col] - 6) / 2) : 0
|
167
|
+
np = " " * 3
|
168
|
+
fcp = " " * first_col
|
169
|
+
scp = " " * second_col
|
170
|
+
|
171
|
+
separator
|
172
|
+
if second_col.positive?
|
173
|
+
puts "#{np} # | Version | #{fcp}Repo #{fcp} | #{scp} Distro #{scp}"
|
141
174
|
else
|
142
|
-
puts "#{
|
175
|
+
puts "#{np} # | Version | #{fcp}Repo"
|
143
176
|
end
|
144
|
-
|
177
|
+
separator
|
145
178
|
end
|
146
179
|
|
147
180
|
def self.package(args)
|
148
|
-
r_length = @@first_col - args[:pack][:repo].to_s.length
|
149
|
-
n_length = args[:num].to_s.length
|
150
|
-
d_length = @@second_col > 0 ? @@second_col - args[:pack][:distro].to_s.length : 0
|
151
|
-
|
152
181
|
num = args[:num].to_s.bold.send(TYPE_COLORS[args[:pack][:type]])
|
153
182
|
repo = args[:pack][:repo].bold.send(TYPE_COLORS[args[:pack][:type]])
|
154
|
-
distro =
|
183
|
+
distro = if args[:args][:distro] == args[:pack][:distro]
|
184
|
+
args[:pack][:distro].bold.blue
|
185
|
+
else
|
186
|
+
args[:pack][:distro]
|
187
|
+
end
|
155
188
|
version = args[:pack][:version].to_s[0..6]
|
156
189
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
190
|
+
nl = 5 - args[:num].to_s.length
|
191
|
+
rl = @@first_col - args[:pack][:repo].to_s.length
|
192
|
+
dl = @@second_col.positive? ? @@second_col - args[:pack][:distro].to_s.length : 0
|
193
|
+
vl = 7 - version.length
|
194
|
+
|
195
|
+
if @@second_col.positive?
|
196
|
+
puts "#{" " * nl}#{num} | #{" " * vl}#{version} | #{repo}#{" " * rl} | #{distro}#{" " * dl}"
|
162
197
|
else
|
163
|
-
puts
|
164
|
-
' | ' + (' ' * ( 7 - version.length )) + version +
|
165
|
-
' | ' + repo.to_s + (' ' * r_length) #+
|
198
|
+
puts "#{" " * nl}#{num} | #{" " * vl}#{version} | #{repo}"
|
166
199
|
end
|
167
|
-
|
168
|
-
self.separator
|
200
|
+
separator
|
169
201
|
end
|
170
|
-
|
171
202
|
end
|
172
203
|
|
173
|
-
|
204
|
+
#
|
205
|
+
# Report view for page operation.
|
206
|
+
#
|
174
207
|
class Report < Common
|
175
|
-
|
176
208
|
def self.header(args)
|
177
209
|
@@second_col = args[:second_col]
|
178
|
-
|
179
|
-
puts "#{
|
180
|
-
|
210
|
+
separator
|
211
|
+
puts "#{" " * 3} # | Info"
|
212
|
+
separator
|
181
213
|
end
|
182
214
|
|
183
215
|
def self.package(args)
|
184
216
|
n_length = args[:num].to_s.length
|
185
|
-
|
186
|
-
#p args
|
187
217
|
num = args[:num].to_s.bold.send(TYPE_COLORS[args[:pack][:type]])
|
188
218
|
repo = args[:pack][:repo].bold.send(TYPE_COLORS[args[:pack][:type]])
|
189
|
-
distro =
|
219
|
+
distro = if args[:args][:distro] == args[:pack][:distro]
|
220
|
+
args[:pack][:distro].bold.blue
|
221
|
+
else
|
222
|
+
args[:pack][:distro]
|
223
|
+
end
|
190
224
|
version = args[:pack][:version].to_s
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
puts
|
195
|
-
|
196
|
-
puts
|
197
|
-
|
225
|
+
type = args[:pack][:type].to_s.capitalize.bold.send(TYPE_COLORS[args[:pack][:type]])
|
226
|
+
prefix = " " * 5
|
227
|
+
|
228
|
+
puts "#{" " * (5 - n_length)}#{num} | Version: #{version}"
|
229
|
+
puts "#{prefix} | Repository: #{repo}"
|
230
|
+
puts "#{prefix} | Distribution: #{distro}" if @@second_col.positive?
|
231
|
+
# puts #{prefix} | Formats: ' + args[:formats].join(', ')
|
232
|
+
puts "#{prefix} | Type: #{type}"
|
233
|
+
separator
|
198
234
|
end
|
199
|
-
|
200
235
|
end
|
201
236
|
|
202
|
-
|
203
237
|
class Urls < Table
|
204
|
-
|
205
238
|
end
|
206
|
-
|
207
|
-
end # Module Page
|
208
|
-
|
239
|
+
end
|
209
240
|
|
210
241
|
module Links
|
211
|
-
|
242
|
+
#
|
243
|
+
# Common class for links view.
|
244
|
+
#
|
212
245
|
class Common < Page::Common
|
213
|
-
|
214
246
|
def self.info_package(args)
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
247
|
+
separator
|
248
|
+
repo = args[:repo].bold.send(TYPE_COLORS[args[:type]])
|
249
|
+
distro = args[:distro].bold
|
250
|
+
ver = args[:version].bold
|
251
|
+
puts "#{"Selected Item:".bold} Repository: #{repo} | Distribution: #{distro} | Version: #{ver}"
|
252
|
+
separator
|
221
253
|
end
|
222
254
|
|
223
255
|
def self.header(args)
|
@@ -225,72 +257,73 @@ module Zypper
|
|
225
257
|
end
|
226
258
|
end
|
227
259
|
|
260
|
+
#
|
261
|
+
# Table view for links operation.
|
262
|
+
#
|
228
263
|
class Table < Common
|
229
|
-
|
230
264
|
def self.header(args)
|
231
265
|
super args
|
232
|
-
|
233
|
-
puts
|
234
|
-
|
266
|
+
separator
|
267
|
+
puts "#{" " * 3} # | Format | Link"
|
268
|
+
separator
|
235
269
|
end
|
236
270
|
|
237
|
-
def self.package(args)
|
238
|
-
end
|
271
|
+
def self.package(args); end
|
239
272
|
|
240
273
|
def self.link(args)
|
241
|
-
|
242
|
-
|
243
|
-
puts
|
244
|
-
|
245
|
-
self.separator
|
274
|
+
nl = args[:num].to_s.length
|
275
|
+
fl = args[:pack][:format].to_s.length
|
276
|
+
puts "#{" " * (5 - nl)}#{args[:num]} | #{" " * (6 - fl)}#{args[:pack][:format]} | #{args[:pack][:link]}"
|
277
|
+
separator
|
246
278
|
end
|
247
279
|
end
|
248
280
|
|
281
|
+
#
|
282
|
+
# Report view for links operation.
|
283
|
+
#
|
249
284
|
class Report < Common
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
self.separator
|
285
|
+
def self.header(_args)
|
286
|
+
separator
|
287
|
+
puts "#{" " * 3} # | Links"
|
288
|
+
separator
|
255
289
|
end
|
256
290
|
|
257
291
|
def self.link(args)
|
258
|
-
alt_format = args[:pack][:format].to_s == PageData::FORMATS[args[:pack][:format]]
|
292
|
+
alt_format = if args[:pack][:format].to_s == PageData::FORMATS[args[:pack][:format]]
|
293
|
+
""
|
294
|
+
else
|
295
|
+
" (#{PageData::FORMATS[args[:pack][:format]]})"
|
296
|
+
end
|
259
297
|
n_length = args[:num].to_s.length
|
260
|
-
puts
|
261
|
-
puts
|
262
|
-
puts
|
298
|
+
puts "#{" " * (5 - n_length)}#{args[:num]} | Format: #{args[:pack][:format].to_s.bold}#{alt_format}"
|
299
|
+
puts "#{" " * 5} | Distribution: #{args[:pack][:distro]}"
|
300
|
+
puts "#{" " * 5} | Link: #{args[:pack][:link]}"
|
263
301
|
|
264
|
-
|
302
|
+
separator
|
265
303
|
end
|
266
304
|
end
|
267
305
|
|
306
|
+
#
|
307
|
+
# URLs view for links operation.
|
308
|
+
#
|
268
309
|
class Urls
|
269
|
-
def self.general(args)
|
270
|
-
end
|
310
|
+
def self.general(args); end
|
271
311
|
|
272
|
-
def self.info_package(args)
|
273
|
-
end
|
312
|
+
def self.info_package(args); end
|
274
313
|
|
275
|
-
def self.header(args)
|
276
|
-
end
|
314
|
+
def self.header(args); end
|
277
315
|
|
278
|
-
def self.separator
|
279
|
-
end
|
316
|
+
def self.separator; end
|
280
317
|
|
281
|
-
def self.package(args)
|
282
|
-
end
|
318
|
+
def self.package(args); end
|
283
319
|
|
284
320
|
def self.link(args)
|
285
321
|
puts args[:pack][:link]
|
286
322
|
end
|
287
323
|
|
288
|
-
def self.no_packages(args)
|
289
|
-
end
|
324
|
+
def self.no_packages(args); end
|
290
325
|
end
|
291
|
-
|
292
|
-
end # Module Links
|
293
|
-
|
326
|
+
end
|
294
327
|
end
|
295
328
|
end
|
296
329
|
end
|