zypper-onlinesearch 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/lib/zypper/onlinesearch.rb
CHANGED
@@ -1,62 +1,57 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "zypper/onlinesearch/cache"
|
4
|
+
require "zypper/onlinesearch/request"
|
5
|
+
require "zypper/onlinesearch/data"
|
6
|
+
require "zypper/onlinesearch/release"
|
7
|
+
require "zypper/onlinesearch/utils"
|
8
|
+
require "zypper/onlinesearch/view"
|
7
9
|
|
8
10
|
module Zypper
|
9
11
|
module Onlinesearch
|
10
|
-
|
12
|
+
#
|
13
|
+
# Facade class for all the operations.
|
14
|
+
#
|
11
15
|
class Builder
|
12
16
|
def initialize(options)
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
@num = options.number
|
29
|
-
|
30
|
-
@view_class = Zypper::Onlinesearch::View.const_get options.operation.to_s.split('_').map(&:capitalize).join
|
31
|
-
@view_class = @view_class.const_get options.view.to_s.capitalize
|
32
|
-
end
|
17
|
+
return unless options.operation != :cache_clean
|
18
|
+
|
19
|
+
@search = RequestList.new operation: options.operation == :links ? :page : options.operation,
|
20
|
+
engine: options.engine,
|
21
|
+
timeout: options.timeout,
|
22
|
+
refresh: options.refresh,
|
23
|
+
query: options.query
|
24
|
+
@release = Release.new
|
25
|
+
@formats = options.formats
|
26
|
+
@distributions = options.distributions
|
27
|
+
@format = options.format
|
28
|
+
@types = options.types
|
29
|
+
@num = options.number
|
30
|
+
@view_class = Zypper::Onlinesearch::View.const_get options.operation.to_s.split("_").map(&:capitalize).join
|
31
|
+
@view_class = @view_class.const_get options.view.to_s.capitalize
|
33
32
|
end
|
34
33
|
|
35
34
|
def search
|
36
35
|
raise QueryStringTooShort, @search.query if @search.query.length < 3
|
37
|
-
@search.engines.each do |k, v|
|
38
36
|
|
37
|
+
@search.engines.each do |k, v|
|
39
38
|
@view_class.parameters engine: k,
|
40
|
-
|
39
|
+
refresh: @search.refresh,
|
41
40
|
query: @search.query,
|
42
41
|
cache_time: v.cache_time
|
43
|
-
|
44
42
|
if v.available?
|
45
43
|
data = v.to_data
|
46
|
-
|
47
44
|
if data.empty?
|
48
45
|
@view_class.no_packages if data.empty?
|
49
46
|
else
|
50
47
|
@view_class.header first_col: data.max_column(:name)
|
51
|
-
|
52
48
|
data.each_with_index do |i, idx|
|
53
|
-
next if @num
|
49
|
+
next if @num.positive? && idx.next != @num
|
54
50
|
|
55
51
|
@view_class.package num: idx.next,
|
56
52
|
name: i[:name],
|
57
53
|
description: i[:description],
|
58
54
|
url: i[:url]
|
59
|
-
|
60
55
|
end
|
61
56
|
end
|
62
57
|
else
|
@@ -69,62 +64,60 @@ module Zypper
|
|
69
64
|
@search.engines.each do |engine, x|
|
70
65
|
packages = []
|
71
66
|
next unless x.available?
|
67
|
+
|
72
68
|
data = x.to_data
|
73
69
|
versions = data[:versions].select { |y| package_select?(y) }
|
74
|
-
.group_by { |v| v[:repo]
|
75
|
-
|
76
|
-
versions.each.each_with_index do |collection, idx|
|
70
|
+
.group_by { |v| "#{v[:repo]}##{v[:distro]}##{v[:version]}" }
|
71
|
+
versions.each do |collection|
|
77
72
|
collection = collection.pop
|
78
73
|
packages << collection.pop
|
79
74
|
end
|
80
|
-
|
81
|
-
|
82
|
-
engine: engine, distro: @release.pretty_name, cache_time: x.cache_time)
|
75
|
+
print_packages(data, packages, first_col: :repo, second_col: :distro, view: :package, engine: engine,
|
76
|
+
distro: @release.pretty_name, cache_time: x.cache_time)
|
83
77
|
end
|
84
78
|
end
|
85
79
|
|
86
|
-
|
87
80
|
def links
|
88
|
-
raise MissingItemNumber unless @num
|
81
|
+
raise MissingItemNumber unless @num.positive?
|
82
|
+
|
89
83
|
@search.engines.each do |engine, x|
|
90
84
|
packages = []
|
91
|
-
next
|
92
|
-
data = x.to_data
|
85
|
+
next unless x.available?
|
93
86
|
|
87
|
+
data = x.to_data
|
94
88
|
versions = data[:versions].select { |y| package_select?(y) }
|
95
|
-
.group_by { |v| v[:repo]
|
89
|
+
.group_by { |v| "#{v[:repo]}##{v[:distro]}#{v[:version]}" }
|
96
90
|
|
97
|
-
versions.
|
91
|
+
versions.each_with_index do |collection, idx|
|
98
92
|
next if idx.next != @num
|
93
|
+
|
99
94
|
collection = collection.pop
|
100
95
|
collection.each do |pack|
|
101
|
-
|
102
|
-
|
96
|
+
if (pack[:link] =~ /rpm$/) || (pack[:format] == :ymp)
|
97
|
+
packages << pack
|
98
|
+
else
|
103
99
|
result = RequestList.new operation: :links,
|
104
100
|
engine: engine,
|
105
101
|
timeout: @search.timeout,
|
106
102
|
refresh: @search.refresh,
|
107
103
|
query: pack[:link]
|
108
104
|
|
109
|
-
result.engines.each do |
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
end
|
105
|
+
result.engines.each do |_k, v|
|
106
|
+
next unless v.available?
|
107
|
+
|
108
|
+
v.to_data[:versions].each do |f|
|
109
|
+
f[:type] = pack[:type]
|
110
|
+
f[:repo] = pack[:repo]
|
111
|
+
f[:version] ||= pack[:version]
|
112
|
+
f[:distro] ||= pack[:distro]
|
113
|
+
packages << f if package_select?(f)
|
119
114
|
end
|
120
115
|
end
|
121
|
-
else
|
122
|
-
packages << pack
|
123
116
|
end
|
124
117
|
end
|
125
118
|
end
|
126
|
-
print_packages(data, packages, first_col: :format, second_col: :link,
|
127
|
-
|
119
|
+
print_packages(data, packages, first_col: :format, second_col: :link, view: :link,
|
120
|
+
engine: engine, cache_time: x.cache_time)
|
128
121
|
end
|
129
122
|
end
|
130
123
|
|
@@ -132,64 +125,50 @@ module Zypper
|
|
132
125
|
View::CacheClean.reset Cache.reset!
|
133
126
|
end
|
134
127
|
|
135
|
-
|
136
128
|
private
|
137
129
|
|
138
130
|
def print_packages(data, packages, args)
|
139
|
-
|
140
131
|
@view_class.general name: data[:name] || @search.query,
|
141
|
-
short_description: data[:short_description] ||
|
142
|
-
description: data[:description] ||
|
132
|
+
short_description: data[:short_description] || "",
|
133
|
+
description: data[:description] || "",
|
143
134
|
engine: args[:engine],
|
144
|
-
distro:
|
135
|
+
distro: @distributions == :compatible ? @release.pretty_name : "All",
|
145
136
|
architecture: architecture,
|
146
137
|
refresh: @search.refresh,
|
147
138
|
cache_time: args[:cache_time]
|
148
139
|
|
149
|
-
if packages.count
|
150
|
-
|
140
|
+
if packages.count.positive?
|
151
141
|
@view_class.header first_col: packages.max_column(args[:first_col]),
|
152
142
|
second_col: packages.max_column(args[:second_col])
|
153
143
|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
args: args }
|
158
|
-
end
|
144
|
+
packages.each_with_index do |pack, idx|
|
145
|
+
@view_class.send args[:view], { num: idx.next, pack: pack, args: args }
|
146
|
+
end
|
159
147
|
else
|
160
148
|
@view_class.no_packages(!data[:versions].empty?)
|
161
149
|
end
|
162
150
|
end
|
163
151
|
|
164
152
|
def pretty_name
|
165
|
-
|
153
|
+
@distributions == :compatible ? @release.pretty_name : "All"
|
166
154
|
end
|
167
155
|
|
168
156
|
def architecture
|
169
|
-
|
157
|
+
@formats == :compatible ? @release.arch : :all
|
170
158
|
end
|
171
159
|
|
172
160
|
def package_select?(package)
|
173
161
|
res = true
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
unless (@format == :all)
|
180
|
-
res = res && (@format == package[:format])
|
162
|
+
res = [:ymp, :src, :extra, @release.arch].include?(package[:format]) if @formats == :compatible
|
163
|
+
res &&= (@format == package[:format]) unless @format == :all
|
164
|
+
if @distributions == :compatible
|
165
|
+
res &&= ((package[:distro] == :current) ||
|
166
|
+
package[:distro].match?(Regexp.new(@release.pretty_name, "i")))
|
181
167
|
end
|
182
|
-
|
183
|
-
if (@distributions == :compatible)
|
184
|
-
res = res && ((:current == package[:distro]) || package[:distro].match?(Regexp.new(@release.pretty_name, 'i')))
|
185
|
-
end
|
186
|
-
|
187
168
|
res = false unless @types.include?(package[:type])
|
188
169
|
|
189
170
|
res
|
190
171
|
end
|
191
|
-
|
192
172
|
end
|
193
|
-
|
194
173
|
end
|
195
174
|
end
|
data/zypper-onlinesearch.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/zypper/onlinesearch/version"
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "zypper-onlinesearch"
|
@@ -8,33 +8,30 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.authors = ["Fabio Mucciante"]
|
9
9
|
spec.email = ["fabio.mucciante@gmail.com"]
|
10
10
|
|
11
|
-
spec.summary =
|
12
|
-
spec.description =
|
11
|
+
spec.summary = "Zypper addon to search packages online through the openSUSE software search website."
|
12
|
+
spec.description = "Search for packages through the openSUSE software search website and similar."
|
13
13
|
spec.homepage = "https://github.com/fabiomux/zypper-onlinesearch"
|
14
|
-
spec.license =
|
14
|
+
spec.license = "GPL-3.0"
|
15
|
+
spec.required_ruby_version = ">= 2.6.0"
|
16
|
+
|
17
|
+
spec.metadata["bug_tracker_uri"] = "https://github.com/fabiomux/zypper-onlinesearch/issues"
|
18
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
19
|
+
spec.metadata["source_code_uri"] = "https://github.com/fabiomux/zypper-onlinesearch"
|
20
|
+
spec.metadata["changelog_uri"] = "https://freeaptitude.altervista.org/projects/zypper-onlinesearch.html#changelog"
|
21
|
+
spec.metadata["wiki_uri"] = "https://github.com/fabiomux/zypper-onlinesearch/wiki"
|
22
|
+
spec.metadata["rubygems_mfa_required"] = "true"
|
15
23
|
|
16
|
-
spec.metadata = {
|
17
|
-
"bug_tracker_uri" => 'https://github.com/fabiomux/zypper-onlinesearch/issues',
|
18
|
-
"changelog_uri" => 'https://freeaptitude.altervista.org/projects/zypper-onlinesearch.html#changelog',
|
19
|
-
"documentation_uri" => "https://www.rubydoc.info/gems/zypper-onlinesearch/#{spec.version}",
|
20
|
-
"homepage_uri" => 'https://freeaptitude.altervista.org/projects/zypper-onlinesearch.html',
|
21
|
-
#"mailing_list_uri" => "",
|
22
|
-
"source_code_uri" => 'https://github.com/fabiomux/zypper-onlinesearch',
|
23
|
-
"wiki_uri" => 'https://github.com/fabiomux/zypper-onlinesearch/wiki'
|
24
|
-
}
|
25
24
|
# Specify which files should be added to the gem when it is released.
|
26
25
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
27
|
-
spec.files
|
28
|
-
`git ls-files -z`.split("\x0").reject
|
26
|
+
spec.files = Dir.chdir(__dir__) do
|
27
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
28
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|circleci)|appveyor)})
|
29
|
+
end
|
29
30
|
end
|
30
31
|
spec.bindir = "exe"
|
31
|
-
spec.executables = spec.files.grep(%r{
|
32
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
32
33
|
spec.require_paths = ["lib"]
|
33
34
|
|
34
|
-
spec.add_development_dependency "bundler", "~> 2.0"
|
35
|
-
spec.add_development_dependency "rake", "~> 12.0"
|
36
|
-
spec.add_development_dependency "rspec", "~> 3.0"
|
37
|
-
|
38
|
-
spec.add_runtime_dependency "nokogiri"
|
39
35
|
spec.add_runtime_dependency "iniparse"
|
36
|
+
spec.add_runtime_dependency "nokogiri"
|
40
37
|
end
|
metadata
CHANGED
@@ -1,59 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zypper-onlinesearch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fabio Mucciante
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '2.0'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '2.0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rake
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '12.0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '12.0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rspec
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '3.0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '3.0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: nokogiri
|
14
|
+
name: iniparse
|
57
15
|
requirement: !ruby/object:Gem::Requirement
|
58
16
|
requirements:
|
59
17
|
- - ">="
|
@@ -67,7 +25,7 @@ dependencies:
|
|
67
25
|
- !ruby/object:Gem::Version
|
68
26
|
version: '0'
|
69
27
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
28
|
+
name: nokogiri
|
71
29
|
requirement: !ruby/object:Gem::Requirement
|
72
30
|
requirements:
|
73
31
|
- - ">="
|
@@ -80,8 +38,8 @@ dependencies:
|
|
80
38
|
- - ">="
|
81
39
|
- !ruby/object:Gem::Version
|
82
40
|
version: '0'
|
83
|
-
description:
|
84
|
-
|
41
|
+
description: Search for packages through the openSUSE software search website and
|
42
|
+
similar.
|
85
43
|
email:
|
86
44
|
- fabio.mucciante@gmail.com
|
87
45
|
executables:
|
@@ -89,16 +47,14 @@ executables:
|
|
89
47
|
extensions: []
|
90
48
|
extra_rdoc_files: []
|
91
49
|
files:
|
92
|
-
- ".gitignore"
|
93
50
|
- ".rspec"
|
94
|
-
- ".
|
51
|
+
- ".rubocop.yml"
|
95
52
|
- CODE_OF_CONDUCT.md
|
96
53
|
- Gemfile
|
97
54
|
- Gemfile.lock
|
55
|
+
- LICENSE
|
98
56
|
- README.md
|
99
57
|
- Rakefile
|
100
|
-
- bin/console
|
101
|
-
- bin/setup
|
102
58
|
- exe/onlinesearch
|
103
59
|
- lib/zypper/onlinesearch.rb
|
104
60
|
- lib/zypper/onlinesearch/cache.rb
|
@@ -115,11 +71,11 @@ licenses:
|
|
115
71
|
- GPL-3.0
|
116
72
|
metadata:
|
117
73
|
bug_tracker_uri: https://github.com/fabiomux/zypper-onlinesearch/issues
|
118
|
-
|
119
|
-
documentation_uri: https://www.rubydoc.info/gems/zypper-onlinesearch/1.0.0
|
120
|
-
homepage_uri: https://freeaptitude.altervista.org/projects/zypper-onlinesearch.html
|
74
|
+
homepage_uri: https://github.com/fabiomux/zypper-onlinesearch
|
121
75
|
source_code_uri: https://github.com/fabiomux/zypper-onlinesearch
|
76
|
+
changelog_uri: https://freeaptitude.altervista.org/projects/zypper-onlinesearch.html#changelog
|
122
77
|
wiki_uri: https://github.com/fabiomux/zypper-onlinesearch/wiki
|
78
|
+
rubygems_mfa_required: 'true'
|
123
79
|
post_install_message:
|
124
80
|
rdoc_options: []
|
125
81
|
require_paths:
|
@@ -128,7 +84,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
128
84
|
requirements:
|
129
85
|
- - ">="
|
130
86
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
87
|
+
version: 2.6.0
|
132
88
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
89
|
requirements:
|
134
90
|
- - ">="
|
data/.gitignore
DELETED
data/.travis.yml
DELETED
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "zypper/onlinesearch"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start(__FILE__)
|