zypper-onlinesearch 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4fb320a7be8ac2fc8adcc67f3de65cdf424dc8cf27a1a76d3fca6ea251164537
4
+ data.tar.gz: caed75b0b715d1f98f1dcc84f8388cf95ecadc0776902c151ebb3267c4f9fbf2
5
+ SHA512:
6
+ metadata.gz: b6698b420ce6f61e8b6719775f8924e28c6be832f2f1e100e4c77d2cf3feddbfab4c45b2fa6ae1bbeb2d07cb57889901e2c76f5eb67f55b640a35c679911e1ea
7
+ data.tar.gz: 45fc3cf71baa2d105270c16a136bbccd097e7cc2f7c11cb7c9f5207210462637391c7aa6db6c8f240a38af7a06ae5341e57d2c01ab891c9463d46a4581e28eec
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.5
5
+ before_install: gem install bundler -v 1.16.2
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at fabio.mucciante@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in zypper-onlinesearch.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,43 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ zypper-onlinesearch (1.0.0)
5
+ iniparse
6
+ nokogiri
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ diff-lcs (1.5.0)
12
+ iniparse (1.5.0)
13
+ mini_portile2 (2.8.1)
14
+ nokogiri (1.13.10)
15
+ mini_portile2 (~> 2.8.0)
16
+ racc (~> 1.4)
17
+ racc (1.6.2)
18
+ rake (12.3.3)
19
+ rspec (3.12.0)
20
+ rspec-core (~> 3.12.0)
21
+ rspec-expectations (~> 3.12.0)
22
+ rspec-mocks (~> 3.12.0)
23
+ rspec-core (3.12.1)
24
+ rspec-support (~> 3.12.0)
25
+ rspec-expectations (3.12.2)
26
+ diff-lcs (>= 1.2.0, < 2.0)
27
+ rspec-support (~> 3.12.0)
28
+ rspec-mocks (3.12.3)
29
+ diff-lcs (>= 1.2.0, < 2.0)
30
+ rspec-support (~> 3.12.0)
31
+ rspec-support (3.12.0)
32
+
33
+ PLATFORMS
34
+ ruby
35
+
36
+ DEPENDENCIES
37
+ bundler (~> 2.0)
38
+ rake (~> 12.0)
39
+ rspec (~> 3.0)
40
+ zypper-onlinesearch!
41
+
42
+ BUNDLED WITH
43
+ 2.4.3
data/README.md ADDED
@@ -0,0 +1,162 @@
1
+ # Zypper-Onlinesearch
2
+
3
+ Zypper-Onlinesearch brings the ability to find packages from *software.opensuse.org* and *Packman*,
4
+ directly in your terminal.
5
+
6
+ Basically it is just a command-line frontend to these search engines, it executes a query to them,
7
+ arrange the results and display them in a table or report view.
8
+
9
+ ## Installation
10
+
11
+ There are a couple of options to install this application.
12
+
13
+ ### Rubygem
14
+
15
+ Install it as a regular Ruby gem with:
16
+ ```shell
17
+ $ gem install zypper-onlinesearch
18
+ ```
19
+
20
+ ### From the openSUSE Build Service repository
21
+
22
+ This application has been packaged in my personal OBS repository so you can install It
23
+ as a common RPM package:
24
+ - Add the repository URL in your list;
25
+ - install the package from Yast or Zypper.
26
+
27
+ Being the repository URL slightly changing from a version to another, I included all the steps
28
+ in the related [project page][project_page] at my blog.
29
+
30
+ ## Usage
31
+
32
+ To query for the string :
33
+ ```shell
34
+ $ onlinesearch -s <string>
35
+ ```
36
+
37
+ When the pages are returnerd they are identified in the *Page* field and can be read with the `-p` switch:
38
+ ```shell
39
+ $ onlinesearch -p <page>
40
+ ```
41
+
42
+ To list the links from that page:
43
+ ```shell
44
+ $ onlinesearch -l <page>,<link_number>
45
+ ```
46
+
47
+ For example looking for *Qmmp*:
48
+ ```shell
49
+ $ onlinesearch -s qmmp
50
+
51
+ ====================================================================================================
52
+ Parameters: Engine: packman | Query: qmmp | Cache: On (2023-02-23 16:37)
53
+ ====================================================================================================
54
+ # | Page | Description
55
+ ----------------------------------------------------------------------------------------------------
56
+ 1 | qmmp | Qt-based Multimedia Player
57
+ ----------------------------------------------------------------------------------------------------
58
+ 2 | qmmp-plugin-pack | Extra plugins for Qmmp
59
+ ----------------------------------------------------------------------------------------------------
60
+
61
+ ====================================================================================================
62
+ Parameters: Engine: opensuse | Query: qmmp | Cache: On (2023-02-23 16:37)
63
+ ====================================================================================================
64
+ # | Page | Description
65
+ ----------------------------------------------------------------------------------------------------
66
+ 1 | qmmp | Qt-based Multimedia Player
67
+ ----------------------------------------------------------------------------------------------------
68
+ 2 | libqmmp1 | Qmmp library
69
+ ----------------------------------------------------------------------------------------------------
70
+ 3 | libqmmp-devel | Development files for libqmmp
71
+ ----------------------------------------------------------------------------------------------------
72
+ ...
73
+ ```
74
+
75
+ We get among the results a page called *qmmp* for both engines, so to read that pages:
76
+ ```shell
77
+ $ onlinesearch -p qmmp
78
+
79
+ ====================================================================================================
80
+ Parameters: Engine: packman | OS: openSUSE Leap 15.4 | Architecture: 64 Bit | Cache: On (2023-02-07 16:57)
81
+ ====================================================================================================
82
+ Name: qmmp
83
+ Summary:
84
+ Description:
85
+ Qt-based Multimedia Player
86
+ ----------------------------------------------------------------------------------------------------
87
+ # | Version | Repo | Distro
88
+ ----------------------------------------------------------------------------------------------------
89
+ 1 | 2.1.2 | Packman | openSUSE Leap 15.4
90
+ ----------------------------------------------------------------------------------------------------
91
+
92
+ ====================================================================================================
93
+ Parameters: Engine: opensuse | OS: openSUSE Leap 15.4 | Architecture: 64 Bit | Cache: On (2023-02-07 16:57)
94
+ ====================================================================================================
95
+ Name: qmmp
96
+ Summary: Qt-based Multimedia Player
97
+ Description: This program is an audio-player, written with help of Qt library.
98
+ ----------------------------------------------------------------------------------------------------
99
+ # | Version | Repo | Distro
100
+ ----------------------------------------------------------------------------------------------------
101
+ 1 | 2.1.2 | home:plater | openSUSE Leap 15.4
102
+ ----------------------------------------------------------------------------------------------------
103
+ 2 | 1.4.4 | home:ykoba:multimedia | openSUSE Leap 15.4
104
+ ----------------------------------------------------------------------------------------------------
105
+ 3 | 2.1.2 | multimedia:apps | openSUSE Leap 15.4
106
+ ----------------------------------------------------------------------------------------------------
107
+ ```
108
+
109
+ To show the page from one engine only, just append the `--engine <engine_name>` param:
110
+ ```shell
111
+ $ onlinesearch -p qmmp --engine opensuse
112
+ ```
113
+
114
+ To list the links in the third repository listed in the *opensuse* engine:
115
+ ```shell
116
+ $ onlinesearch -l qmmp,3 --engine opensuse
117
+
118
+ ====================================================================================================
119
+ Parameters: Engine: opensuse | OS: openSUSE Leap 15.4 | Architecture: 64 Bit | Cache: On (2023-02-07 16:57)
120
+ ====================================================================================================
121
+ Name: qmmp
122
+ Summary: Qt-based Multimedia Player
123
+ Description: This program is an audio-player, written with help of Qt library.
124
+ ----------------------------------------------------------------------------------------------------
125
+ # | Format | Link
126
+ ----------------------------------------------------------------------------------------------------
127
+ 1 | ymp | https://software.opensuse.org/ymp/multimedia:apps/15.4/qmmp.ymp?base=openSUSE%3ALeap%3A15.4&query=qmmp
128
+ ----------------------------------------------------------------------------------------------------
129
+ 2 | src | https://download.opensuse.org/repositories/multimedia:/apps/15.4/src/qmmp-2.1.2-lp154.182.3.src.rpm
130
+ ----------------------------------------------------------------------------------------------------
131
+ 3 | x86_64 | https://download.opensuse.org/repositories/multimedia:/apps/15.4/x86_64/qmmp-2.1.2-lp154.182.3.x86_64.rpm
132
+ ----------------------------------------------------------------------------------------------------
133
+ ```
134
+
135
+ To print only the raw URLs:
136
+ ```shell
137
+ $ onlinesearch -l qmmp,3 --urls
138
+ https://software.opensuse.org/ymp/multimedia:apps/15.4/qmmp.ymp?base=openSUSE%3ALeap%3A15.4&query=qmmp
139
+ https://download.opensuse.org/repositories/multimedia:/apps/15.4/src/qmmp-2.1.2-lp154.182.3.src.rpm
140
+ https://download.opensuse.org/repositories/multimedia:/apps/15.4/x86_64/qmmp-2.1.2-lp154.182.3.x86_64.rpm
141
+ ```
142
+
143
+ And in case we are interested to a specific format:
144
+ ```shell
145
+ $ onlinesearch -l qmmp,3 --urls --format ymp
146
+ https://software.opensuse.org/ymp/multimedia:apps/15.4/qmmp.ymp?base=openSUSE%3ALeap%3A15.4&query=qmmp
147
+ ```
148
+
149
+ ## Get help
150
+
151
+ Where to start:
152
+ ```shell
153
+ $ onlinesearch --help
154
+ ```
155
+
156
+ ## More Help:
157
+
158
+ More info is available at:
159
+ - the [Zypper-Onlinesearch Project page][project_page].
160
+
161
+ [project_page]: https://freeaptitude.altervista.org/projects/zypper-onlinesearch.html "Zypper-Onlinesearch project page"
162
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
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__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/exe/onlinesearch ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "zypper/onlinesearch/cli"
4
+
5
+ Zypper::Onlinesearch::CLI.start
@@ -0,0 +1,54 @@
1
+ require 'fileutils'
2
+ require 'uri'
3
+
4
+ module Zypper
5
+ module Onlinesearch
6
+
7
+ class Cache
8
+
9
+ def initialize(operation, engine)
10
+ @base_folder = File.join(ENV['HOME'], '.cache', 'zypper-onlinesearch', engine, operation)
11
+ FileUtils.mkdir_p @base_folder unless Dir.exists? @base_folder
12
+ end
13
+
14
+ def set(query, response)
15
+ File.open(File.join(@base_folder, query_to_filename(query)), 'w+') do |f|
16
+ f.write Marshal.dump(response)
17
+ end
18
+ end
19
+
20
+ def get(query)
21
+ fname = query_to_filename(query)
22
+ Marshal.load(File.read(File.join(@base_folder, fname))) if exists? query
23
+ end
24
+
25
+ def exists?(query)
26
+ File.exists?(File.join(@base_folder, query_to_filename(query)))
27
+ end
28
+
29
+ def self.reset!
30
+ base_folder = File.join(ENV['HOME'], '.cache', 'zypper-onlinesearch')
31
+ if Dir.exist? base_folder
32
+ size = Dir.glob(File.join(base_folder, '**', '*')).map{ |f| File.size(f) }.inject(:+)
33
+ FileUtils.remove_dir base_folder
34
+ return size
35
+ else
36
+ raise EmptyCache
37
+ end
38
+ end
39
+
40
+ def mtime(query)
41
+ fname = File.join(@base_folder, query_to_filename(query))
42
+ File.mtime(fname) if File.exist? fname
43
+ end
44
+
45
+ private
46
+
47
+ def query_to_filename(query)
48
+ URI.encode query.delete('./')
49
+ end
50
+ end
51
+
52
+ end
53
+ end
54
+
@@ -0,0 +1,162 @@
1
+ require 'optparse'
2
+ require 'ostruct'
3
+ require 'zypper/onlinesearch'
4
+ require 'zypper/onlinesearch/version'
5
+
6
+ module Zypper
7
+
8
+ module Onlinesearch
9
+
10
+ class OptParseMain
11
+
12
+ def self.parse(args)
13
+ options = OpenStruct.new
14
+ options.operation = :search
15
+ options.query = ''
16
+ options.refresh = false
17
+ options.engine = :all # :opensuse, :packman
18
+ options.timeout = 20
19
+ options.formats = :compatible # :all
20
+ options.distributions = :compatible # :all
21
+ options.types = [:supported, :community, :experimental]
22
+ options.number = 0
23
+ options.view = :table
24
+ options.format = :all # or single format
25
+ #options.preload = nil #used by :links or :page operations
26
+
27
+ opt_parser = OptionParser.new do |opt|
28
+
29
+ if ENV['ZYPPER_ONLINESEARCH']
30
+ opt.banner = 'Usage: zypper onlinesearch [OPTIONS] [OPERATION]'
31
+ else
32
+ opt.banner = 'Usage: onlinesearch [OPTIONS] [OPERATION]'
33
+ end
34
+
35
+ opt.separator ''
36
+ opt.separator 'Operations:'
37
+
38
+ opt.on('-s', '--search <STRING>', 'Search for STRING to the online engines available') do |o|
39
+ options.operation = :search
40
+ options.query = o
41
+ end
42
+
43
+ opt.on('-p', '--page <PAGE_NAME>', 'Get info about the PAGE_NAME') do |o|
44
+ options.operation = :page
45
+ options.query = o
46
+ end
47
+
48
+ opt.on('-l', '--links <PAGE_NAME>,<NTH>', Array, 'Print all the links of the NTH item in the PAGE_NAME') do |o|
49
+ options.operation = :links
50
+ options.query = o[0]
51
+ options.number = o[1].to_i
52
+ #options.preload = :page
53
+ end
54
+
55
+ opt.on('--clean-cache', 'Clean the whole cache') do |o|
56
+ options.operation = :cache_clean
57
+ end
58
+
59
+ opt.separator ''
60
+ opt.separator 'General Options'
61
+
62
+ opt.on('--engine <ENGINE>', 'Use only ENGINE to search for (default: ' + options.engine.to_s + ', alternatives: ' + Request::Search.constants.map(&:to_s).map(&:downcase).join(', ') + ')') do |o|
63
+ options.engine = o.to_sym
64
+ end
65
+
66
+ opt.on('--refresh', 'Refresh the cached values.') do |o|
67
+ options.refresh = true
68
+ end
69
+
70
+ opt.on('--timeout <SECONDS>', "Adjust the waiting SECONDS used to catch an HTTP Timeout Error (Default: #{options.timeout})") do |o|
71
+ options.timeout = o.to_f
72
+ end
73
+
74
+ opt.separator ''
75
+ opt.separator 'View options:'
76
+
77
+ opt.on('--table', 'Show the results as a table [DEFAULT]') do |o|
78
+ options.view = :table
79
+ end
80
+
81
+ opt.on('--report', 'Show the results as report') do |o|
82
+ options.view = :report
83
+ end
84
+
85
+ opt.separator ''
86
+ opt.separator '"Page" and "Links" options:'
87
+
88
+ opt.on('--all-formats', 'Show all the available formats') do |o|
89
+ options.formats = :all
90
+ end
91
+
92
+ opt.on('--all-distributions', 'Show all the available distributions') do |o|
93
+ options.distributions = :all
94
+ end
95
+
96
+ opt.on('--no-supported', 'Hide supported packages.') do |o|
97
+ options.types.delete :supported
98
+ end
99
+
100
+ opt.on('--no-experimental', 'Hide experimental packages.') do |o|
101
+ options.types.delete :experimental
102
+ end
103
+
104
+ opt.on('--no-community', 'Hide community packages.') do |o|
105
+ options.types.delete :community
106
+ end
107
+
108
+ opt.separator ''
109
+ opt.separator '"Links" options:'
110
+
111
+ opt.on('--format FORMAT', 'Filter for packages with the specified FORMAT') do |o|
112
+ options.format = o.to_sym
113
+ end
114
+
115
+ opt.on('--urls', 'Show only the urls without headers') do |o|
116
+ options.view = :urls
117
+ end
118
+
119
+ unless ENV['ZYPPER_ONLINESEARCH']
120
+ opt.separator ''
121
+ opt.separator 'Other:'
122
+
123
+ opt.on_tail('-h', '--help', 'Show this message') do |o|
124
+ puts opt
125
+ exit
126
+ end
127
+
128
+ opt.on_tail('-v', '--version', 'Show version') do |o|
129
+ puts VERSION
130
+ exit
131
+ end
132
+ end
133
+
134
+ end
135
+
136
+
137
+ if ARGV.empty?
138
+ puts opt_parser; exit
139
+ else
140
+ opt_parser.parse!(ARGV)
141
+ end
142
+
143
+ options
144
+ end
145
+ end
146
+
147
+
148
+ class CLI
149
+ def self.start
150
+ begin
151
+ options = OptParseMain.parse(ARGV)
152
+ Onlinesearch::Builder.new(options).send(options.operation)
153
+ rescue => e
154
+ Messages.error e
155
+ exit e.error_code
156
+ end
157
+ end
158
+ end
159
+
160
+ end
161
+ end
162
+