getv 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8b7033c123fd837edd23f202973d20c313932df2e35bb8eb680c2ecd4aa3f674
4
- data.tar.gz: 5e66336327fc70676fba92f92eb56398b00bdfcc780cf4ec54365c38bf1edce3
3
+ metadata.gz: daac0f934a1cdcea8875d71dc0a2579df0cfc79a11c81adf11249aa0a3fc14c8
4
+ data.tar.gz: 6af122cebd5cb12cbd1c11bc615c5e2eb9aaec166ac5d7b7b55c456d496e1e4f
5
5
  SHA512:
6
- metadata.gz: cf6eb57389b7cf24b99177a8dba23da0095719da908672489b5e137e4c89aee948fd134f28bba952785098db43f60cf2645b2bf0bfaffcb81be849382c26db5b
7
- data.tar.gz: 1b24a3216e4b33febabe870994c901c48e17108718f5d5d86dee79f0dabd77936e26b20a3b19ea41160a7774e8eb2e27ae69a31d32fd887d192a6c2ba52e7ffb
6
+ metadata.gz: 77e6a4c99d59ecf7f6bfaf9a10e37854ea90d80cc41115a581c84398f52d9c1048059a66482860add6ecc4f80d593ddab9481a2cc313b61fbef7bc2b417e2ce6
7
+ data.tar.gz: 1c578d98f20fa6d690b2b4db46f2cb5b21af39ece384a4ec08d57c7f2a12c6aa3a8ac1ea07d74115ab37c7b711eb74c4b02a3113d6722a958f6b4959b7e8bdc4
@@ -0,0 +1,37 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Ruby
9
+
10
+ on:
11
+ push:
12
+ branches: [ main ]
13
+ pull_request:
14
+ branches: [ main ]
15
+
16
+ jobs:
17
+ test:
18
+
19
+ runs-on: ubuntu-latest
20
+ strategy:
21
+ matrix:
22
+ ruby-version: ['2.6', '2.7', '3.0']
23
+
24
+ steps:
25
+ - uses: actions/checkout@v2
26
+ - name: Set up Ruby
27
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
28
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
29
+ # uses: ruby/setup-ruby@v1
30
+ uses: ruby/setup-ruby@v1
31
+ with:
32
+ ruby-version: ${{ matrix.ruby-version }}
33
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
34
+ - name: Run linter
35
+ run: bundle exec rake rubocop
36
+ - name: Run unit tests
37
+ run: bundle exec rake
data/.gitignore CHANGED
@@ -1,4 +1,7 @@
1
- /bin/
1
+ /bin/*
2
+ !/bin/console
3
+ !/bin/getv
4
+ !/bin/setup
2
5
  /bundle/
3
6
  /.yardoc
4
7
  /_yardoc/
data/.rubocop.yml CHANGED
@@ -1,8 +1,11 @@
1
1
  ---
2
+ require:
3
+ - rubocop-rspec
2
4
  AllCops:
3
5
  Exclude:
4
- - 'bin/**/*'
6
+ - !ruby/regexp /\/bin\/\b(?!getv\b)\w+/
5
7
  - 'bundle/**/*'
8
+ - 'vendor/**/*'
6
9
  - '*.gemspec'
7
10
  NewCops: enable
8
11
 
@@ -10,5 +13,4 @@ Metrics/BlockLength:
10
13
  Exclude:
11
14
  - 'Rakefile'
12
15
  - '**/*.rake'
13
- - 'test/**/*.rb'
14
16
  - 'spec/**/*_spec.rb'
data/Gemfile CHANGED
@@ -6,6 +6,7 @@ source 'https://rubygems.org'
6
6
  gemspec
7
7
 
8
8
  gem 'docker_registry2', '~> 1.10'
9
+ gem 'gli', '~> 2.20'
9
10
  gem 'irb', '~> 1.4'
10
11
  gem 'nokogiri', '~> 1.13'
11
12
  gem 'octokit', '~> 4.21'
data/README.md CHANGED
@@ -1,10 +1,16 @@
1
- # Getv
1
+ # getv
2
2
 
3
- Pull package version numbers from the web in various ways.
3
+ The goal of `getv` is to make it easy and quick to pull software package version numbers from various sources on the web. The application is packaged as a [gem](https://rubygems.org/gems/getv) and provides both a Ruby library and an executable command line tool, `getv`.
4
4
 
5
5
  ## Installation
6
6
 
7
- Add this line to your application's Gemfile:
7
+ Install `getv` with:
8
+
9
+ ```
10
+ gem install getv
11
+ ```
12
+
13
+ Or add this line to your application's Gemfile:
8
14
 
9
15
  ```ruby
10
16
  gem 'getv'
@@ -12,50 +18,132 @@ gem 'getv'
12
18
 
13
19
  And then execute:
14
20
 
15
- $ bundle install
21
+ ```sh
22
+ bundle install
23
+ ```
24
+
25
+ ## CLI
26
+
27
+ An executable command tool, `getv` is bundled with this gem:
28
+
29
+ ```console
30
+ $ getv
31
+ NAME
32
+ getv - Get package version numbers from the web in various ways
33
+
34
+
35
+ SYNOPSIS
36
+ getv [global options] command [command options] [arguments...]
37
+
16
38
 
17
- Or install it yourself as:
39
+ VERSION
40
+ 1.1.0
18
41
 
19
- $ gem install getv
20
42
 
21
- ## Usage
22
43
 
44
+ GLOBAL OPTIONS
45
+ --help - Show this message
46
+ -j, --json - Output in json
47
+ -l, --latest - Latest version
48
+ --reject=arg - Regex version rejection (default: none)
49
+ --select_replace=arg - Regex version selection replace (default: none)
50
+ --select_search=arg - Regex version selection search (default: none)
51
+ --version - Display the program version
52
+
53
+
54
+
55
+ COMMANDS
56
+ docker - Get package versions from a Docker or OCI container image registry
57
+ gem - Get package versions from RubyGems.org
58
+ get - Get package versions from text file URL
59
+ github_commit - Get package versions from GitHub commits
60
+ github_release - Get package versions from GitHub releases
61
+ github_tag - Get package versions from GitHub tags
62
+ help - Shows a list of commands or help for one command
63
+ index - Get package versions from web page of links
64
+ npm - Get package versions from npm at registry.npmjs.org
65
+ pypi - Get package versions from the Python Package Index at pypi.org
23
66
  ```
24
- irb(main):024:0> superset = Getv::Package.new('superset', type: 'docker', owner: 'apache', reject: '-')
25
- =>
26
- #<Getv::Package:0x000055b6d2326f20
27
- ...
28
- irb(main):025:0> superset.versions
29
- => ["1.0.0", "1.0.1", "1.1.0", "1.2.0", "1.3.0", "1.3.1", "1.3.2"]
30
- irb(main):026:0> superset.latest_version
31
- => "1.3.2"
32
- irb(main):027:0> superset
33
- =>
34
- #<Getv::Package:0x000055b6d2326f20
35
- @name="superset",
36
- @opts=
37
- {:owner=>"apache",
38
- :repo=>"superset",
39
- :url=>"https://registry.hub.docker.com",
40
- :type=>"docker",
41
- :select=>{:search=>"^\\s*v?((0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?)\\s*$", :replace=>"\\1"},
42
- :reject=>"-",
43
- :semantic_only=>true,
44
- :semantic_select=>["*"],
45
- :versions=>["1.0.0", "1.0.1", "1.1.0", "1.2.0", "1.3.0", "1.3.1", "1.3.2"],
46
- :latest_version=>"1.3.2"}>
67
+
68
+ ### CLI examples
69
+
70
+ Show the latest available version of the `getv` gem:
71
+
72
+ ```console
73
+ $ getv --latest gem getv
74
+ 1.1.0
47
75
  ```
48
76
 
49
- ## Development
77
+ Show all `dep` GitHub release versions in JSON:
50
78
 
51
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
79
+ ```console
80
+ $ getv --json github_release golang/dep
81
+ {"name":"golang/dep","versions":["0.2.0","0.2.1","0.3.0","0.3.1","0.3.2","0.4.0","0.4.1","0.5.0","0.5.1","0.5.2","0.5.3","0.5.4"]}
82
+ ```
52
83
 
53
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
84
+ Show all AtomicParsley Github release versions:
54
85
 
55
- ## Contributing
86
+ ```console
87
+ $ getv --select_search='(.*)' github_release --invalid_versions wez/atomicparsley
88
+ 20200701.154658.b0d6223
89
+ 20201231.092811.cbecfb1
90
+ 20210114.184825.1dbe1be
91
+ 20210124.204813.840499f
92
+ 20210617.200601.1ac7c08
93
+ 20210715.151551.e7ad03a
94
+ ```
95
+
96
+ Show the latest stable version of Kubernetes using the release text file URL:
56
97
 
57
- Bug reports and pull requests are welcome on GitHub at https://github.com/liger1978/getv.
98
+ ```console
99
+ $ getv -l get --url=https://storage.googleapis.com/kubernetes-release/release/stable.txt kubernetes
100
+ 1.23.2
101
+ ```
102
+
103
+ Show selected semantic versions of the `apache/superset` Docker image in JSON:
104
+
105
+ ```console
106
+ $ getv --json --reject '-' docker --semantic_select '~>1.3.0,!=1.3.1' apache/superset
107
+ {"name":"apache/superset","versions":["1.3.0","1.3.2"]}
108
+ ```
109
+
110
+ Show all versions of `libnetfilter_acct` using selected link values on an indexed web page:
111
+
112
+ ```console
113
+ $ getv --select_search='^.*libnetfilter_acct-([\d\.]*)\.tar\.bz2$' index --url=https://netfilter.org/projects/libnetfilter_acct/files --link_value libnetfilter_acct
114
+ 1.0.0
115
+ 1.0.1
116
+ 1.0.2
117
+ 1.0.3
118
+ ```
119
+
120
+ Show the latest GitHub commit to the `main` branch of the `getv` project in a useful versioning format:
121
+
122
+ ```console
123
+ # By default the \2 capture group contains the date and \5 contains the short commit hash
124
+ $ getv -l --select_replace '\2git\5' github_commit --branch main liger1978/getv
125
+ 20220123git9ed86f0
126
+ ```
127
+
128
+ ## Ruby library
129
+
130
+ Example:
131
+
132
+ ```ruby
133
+ require 'getv'
134
+
135
+ superset = Getv::Package.new 'superset', type: 'docker', owner: 'apache', reject: '-'
136
+ puts superset.versions
137
+ puts superset.latest_version
138
+ ```
139
+
140
+ ## Development
141
+
142
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rake spec` to run the tests. Run `bundle exec rubocop` to run the linter. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
143
+
144
+ ## Contributing
58
145
 
146
+ Bug reports and pull requests are welcome on [GitHub](https://github.com/liger1978/getv).
59
147
 
60
148
  ## License
61
149
 
data/Rakefile CHANGED
@@ -2,7 +2,12 @@
2
2
 
3
3
  require 'bundler/gem_tasks'
4
4
  require 'rspec/core/rake_task'
5
+ require 'rubocop/rake_task'
5
6
 
6
7
  RSpec::Core::RakeTask.new(:spec)
7
8
 
9
+ RuboCop::RakeTask.new do |task|
10
+ task.requires << 'rubocop-rspec'
11
+ end
12
+
8
13
  task default: :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "getv"
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/getv ADDED
@@ -0,0 +1,265 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'getv'
5
+ require 'gli'
6
+
7
+ module Getv
8
+ # cli class
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
22
+ require 'json'
23
+ puts({
24
+ 'name' => package.name,
25
+ 'versions' => package.versions
26
+ }.to_json)
27
+ else
28
+ puts package.versions
29
+ end
30
+ end
31
+ end
32
+ end
33
+
34
+ # app class
35
+ class App # rubocop:disable Metrics/ClassLength
36
+ extend GLI::App
37
+
38
+ program_desc 'Get package version numbers from the web in various ways'
39
+
40
+ version Getv::VERSION
41
+
42
+ subcommand_option_handling :normal
43
+ arguments :strict
44
+
45
+ switch %i[l latest], desc: 'Latest version', negatable: false
46
+ switch %i[j json], desc: 'Output in json', negatable: false
47
+ flag %i[select_search], desc: 'Regex version selection search'
48
+ flag %i[select_replace], desc: 'Regex version selection replace'
49
+ flag %i[reject], desc: 'Regex version rejection'
50
+
51
+ desc 'Get package versions from a Docker or OCI container image registry'
52
+ arg_name 'package_name'
53
+ command :docker do |c|
54
+ c.switch %i[invalid_versions], desc: 'Include invalid semantic versions', negatable: false, default_value: false
55
+ c.flag %i[semantic_select], desc: 'Semantic version selection (comma delimited)'
56
+ c.flag %i[owner], desc: 'Repository owner'
57
+ c.flag %i[repo], desc: 'Repository name'
58
+ c.flag %i[url], desc: 'URL'
59
+ c.action do |global_options, options, args|
60
+ if args.size == 1
61
+ opts = global_options.merge(options)
62
+ opts = opts.slice :select_search, :select_replace, :reject, :semantic_only, :semantic_select, :owner, :repo,
63
+ :url
64
+ opts = opts.delete_if { |_k, v| v.nil? }
65
+ opts[:semantic_only] = !options[:invalid_versions]
66
+ opts[:semantic_select] = opts[:semantic_select].split(',') unless opts.fetch(:semantic_select, nil).nil?
67
+ package = Getv::Package.new args[0], { type: c.name.to_s }.merge(opts)
68
+ Getv::Cli.output(package, latest: global_options[:latest], json: global_options[:json])
69
+ else
70
+ help_now!
71
+ end
72
+ end
73
+ end
74
+
75
+ desc 'Get package versions from RubyGems.org'
76
+ arg_name 'package_name'
77
+ command :gem do |c|
78
+ c.switch %i[invalid_versions], desc: 'Include invalid semantic versions', negatable: false, default_value: false
79
+ c.flag %i[semantic_select], desc: 'Semantic version selection (comma delimited)'
80
+ c.action do |global_options, options, args|
81
+ if args.size == 1
82
+ opts = global_options.merge(options)
83
+ opts = opts.slice :select_search, :select_replace, :reject, :semantic_only, :semantic_select
84
+ opts = opts.delete_if { |_k, v| v.nil? }
85
+ opts[:semantic_only] = !options[:invalid_versions]
86
+ opts[:semantic_select] = opts[:semantic_select].split(',') unless opts.fetch(:semantic_select, nil).nil?
87
+ package = Getv::Package.new args[0], { type: c.name.to_s }.merge(opts)
88
+ Getv::Cli.output(package, latest: global_options[:latest], json: global_options[:json])
89
+ else
90
+ help_now!
91
+ end
92
+ end
93
+ end
94
+
95
+ desc 'Get package versions from text file URL'
96
+ arg_name 'package_name'
97
+ command :get do |c|
98
+ c.switch %i[invalid_versions], desc: 'Include invalid semantic versions', negatable: false, default_value: false
99
+ c.flag %i[semantic_select], desc: 'Semantic version selection (comma delimited)'
100
+ c.flag %i[url], desc: 'URL'
101
+ c.action do |global_options, options, args|
102
+ if args.size == 1
103
+ opts = global_options.merge(options)
104
+ opts = opts.slice :select_search, :select_replace, :reject, :semantic_only, :semantic_select, :url
105
+ opts = opts.delete_if { |_k, v| v.nil? }
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])
110
+ else
111
+ help_now!
112
+ end
113
+ end
114
+ end
115
+
116
+ desc 'Get package versions from GitHub commits. Set environment variable $GITHUB_TOKEN to avoid GitHub API limit.'
117
+ arg_name 'package_name'
118
+ command :github_commit do |c|
119
+ c.flag %i[owner], desc: 'Repository owner'
120
+ c.flag %i[repo], desc: 'Repository name'
121
+ c.flag %i[branch], desc: 'Repository branch'
122
+ c.action do |global_options, options, args|
123
+ if args.size == 1
124
+ opts = global_options.merge(options)
125
+ opts = opts.slice :select_search, :select_replace, :reject, :owner, :repo, :branch
126
+ opts = opts.delete_if { |_k, v| v.nil? }
127
+ package = Getv::Package.new args[0], { type: c.name.to_s }.merge(opts)
128
+ Getv::Cli.output(package, latest: global_options[:latest], json: global_options[:json])
129
+ else
130
+ help_now!
131
+ end
132
+ end
133
+ end
134
+
135
+ desc 'Get package versions from GitHub releases. Set environment variable $GITHUB_TOKEN to avoid GitHub API limit.'
136
+ arg_name 'package_name'
137
+ command :github_release do |c|
138
+ c.switch %i[invalid_versions], desc: 'Include invalid semantic versions', negatable: false, default_value: false
139
+ c.flag %i[semantic_select], desc: 'Semantic version selection (comma delimited)'
140
+ c.flag %i[owner], desc: 'Repository owner'
141
+ c.flag %i[repo], desc: 'Repository name'
142
+ 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, :semantic_only, :semantic_select, :owner, :repo
146
+ opts = opts.delete_if { |_k, v| v.nil? }
147
+ opts[:semantic_only] = !options[:invalid_versions]
148
+ opts[:semantic_select] = opts[:semantic_select].split(',') unless opts.fetch(:semantic_select, nil).nil?
149
+ package = Getv::Package.new args[0], { type: c.name.to_s }.merge(opts)
150
+ Getv::Cli.output(package, latest: global_options[:latest], json: global_options[:json])
151
+ else
152
+ help_now!
153
+ end
154
+ end
155
+ end
156
+
157
+ desc 'Get package versions from GitHub tags. Set environment variable $GITHUB_TOKEN to avoid GitHub API limit.'
158
+ arg_name 'package_name'
159
+ command :github_tag do |c|
160
+ c.switch %i[invalid_versions], desc: 'Include invalid semantic versions', negatable: false, default_value: false
161
+ c.flag %i[semantic_select], desc: 'Semantic version selection (comma delimited)'
162
+ c.flag %i[owner], desc: 'Repository owner'
163
+ c.flag %i[repo], desc: 'Repository name'
164
+ c.action do |global_options, options, args|
165
+ if args.size == 1
166
+ opts = global_options.merge(options)
167
+ opts = opts.slice :select_search, :select_replace, :reject, :semantic_only, :semantic_select, :owner, :repo
168
+ opts = opts.delete_if { |_k, v| v.nil? }
169
+ opts[:semantic_only] = !options[:invalid_versions]
170
+ opts[:semantic_select] = opts[:semantic_select].split(',') unless opts.fetch(:semantic_select, nil).nil?
171
+ package = Getv::Package.new args[0], { type: c.name.to_s }.merge(opts)
172
+ Getv::Cli.output(package, latest: global_options[:latest], json: global_options[:json])
173
+ else
174
+ help_now!
175
+ end
176
+ end
177
+ end
178
+
179
+ desc 'Get package versions from web page of links'
180
+ arg_name 'package_name'
181
+ command :index do |c|
182
+ c.switch %i[invalid_versions], desc: 'Include invalid semantic versions', negatable: false, default_value: false
183
+ c.flag %i[semantic_select], desc: 'Semantic version selection (comma delimited)'
184
+ c.flag %i[url], desc: 'URL'
185
+ c.switch %i[link_value], desc: 'Use the value (target) of links rather than the content (display text)',
186
+ negatable: false, default_value: false
187
+ c.action do |global_options, options, args|
188
+ if args.size == 1
189
+ opts = global_options.merge(options)
190
+ opts = opts.slice :select_search, :select_replace, :reject, :semantic_only, :semantic_select, :url
191
+ opts = opts.delete_if { |_k, v| v.nil? }
192
+ opts[:link] == 'value' if options[:link_value]
193
+ opts[:semantic_only] = !options[:invalid_versions]
194
+ opts[:semantic_select] = opts[:semantic_select].split(',') unless opts.fetch(:semantic_select, nil).nil?
195
+ package = Getv::Package.new args[0], { type: c.name.to_s }.merge(opts)
196
+ Getv::Cli.output(package, latest: global_options[:latest], json: global_options[:json])
197
+ else
198
+ help_now!
199
+ end
200
+ end
201
+ end
202
+
203
+ desc 'Get package versions from npm at registry.npmjs.org'
204
+ arg_name 'package_name'
205
+ command :npm do |c|
206
+ c.switch %i[invalid_versions], desc: 'Include invalid semantic versions', negatable: false, default_value: false
207
+ c.flag %i[semantic_select], desc: 'Semantic version selection (comma delimited)'
208
+ c.action do |global_options, options, args|
209
+ if args.size == 1
210
+ opts = global_options.merge(options)
211
+ opts = opts.slice :select_search, :select_replace, :reject, :semantic_only, :semantic_select
212
+ opts = opts.delete_if { |_k, v| v.nil? }
213
+ opts[:semantic_only] = !options[:invalid_versions]
214
+ opts[:semantic_select] = opts[:semantic_select].split(',') unless opts.fetch(:semantic_select, nil).nil?
215
+ package = Getv::Package.new args[0], { type: c.name.to_s }.merge(opts)
216
+ Getv::Cli.output(package, latest: global_options[:latest], json: global_options[:json])
217
+ else
218
+ help_now!
219
+ end
220
+ end
221
+ end
222
+
223
+ desc 'Get package versions from the Python Package Index at pypi.org'
224
+ arg_name 'package_name'
225
+ command :pypi do |c|
226
+ c.switch %i[invalid_versions], desc: 'Include invalid semantic versions', negatable: false, default_value: false
227
+ c.flag %i[semantic_select], desc: 'Semantic version selection (comma delimited)'
228
+ c.action do |global_options, options, args|
229
+ if args.size == 1
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? }
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])
237
+ else
238
+ help_now!
239
+ end
240
+ end
241
+ end
242
+
243
+ pre do |_global, _command, _options, _args|
244
+ # Pre logic here
245
+ # Return true to proceed; false to abort and not call the
246
+ # chosen command
247
+ # Use skips_pre before a command to skip this block
248
+ # on that command only
249
+ true
250
+ end
251
+
252
+ post do |global, command, options, args|
253
+ # Post logic here
254
+ # Use skips_post before a command to skip this
255
+ # block on that command only
256
+ end
257
+
258
+ on_error do |_exception|
259
+ # Error logic here
260
+ # return false to skip default error handling
261
+ true
262
+ end
263
+ end
264
+
265
+ exit App.run(ARGV)
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/getv.gemspec CHANGED
@@ -26,6 +26,7 @@ Gem::Specification.new do |spec|
26
26
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
27
  spec.require_paths = ['lib']
28
28
 
29
+ spec.add_dependency('gli', '>= 2.20.1', '< 3.0.0')
29
30
  spec.add_dependency('docker_registry2', '>= 1.0.0', '< 2.0.0')
30
31
  spec.add_dependency('nokogiri', '>= 1.0.0', '< 2.0.0')
31
32
  spec.add_dependency('octokit', '>= 3.0.0', '< 5.0.0')
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.1.0'
4
+ VERSION = '1.2.0'
5
5
  end
metadata CHANGED
@@ -1,15 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: getv
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - harbottle
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-18 00:00:00.000000000 Z
11
+ date: 2022-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: gli
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 2.20.1
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: 3.0.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 2.20.1
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: 3.0.0
13
33
  - !ruby/object:Gem::Dependency
14
34
  name: docker_registry2
15
35
  requirement: !ruby/object:Gem::Requirement
@@ -98,6 +118,7 @@ extensions: []
98
118
  extra_rdoc_files: []
99
119
  files:
100
120
  - ".bundle/config"
121
+ - ".github/workflows/ruby.yml"
101
122
  - ".gitignore"
102
123
  - ".rspec"
103
124
  - ".rubocop.yml"
@@ -106,6 +127,9 @@ files:
106
127
  - LICENSE.txt
107
128
  - README.md
108
129
  - Rakefile
130
+ - bin/console
131
+ - bin/getv
132
+ - bin/setup
109
133
  - getv.gemspec
110
134
  - lib/getv.rb
111
135
  - lib/getv/package.rb
@@ -117,7 +141,7 @@ metadata:
117
141
  homepage_uri: https://github.com/liger1978/getv
118
142
  source_code_uri: https://github.com/liger1978/getv
119
143
  changelog_uri: https://github.com/liger1978/getv
120
- post_install_message:
144
+ post_install_message:
121
145
  rdoc_options: []
122
146
  require_paths:
123
147
  - lib
@@ -132,8 +156,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
156
  - !ruby/object:Gem::Version
133
157
  version: '0'
134
158
  requirements: []
135
- rubygems_version: 3.0.3
136
- signing_key:
159
+ rubygems_version: 3.2.22
160
+ signing_key:
137
161
  specification_version: 4
138
162
  summary: Pull package version numbers from the web in various ways.
139
163
  test_files: []