zypper-onlinesearch 1.1.1 → 1.3.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 +0 -14
- data/Gemfile.lock +52 -39
- data/exe/onlinesearch +1 -0
- data/lib/zypper/onlinesearch/cache.rb +1 -1
- data/lib/zypper/onlinesearch/cli.rb +8 -4
- data/lib/zypper/onlinesearch/data.rb +36 -25
- data/lib/zypper/onlinesearch/request.rb +9 -9
- data/lib/zypper/onlinesearch/utils.rb +94 -29
- data/lib/zypper/onlinesearch/version.rb +1 -1
- data/lib/zypper/onlinesearch/view.rb +15 -13
- data/lib/zypper/onlinesearch.rb +18 -14
- data/zypper-onlinesearch.gemspec +2 -2
- metadata +3 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c1efabb18f7e49b9c21fc06a529bc07e67c73e15bb5ff43cbb574f4cfe69295b
|
|
4
|
+
data.tar.gz: 3a9e48f16004fc4b65b3d34336a1fb56bfd9729716262e1663239ee6a51d86ae
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3d8b1ddd8ed7fe055b357cab2016fcf65039b66261bb6c3f39b4a0600600656b70fd5c0ea8484421d20b1b21b7932a91e8053805d60ee069864f5ebd1ae37ef0
|
|
7
|
+
data.tar.gz: 47b3d94558eab162410fdb46d754b4a9e0aaa18db4a63334f2e741ce01f9233253b3954e031fc14eda6e9f198fb035fa92036f93072f1ad8bc2ddba10fa1d0e9
|
data/.rubocop.yml
CHANGED
|
@@ -56,9 +56,6 @@ Metrics/CyclomaticComplexity:
|
|
|
56
56
|
- './lib/**/onlinesearch.rb'
|
|
57
57
|
- './lib/**/data.rb'
|
|
58
58
|
|
|
59
|
-
Lint/UriEscapeUnescape:
|
|
60
|
-
Enabled: false
|
|
61
|
-
|
|
62
59
|
Metrics/ParameterLists:
|
|
63
60
|
Enabled: true
|
|
64
61
|
Exclude:
|
|
@@ -68,14 +65,3 @@ Security/MarshalLoad:
|
|
|
68
65
|
Enabled: true
|
|
69
66
|
Exclude:
|
|
70
67
|
- './lib/**/cache.rb'
|
|
71
|
-
|
|
72
|
-
Style/SingleLineMethods:
|
|
73
|
-
Enabled: true
|
|
74
|
-
Exclude:
|
|
75
|
-
- './lib/**/utils.rb'
|
|
76
|
-
|
|
77
|
-
Style/FrozenStringLiteralComment:
|
|
78
|
-
Enabled: true
|
|
79
|
-
Exclude:
|
|
80
|
-
- './bin/*'
|
|
81
|
-
- './exe/*'
|
data/Gemfile.lock
CHANGED
|
@@ -1,66 +1,79 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
zypper-onlinesearch (1.
|
|
4
|
+
zypper-onlinesearch (1.3.0)
|
|
5
5
|
iniparse
|
|
6
6
|
nokogiri
|
|
7
7
|
|
|
8
8
|
GEM
|
|
9
9
|
remote: https://rubygems.org/
|
|
10
10
|
specs:
|
|
11
|
-
ast (2.4.
|
|
12
|
-
diff-lcs (1.
|
|
11
|
+
ast (2.4.3)
|
|
12
|
+
diff-lcs (1.6.2)
|
|
13
13
|
iniparse (1.5.0)
|
|
14
|
-
json (2.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
json (2.18.0)
|
|
15
|
+
language_server-protocol (3.17.0.5)
|
|
16
|
+
lint_roller (1.1.0)
|
|
17
|
+
nokogiri (1.18.10-x86_64-linux-gnu)
|
|
18
18
|
racc (~> 1.4)
|
|
19
|
-
parallel (1.
|
|
20
|
-
parser (3.
|
|
19
|
+
parallel (1.27.0)
|
|
20
|
+
parser (3.3.10.0)
|
|
21
21
|
ast (~> 2.4.1)
|
|
22
|
-
|
|
22
|
+
racc
|
|
23
|
+
prism (1.6.0)
|
|
24
|
+
racc (1.8.1)
|
|
23
25
|
rainbow (3.1.1)
|
|
24
|
-
rake (13.
|
|
25
|
-
regexp_parser (2.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
rspec-
|
|
29
|
-
rspec-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
rspec-expectations (3.12.2)
|
|
26
|
+
rake (13.3.1)
|
|
27
|
+
regexp_parser (2.11.3)
|
|
28
|
+
rspec (3.13.2)
|
|
29
|
+
rspec-core (~> 3.13.0)
|
|
30
|
+
rspec-expectations (~> 3.13.0)
|
|
31
|
+
rspec-mocks (~> 3.13.0)
|
|
32
|
+
rspec-core (3.13.6)
|
|
33
|
+
rspec-support (~> 3.13.0)
|
|
34
|
+
rspec-expectations (3.13.5)
|
|
34
35
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
35
|
-
rspec-support (~> 3.
|
|
36
|
-
rspec-mocks (3.
|
|
36
|
+
rspec-support (~> 3.13.0)
|
|
37
|
+
rspec-mocks (3.13.7)
|
|
37
38
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
38
|
-
rspec-support (~> 3.
|
|
39
|
-
rspec-support (3.
|
|
40
|
-
rubocop (1.
|
|
39
|
+
rspec-support (~> 3.13.0)
|
|
40
|
+
rspec-support (3.13.6)
|
|
41
|
+
rubocop (1.82.0)
|
|
41
42
|
json (~> 2.3)
|
|
43
|
+
language_server-protocol (~> 3.17.0.2)
|
|
44
|
+
lint_roller (~> 1.1.0)
|
|
42
45
|
parallel (~> 1.10)
|
|
43
|
-
parser (>= 3.
|
|
46
|
+
parser (>= 3.3.0.2)
|
|
44
47
|
rainbow (>= 2.2.2, < 4.0)
|
|
45
|
-
regexp_parser (>=
|
|
46
|
-
|
|
47
|
-
rubocop-ast (>= 1.26.0, < 2.0)
|
|
48
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
|
49
|
+
rubocop-ast (>= 1.48.0, < 2.0)
|
|
48
50
|
ruby-progressbar (~> 1.7)
|
|
49
|
-
unicode-display_width (>= 2.4.0, <
|
|
50
|
-
rubocop-ast (1.
|
|
51
|
-
parser (>= 3.
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
|
52
|
+
rubocop-ast (1.48.0)
|
|
53
|
+
parser (>= 3.3.7.2)
|
|
54
|
+
prism (~> 1.4)
|
|
55
|
+
rubocop-capybara (2.22.1)
|
|
56
|
+
lint_roller (~> 1.1)
|
|
57
|
+
rubocop (~> 1.72, >= 1.72.1)
|
|
58
|
+
rubocop-factory_bot (2.28.0)
|
|
59
|
+
lint_roller (~> 1.1)
|
|
60
|
+
rubocop (~> 1.72, >= 1.72.1)
|
|
54
61
|
rubocop-rake (0.6.0)
|
|
55
62
|
rubocop (~> 1.0)
|
|
56
|
-
rubocop-rspec (2.
|
|
57
|
-
rubocop (~> 1.
|
|
63
|
+
rubocop-rspec (2.31.0)
|
|
64
|
+
rubocop (~> 1.40)
|
|
58
65
|
rubocop-capybara (~> 2.17)
|
|
66
|
+
rubocop-factory_bot (~> 2.22)
|
|
67
|
+
rubocop-rspec_rails (~> 2.28)
|
|
68
|
+
rubocop-rspec_rails (2.29.1)
|
|
69
|
+
rubocop (~> 1.61)
|
|
59
70
|
ruby-progressbar (1.13.0)
|
|
60
|
-
unicode-display_width (2.
|
|
71
|
+
unicode-display_width (3.2.0)
|
|
72
|
+
unicode-emoji (~> 4.1)
|
|
73
|
+
unicode-emoji (4.2.0)
|
|
61
74
|
|
|
62
75
|
PLATFORMS
|
|
63
|
-
|
|
76
|
+
x86_64-linux-gnu
|
|
64
77
|
|
|
65
78
|
DEPENDENCIES
|
|
66
79
|
rake (~> 13.0)
|
|
@@ -71,4 +84,4 @@ DEPENDENCIES
|
|
|
71
84
|
zypper-onlinesearch!
|
|
72
85
|
|
|
73
86
|
BUNDLED WITH
|
|
74
|
-
2.4.
|
|
87
|
+
2.4.22
|
data/exe/onlinesearch
CHANGED
|
@@ -11,14 +11,14 @@ module Zypper
|
|
|
11
11
|
#
|
|
12
12
|
class OptParseMain
|
|
13
13
|
def self.parse(args)
|
|
14
|
-
options = Struct.new(:operation, :query, :refresh, :engine, :timeout, :
|
|
14
|
+
options = Struct.new(:operation, :query, :refresh, :engine, :timeout, :arch,
|
|
15
15
|
:distributions, :types, :number, :view, :format).new
|
|
16
16
|
options.operation = :search
|
|
17
17
|
options.query = ""
|
|
18
18
|
options.refresh = false
|
|
19
19
|
options.engine = :all # :opensuse, :packman
|
|
20
20
|
options.timeout = 20
|
|
21
|
-
options.
|
|
21
|
+
options.arch = :compatible # :all
|
|
22
22
|
options.distributions = :compatible # :all
|
|
23
23
|
options.types = %i[supported community experimental unsupported]
|
|
24
24
|
options.number = 0
|
|
@@ -86,8 +86,8 @@ module Zypper
|
|
|
86
86
|
opt.separator ""
|
|
87
87
|
opt.separator '"Page" and "Links" options:'
|
|
88
88
|
|
|
89
|
-
opt.on("--all-
|
|
90
|
-
options.
|
|
89
|
+
opt.on("--all-architectures", "Show all the available architectures") do
|
|
90
|
+
options.arch = :all
|
|
91
91
|
end
|
|
92
92
|
|
|
93
93
|
opt.on("--all-distributions", "Show all the available distributions") do
|
|
@@ -117,6 +117,10 @@ module Zypper
|
|
|
117
117
|
options.format = o.to_sym
|
|
118
118
|
end
|
|
119
119
|
|
|
120
|
+
opt.on("--architecture ARCHITECTURE", "Filter for packages with the specified ARCHITECTURE") do |o|
|
|
121
|
+
options.arch = o.to_sym
|
|
122
|
+
end
|
|
123
|
+
|
|
120
124
|
opt.on("--urls", "Show only the urls without headers") do
|
|
121
125
|
options.view = :urls
|
|
122
126
|
end
|
|
@@ -8,27 +8,33 @@ module Zypper
|
|
|
8
8
|
# Base class for page scraping.
|
|
9
9
|
#
|
|
10
10
|
class PageData
|
|
11
|
-
|
|
11
|
+
ARCHS = {
|
|
12
12
|
aarch64: "ARM v8.x 64-bit",
|
|
13
13
|
aarch64_ilp32: "ARM v8.x 64-bit ilp32 mode",
|
|
14
14
|
all: "All",
|
|
15
15
|
armv6l: "ARM v6",
|
|
16
16
|
armv7l: "ARM v7",
|
|
17
|
-
extra: "Extra",
|
|
18
17
|
i586: "Intel 32-bit",
|
|
19
18
|
i686: "Intel Pentium 32-bit",
|
|
20
|
-
lang: "Language",
|
|
21
19
|
lsrc: "Language source",
|
|
22
20
|
noarch: "No architecture",
|
|
23
21
|
ppc64le: "PowerPC 64-bit little-endian",
|
|
24
22
|
ppc64: "PowerPC 64-bit",
|
|
25
23
|
ppc: "PowerPC",
|
|
26
|
-
repo: "Repository",
|
|
27
24
|
riscv64: "Risc v64",
|
|
28
25
|
s390x: "IBM System/390",
|
|
29
26
|
src: "Source",
|
|
30
|
-
x86_64: "Intel/AMD 64-bit"
|
|
31
|
-
|
|
27
|
+
x86_64: "Intel/AMD 64-bit"
|
|
28
|
+
}.freeze
|
|
29
|
+
|
|
30
|
+
FORMATS = {
|
|
31
|
+
all: "All",
|
|
32
|
+
extra: "Extra",
|
|
33
|
+
lang: "Language",
|
|
34
|
+
repo: "Repository",
|
|
35
|
+
src: "Source",
|
|
36
|
+
ymp: "1 Click Install",
|
|
37
|
+
rpm: "RPM"
|
|
32
38
|
}.freeze
|
|
33
39
|
|
|
34
40
|
def initialize(page)
|
|
@@ -63,7 +69,7 @@ module Zypper
|
|
|
63
69
|
cards.each do |c|
|
|
64
70
|
url = expand_link(c.xpath(XPATH_URL).text)
|
|
65
71
|
name = c.xpath(XPATH_NAME).text
|
|
66
|
-
name = File.basename(url)
|
|
72
|
+
name = "#{File.basename(url)} (#{name})" if File.basename(url) != name
|
|
67
73
|
res << { name: name, description: c.xpath(XPATH_DESC).text.strip.gsub(/\n|\ +/, " "), url: url }
|
|
68
74
|
end
|
|
69
75
|
|
|
@@ -164,7 +170,7 @@ module Zypper
|
|
|
164
170
|
|
|
165
171
|
@page.xpath(XPATH_UNSUPPORTED).each_with_index do |ver, i|
|
|
166
172
|
extract(ver, res, :unsupported,
|
|
167
|
-
XPATH_UNSUPPORTED_LABEL.gsub(
|
|
173
|
+
XPATH_UNSUPPORTED_LABEL.gsub("_n_", i.next.to_s),
|
|
168
174
|
XPATH_UNSUPPORTED_VERSION, XPATH_UNSUPPORTED_LINK)
|
|
169
175
|
end
|
|
170
176
|
|
|
@@ -175,7 +181,8 @@ module Zypper
|
|
|
175
181
|
|
|
176
182
|
def extract(ver, res, type, xpath_group, xpath_version, xpath_link)
|
|
177
183
|
repo = ""
|
|
178
|
-
format =
|
|
184
|
+
format = :none
|
|
185
|
+
arch = :noarch
|
|
179
186
|
version = nil
|
|
180
187
|
|
|
181
188
|
ver.xpath(xpath_group).each do |pack|
|
|
@@ -187,8 +194,8 @@ module Zypper
|
|
|
187
194
|
@old_version = version
|
|
188
195
|
end
|
|
189
196
|
|
|
190
|
-
if
|
|
191
|
-
format =
|
|
197
|
+
if pack.text.strip =~ /1 Click Install/
|
|
198
|
+
format = :ymp
|
|
192
199
|
else
|
|
193
200
|
repo = pack.text.strip
|
|
194
201
|
if repo.empty?
|
|
@@ -201,15 +208,15 @@ module Zypper
|
|
|
201
208
|
link = expand_link(pack.xpath(xpath_link).text)
|
|
202
209
|
|
|
203
210
|
if repo =~ /Expert Download/
|
|
204
|
-
res[:versions] << { distro: ver.text.gsub(
|
|
205
|
-
repo: @old_repo, format: :extra, version: version }
|
|
211
|
+
res[:versions] << { distro: ver.text.gsub(":", " "), link: link, type: type,
|
|
212
|
+
repo: @old_repo, format: :extra, arch: arch, version: version }
|
|
206
213
|
next
|
|
207
214
|
end
|
|
208
215
|
|
|
209
216
|
next if format.to_s.empty? || link.include?("/package/show/")
|
|
210
217
|
|
|
211
218
|
res[:versions] << { distro: ver.text, link: link, type: type, repo: repo,
|
|
212
|
-
format: format, version: version }
|
|
219
|
+
format: format, arch: arch, version: version }
|
|
213
220
|
end
|
|
214
221
|
end
|
|
215
222
|
|
|
@@ -230,7 +237,7 @@ module Zypper
|
|
|
230
237
|
XPATH_PACKAGES = '//td[@id="package-details-left"]//tbody/tr'
|
|
231
238
|
XPATH_VERSION = ".//td[1]"
|
|
232
239
|
XPATH_DISTRO = ".//td[2]"
|
|
233
|
-
|
|
240
|
+
XPATH_ARCH = ".//td[3]"
|
|
234
241
|
XPATH_LINK = ".//a/@href"
|
|
235
242
|
|
|
236
243
|
def data
|
|
@@ -242,11 +249,11 @@ module Zypper
|
|
|
242
249
|
|
|
243
250
|
@page.xpath(XPATH_PACKAGES).each do |pack|
|
|
244
251
|
version = pack.xpath(XPATH_VERSION).text.split("-")[0].to_s
|
|
245
|
-
distro = pack.xpath(XPATH_DISTRO).text.gsub(
|
|
246
|
-
|
|
252
|
+
distro = pack.xpath(XPATH_DISTRO).text.gsub("_", " ")
|
|
253
|
+
arch = pack.xpath(XPATH_ARCH).text.strip.to_sym
|
|
247
254
|
link = pack.xpath(XPATH_LINK).text
|
|
248
255
|
|
|
249
|
-
res[:versions] << { format:
|
|
256
|
+
res[:versions] << { format: :extra, arch: arch, version: version, distro: distro,
|
|
250
257
|
type: :supported, link: "http://packman.links2linux.org#{link}",
|
|
251
258
|
repo: "Packman" }
|
|
252
259
|
end
|
|
@@ -272,7 +279,7 @@ module Zypper
|
|
|
272
279
|
def data
|
|
273
280
|
res = { versions: [] }
|
|
274
281
|
|
|
275
|
-
extract(res,
|
|
282
|
+
extract(res, :noarch, XPATH_REPO, XPATH_REPO_DISTRO, XPATH_REPO_LINK)
|
|
276
283
|
extract(res, -2, XPATH_PACKAGE_GROUP, XPATH_PACKAGE_DISTRO, XPATH_PACKAGE_LINK)
|
|
277
284
|
|
|
278
285
|
res
|
|
@@ -280,7 +287,7 @@ module Zypper
|
|
|
280
287
|
|
|
281
288
|
private
|
|
282
289
|
|
|
283
|
-
def extract(res,
|
|
290
|
+
def extract(res, arch_idx, xpath_group, xpath_distro, xpath_link)
|
|
284
291
|
@page.xpath(xpath_group).each do |section|
|
|
285
292
|
distro = ""
|
|
286
293
|
section.xpath(xpath_distro).each do |subsection|
|
|
@@ -293,7 +300,8 @@ module Zypper
|
|
|
293
300
|
link = link.gsub("\n", " ").scan(%r{(https://[^ \n]+)}).pop.pop
|
|
294
301
|
res[:versions] << {
|
|
295
302
|
distro: distro,
|
|
296
|
-
format: File.basename(link).split(".")[
|
|
303
|
+
format: File.basename(link).split(".")[-1].to_sym,
|
|
304
|
+
arch: arch_idx.is_a?(Integer) ? File.basename(link).split(".")[arch_idx].to_sym : arch_idx,
|
|
297
305
|
link: link
|
|
298
306
|
}
|
|
299
307
|
end
|
|
@@ -314,23 +322,25 @@ module Zypper
|
|
|
314
322
|
|
|
315
323
|
def data
|
|
316
324
|
res = { versions: [] }
|
|
317
|
-
distro = @page.xpath(XPATH_LINK_DISTRO).text.gsub(
|
|
325
|
+
distro = @page.xpath(XPATH_LINK_DISTRO).text.gsub("_", " ")
|
|
318
326
|
@page.xpath(XPATH_LINK_BIN).each do |pack|
|
|
319
327
|
link = pack.text
|
|
320
328
|
res[:versions] << {
|
|
321
329
|
distro: distro,
|
|
322
|
-
format: File.basename(link).split(".")[-
|
|
330
|
+
format: File.basename(link).split(".")[-1].to_sym,
|
|
331
|
+
arch: File.basename(link).split(".")[-2].to_sym,
|
|
323
332
|
link: URL + link
|
|
324
333
|
}
|
|
325
334
|
end
|
|
326
335
|
|
|
327
336
|
link = res[:versions].last[:link]
|
|
328
|
-
is_lang = (File.basename(link) =~ /-lang/) && (res[:versions].last[:
|
|
337
|
+
is_lang = (File.basename(link) =~ /-lang/) && (res[:versions].last[:arch] == :noarch)
|
|
329
338
|
|
|
330
339
|
link = @page.xpath(XPATH_LINK_SRC).text
|
|
331
340
|
res[:versions] << {
|
|
332
341
|
distro: distro,
|
|
333
|
-
format:
|
|
342
|
+
format: File.basename(link).split(".")[-1].to_sym,
|
|
343
|
+
arch: is_lang ? :lsrc : File.basename(link).split(".")[-2].to_sym,
|
|
334
344
|
link: URL + link
|
|
335
345
|
}
|
|
336
346
|
|
|
@@ -339,6 +349,7 @@ module Zypper
|
|
|
339
349
|
res[:versions] << {
|
|
340
350
|
distro: distro,
|
|
341
351
|
format: :ymp,
|
|
352
|
+
arch: :noarch,
|
|
342
353
|
link: URL + link
|
|
343
354
|
}
|
|
344
355
|
end
|
|
@@ -145,8 +145,8 @@ module Zypper
|
|
|
145
145
|
URL = "https://software.opensuse.org/search"
|
|
146
146
|
|
|
147
147
|
def initialize(query, cache, timeout, cookies = [])
|
|
148
|
-
super
|
|
149
|
-
cookies << "baseproject=ALL;search_devel=true;search_debug=false;search_lang=false"
|
|
148
|
+
super(query, cache, timeout,
|
|
149
|
+
cookies << "baseproject=ALL;search_devel=true;search_debug=false;search_lang=false")
|
|
150
150
|
end
|
|
151
151
|
|
|
152
152
|
def uri
|
|
@@ -178,12 +178,12 @@ module Zypper
|
|
|
178
178
|
URL = "https://software.opensuse.org/package/"
|
|
179
179
|
|
|
180
180
|
def initialize(query, cache, timeout, cookies = [])
|
|
181
|
-
super
|
|
182
|
-
cookies << "baseproject=ALL;search_devel=true;search_debug=false;search_lang=false"
|
|
181
|
+
super(query, cache, timeout,
|
|
182
|
+
cookies << "baseproject=ALL;search_devel=true;search_debug=false;search_lang=false")
|
|
183
183
|
end
|
|
184
184
|
|
|
185
185
|
def uri
|
|
186
|
-
URI(URL + URI.
|
|
186
|
+
URI(URL + URI::DEFAULT_PARSER.escape(@query))
|
|
187
187
|
end
|
|
188
188
|
end
|
|
189
189
|
|
|
@@ -194,7 +194,7 @@ module Zypper
|
|
|
194
194
|
URL = "http://packman.links2linux.org/package/"
|
|
195
195
|
|
|
196
196
|
def uri
|
|
197
|
-
URI(URL + URI.
|
|
197
|
+
URI(URL + URI::DEFAULT_PARSER.escape(@query))
|
|
198
198
|
end
|
|
199
199
|
end
|
|
200
200
|
end
|
|
@@ -208,7 +208,7 @@ module Zypper
|
|
|
208
208
|
|
|
209
209
|
def initialize(query, refresh, timeout = 60, cookies = [])
|
|
210
210
|
query = URI(query).query
|
|
211
|
-
super
|
|
211
|
+
super
|
|
212
212
|
end
|
|
213
213
|
|
|
214
214
|
def uri
|
|
@@ -224,11 +224,11 @@ module Zypper
|
|
|
224
224
|
|
|
225
225
|
def initialize(query, refresh, timeout = 60, cookies = [])
|
|
226
226
|
query = query.split("/")[-2..-1].join("/") if query =~ %r{://}
|
|
227
|
-
super
|
|
227
|
+
super
|
|
228
228
|
end
|
|
229
229
|
|
|
230
230
|
def uri
|
|
231
|
-
URI(@query =~ %r{://} ? @query : "#{URL}#{URI.
|
|
231
|
+
URI(@query =~ %r{://} ? @query : "#{URL}#{URI::DEFAULT_PARSER.escape(@query)}")
|
|
232
232
|
end
|
|
233
233
|
end
|
|
234
234
|
end
|
|
@@ -9,28 +9,93 @@ module Zypper
|
|
|
9
9
|
# String class patch.
|
|
10
10
|
#
|
|
11
11
|
class ::String
|
|
12
|
-
def black
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
def
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
def
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
def
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
def
|
|
33
|
-
|
|
12
|
+
def black
|
|
13
|
+
"\033[30m#{self}\033[0m"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def red
|
|
17
|
+
"\033[31m#{self}\033[0m"
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def green
|
|
21
|
+
"\033[32m#{self}\033[0m"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def yellow
|
|
25
|
+
"\033[33m#{self}\033[0m"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def blue
|
|
29
|
+
"\033[34m#{self}\033[0m"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def magenta
|
|
33
|
+
"\033[35m#{self}\033[0m"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def cyan
|
|
37
|
+
"\033[36m#{self}\033[0m"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def gray
|
|
41
|
+
"\033[37m#{self}\033[0m"
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def bg_black
|
|
45
|
+
"\033[40m#{self}\0330m"
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def bg_red
|
|
49
|
+
"\033[41m#{self}\033[0m"
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def bg_green
|
|
53
|
+
"\033[42m#{self}\033[0m"
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def bg_brown
|
|
57
|
+
"\033[43m#{self}\033[0m"
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def bg_blue
|
|
61
|
+
"\033[44m#{self}\033[0m"
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def bg_magenta
|
|
65
|
+
"\033[45m#{self}\033[0m"
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def bg_cyan
|
|
69
|
+
"\033[46m#{self}\033[0m"
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def bg_gray
|
|
73
|
+
"\033[47m#{self}\033[0m"
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def bold
|
|
77
|
+
"\033[1m#{self}\033[22m"
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def reverse_color
|
|
81
|
+
"\033[7m#{self}\033[27m"
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def cr
|
|
85
|
+
"\r#{self}"
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def clean
|
|
89
|
+
"\e[K#{self}"
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def new_line
|
|
93
|
+
"\n#{self}"
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def none
|
|
97
|
+
self
|
|
98
|
+
end
|
|
34
99
|
end
|
|
35
100
|
|
|
36
101
|
#
|
|
@@ -92,7 +157,7 @@ module Zypper
|
|
|
92
157
|
#
|
|
93
158
|
class QueryStringTooShort < StandardError
|
|
94
159
|
def initialize(query)
|
|
95
|
-
super
|
|
160
|
+
super("The query string '#{query}' is too short, be sure to use more than 3 characters.")
|
|
96
161
|
end
|
|
97
162
|
|
|
98
163
|
def error_code
|
|
@@ -105,7 +170,7 @@ module Zypper
|
|
|
105
170
|
#
|
|
106
171
|
class TooManyRedirections < StandardError
|
|
107
172
|
def initialize(url)
|
|
108
|
-
super
|
|
173
|
+
super("#{url} generates too many redirections!")
|
|
109
174
|
end
|
|
110
175
|
end
|
|
111
176
|
|
|
@@ -114,7 +179,7 @@ module Zypper
|
|
|
114
179
|
#
|
|
115
180
|
class InvalidEngine < StandardError
|
|
116
181
|
def initialize(engine)
|
|
117
|
-
super
|
|
182
|
+
super("#{engine} is not a valid engine!")
|
|
118
183
|
end
|
|
119
184
|
|
|
120
185
|
def error_code
|
|
@@ -127,7 +192,7 @@ module Zypper
|
|
|
127
192
|
#
|
|
128
193
|
class MissingItemNumber < StandardError
|
|
129
194
|
def initialize
|
|
130
|
-
super
|
|
195
|
+
super("No item number has been provided!")
|
|
131
196
|
end
|
|
132
197
|
end
|
|
133
198
|
|
|
@@ -136,7 +201,7 @@ module Zypper
|
|
|
136
201
|
#
|
|
137
202
|
class EmptyCache < StandardError
|
|
138
203
|
def initialize
|
|
139
|
-
super
|
|
204
|
+
super("The cache folder is already empty!")
|
|
140
205
|
end
|
|
141
206
|
end
|
|
142
207
|
|
|
@@ -145,7 +210,7 @@ module Zypper
|
|
|
145
210
|
#
|
|
146
211
|
class NoConnection < StandardError
|
|
147
212
|
def initialize
|
|
148
|
-
super
|
|
213
|
+
super("Internet connection has some trouble")
|
|
149
214
|
end
|
|
150
215
|
|
|
151
216
|
def error_code
|
|
@@ -158,7 +223,7 @@ module Zypper
|
|
|
158
223
|
#
|
|
159
224
|
class Interruption < StandardError
|
|
160
225
|
def initialize
|
|
161
|
-
super
|
|
226
|
+
super("Ok ok... Exiting!")
|
|
162
227
|
end
|
|
163
228
|
end
|
|
164
229
|
|
|
@@ -124,7 +124,7 @@ module Zypper
|
|
|
124
124
|
def self.general(args)
|
|
125
125
|
engine = args[:engine].bold.red
|
|
126
126
|
distro = args[:distro].bold.blue
|
|
127
|
-
arch = PageData::
|
|
127
|
+
arch = PageData::ARCHS[args[:architecture]].bold
|
|
128
128
|
cache = if args[:refresh]
|
|
129
129
|
"Off".bold
|
|
130
130
|
elsif args[:cache_time]
|
|
@@ -135,7 +135,7 @@ module Zypper
|
|
|
135
135
|
|
|
136
136
|
puts ""
|
|
137
137
|
puts "=" * SEPARATOR_LENGTH
|
|
138
|
-
puts "#{"Parameters: ".bold} Engine: #{engine} | OS: #{distro} |
|
|
138
|
+
puts "#{"Parameters: ".bold} Engine: #{engine} | OS: #{distro} | Arch.: #{arch} | Cache: #{cache}"
|
|
139
139
|
puts "=" * SEPARATOR_LENGTH
|
|
140
140
|
puts "#{"Name: ".bold}#{args[:name]}"
|
|
141
141
|
puts "#{"Summary: ".bold}#{args[:short_description]}" if args[:short_description]
|
|
@@ -144,7 +144,7 @@ module Zypper
|
|
|
144
144
|
|
|
145
145
|
def self.no_packages(compatible)
|
|
146
146
|
separator
|
|
147
|
-
puts "#{" " * 3} - | No #{compatible ? "compatible" :
|
|
147
|
+
puts "#{" " * 3} - | No #{compatible ? "compatible" : nil.to_s} packages found!"
|
|
148
148
|
separator
|
|
149
149
|
end
|
|
150
150
|
|
|
@@ -262,9 +262,9 @@ module Zypper
|
|
|
262
262
|
#
|
|
263
263
|
class Table < Common
|
|
264
264
|
def self.header(args)
|
|
265
|
-
super
|
|
265
|
+
super
|
|
266
266
|
separator
|
|
267
|
-
puts "#{" " * 3} # | Format | Link"
|
|
267
|
+
puts "#{" " * 3} # | Format | Arch | Link"
|
|
268
268
|
separator
|
|
269
269
|
end
|
|
270
270
|
|
|
@@ -273,7 +273,11 @@ module Zypper
|
|
|
273
273
|
def self.link(args)
|
|
274
274
|
nl = args[:num].to_s.length
|
|
275
275
|
fl = args[:pack][:format].to_s.length
|
|
276
|
-
|
|
276
|
+
al = args[:pack][:arch].to_s.length
|
|
277
|
+
# rubocop:disable Style/LineEndConcatenation
|
|
278
|
+
puts "#{" " * (5 - nl)}#{args[:num]} | #{" " * (6 - fl)}#{args[:pack][:format]} |" +
|
|
279
|
+
"#{" " * (8 - al)}#{args[:pack][:arch]} | #{args[:pack][:link]}"
|
|
280
|
+
# rubocop:enable Style/LineEndConcatenation
|
|
277
281
|
separator
|
|
278
282
|
end
|
|
279
283
|
end
|
|
@@ -289,16 +293,14 @@ module Zypper
|
|
|
289
293
|
end
|
|
290
294
|
|
|
291
295
|
def self.link(args)
|
|
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
|
|
297
296
|
n_length = args[:num].to_s.length
|
|
298
|
-
|
|
297
|
+
alt_format = PageData::FORMATS[args[:pack][:format]]
|
|
298
|
+
alt_arch = PageData::ARCHS[args[:pack][:arch]]
|
|
299
|
+
|
|
300
|
+
puts "#{" " * (5 - n_length)}#{args[:num]} | Format: #{args[:pack][:format].to_s.bold} (#{alt_format})"
|
|
301
|
+
puts "#{" " * 5} | Architecture: #{args[:pack][:arch]} (#{alt_arch})"
|
|
299
302
|
puts "#{" " * 5} | Distribution: #{args[:pack][:distro]}"
|
|
300
303
|
puts "#{" " * 5} | Link: #{args[:pack][:link]}"
|
|
301
|
-
|
|
302
304
|
separator
|
|
303
305
|
end
|
|
304
306
|
end
|
data/lib/zypper/onlinesearch.rb
CHANGED
|
@@ -22,7 +22,7 @@ module Zypper
|
|
|
22
22
|
refresh: options.refresh,
|
|
23
23
|
query: options.query
|
|
24
24
|
@release = Release.new
|
|
25
|
-
@
|
|
25
|
+
@arch = options.arch
|
|
26
26
|
@distributions = options.distributions
|
|
27
27
|
@format = options.format
|
|
28
28
|
@types = options.types
|
|
@@ -93,16 +93,14 @@ module Zypper
|
|
|
93
93
|
|
|
94
94
|
collection = collection.pop
|
|
95
95
|
collection.each do |pack|
|
|
96
|
-
if
|
|
97
|
-
packages << pack
|
|
98
|
-
else
|
|
96
|
+
if pack[:format] == :extra
|
|
99
97
|
result = RequestList.new operation: :links,
|
|
100
98
|
engine: engine,
|
|
101
99
|
timeout: @search.timeout,
|
|
102
100
|
refresh: @search.refresh,
|
|
103
101
|
query: pack[:link]
|
|
104
102
|
|
|
105
|
-
result.engines.
|
|
103
|
+
result.engines.each_value do |v|
|
|
106
104
|
next unless v.available?
|
|
107
105
|
|
|
108
106
|
v.to_data[:versions].each do |f|
|
|
@@ -110,9 +108,11 @@ module Zypper
|
|
|
110
108
|
f[:repo] = pack[:repo]
|
|
111
109
|
f[:version] ||= pack[:version]
|
|
112
110
|
f[:distro] ||= pack[:distro]
|
|
113
|
-
packages << f if package_select?(f)
|
|
111
|
+
packages << f if package_select?(f, format_and_arch: true)
|
|
114
112
|
end
|
|
115
113
|
end
|
|
114
|
+
elsif package_select?(pack, format_and_arch: true)
|
|
115
|
+
packages << pack
|
|
116
116
|
end
|
|
117
117
|
end
|
|
118
118
|
end
|
|
@@ -137,7 +137,7 @@ module Zypper
|
|
|
137
137
|
refresh: @search.refresh,
|
|
138
138
|
cache_time: args[:cache_time]
|
|
139
139
|
|
|
140
|
-
if packages.
|
|
140
|
+
if packages.any?
|
|
141
141
|
@view_class.header first_col: packages.max_column(args[:first_col]),
|
|
142
142
|
second_col: packages.max_column(args[:second_col])
|
|
143
143
|
|
|
@@ -154,19 +154,23 @@ module Zypper
|
|
|
154
154
|
end
|
|
155
155
|
|
|
156
156
|
def architecture
|
|
157
|
-
@
|
|
157
|
+
@arch == :compatible ? @release.arch : :all
|
|
158
158
|
end
|
|
159
159
|
|
|
160
|
-
def package_select?(package)
|
|
161
|
-
res =
|
|
162
|
-
|
|
163
|
-
|
|
160
|
+
def package_select?(package, format_and_arch: false)
|
|
161
|
+
res = if @arch == :compatible
|
|
162
|
+
[:src, :noarch, @release.arch].include?(package[:arch])
|
|
163
|
+
else
|
|
164
|
+
format_and_arch ? (@arch == package[:arch]) : true
|
|
165
|
+
end
|
|
166
|
+
|
|
164
167
|
if @distributions == :compatible
|
|
165
|
-
res &&= (
|
|
166
|
-
package[:distro].match?(Regexp.new(@release.pretty_name, "i")))
|
|
168
|
+
res &&= (package[:distro] == :current) || package[:distro].match?(Regexp.new(@release.pretty_name, "i"))
|
|
167
169
|
end
|
|
168
170
|
res = false unless @types.include?(package[:type])
|
|
169
171
|
|
|
172
|
+
res &&= (@format == package[:format]) if @format != :all && format_and_arch
|
|
173
|
+
|
|
170
174
|
res
|
|
171
175
|
end
|
|
172
176
|
end
|
data/zypper-onlinesearch.gemspec
CHANGED
|
@@ -32,6 +32,6 @@ Gem::Specification.new do |spec|
|
|
|
32
32
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
|
33
33
|
spec.require_paths = ["lib"]
|
|
34
34
|
|
|
35
|
-
spec.
|
|
36
|
-
spec.
|
|
35
|
+
spec.add_dependency "iniparse"
|
|
36
|
+
spec.add_dependency "nokogiri"
|
|
37
37
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: zypper-onlinesearch
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Fabio Mucciante
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: iniparse
|
|
@@ -76,7 +75,6 @@ metadata:
|
|
|
76
75
|
changelog_uri: https://freeaptitude.altervista.org/projects/zypper-onlinesearch.html#changelog
|
|
77
76
|
wiki_uri: https://github.com/fabiomux/zypper-onlinesearch/wiki
|
|
78
77
|
rubygems_mfa_required: 'true'
|
|
79
|
-
post_install_message:
|
|
80
78
|
rdoc_options: []
|
|
81
79
|
require_paths:
|
|
82
80
|
- lib
|
|
@@ -91,8 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
91
89
|
- !ruby/object:Gem::Version
|
|
92
90
|
version: '0'
|
|
93
91
|
requirements: []
|
|
94
|
-
rubygems_version: 3.
|
|
95
|
-
signing_key:
|
|
92
|
+
rubygems_version: 3.6.7
|
|
96
93
|
specification_version: 4
|
|
97
94
|
summary: Zypper addon to search packages online through the openSUSE software search
|
|
98
95
|
website.
|