getv 2.0.0 → 2.1.2

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: 519a4f5ae5d2129555292f828f3f60ec48f600b738ff2841477d3366502851c7
4
- data.tar.gz: 23a08397b4fe40ca7512b1939ba43dd5262c404d09f8e08f4332e114ab184a0f
3
+ metadata.gz: 4a93d786b9109d9f99361e2e5fbda52af315ee2945d1d286910a2f26afcf4426
4
+ data.tar.gz: d39c715cf2a38fee4a326d577bf238ae44399078ef562d1f585945bc012377b2
5
5
  SHA512:
6
- metadata.gz: 2c076cf15bee2101cfa3c1c53657c39a75e9d5accec6dc0c1949c82e459f925b7c51156c8ee1f8ee49d2c46a1d5811ddeba7dc83ad4a194285769db51ee629dd
7
- data.tar.gz: d4624767daa67dd937992b6da9ce2c909fc26d5eb67267dc2c6b70cf40f29291edf37fc991f9c29e21fa034c65e0524a0fa22575141297453e42acfa461b8a17
6
+ metadata.gz: 0bbd5cfeff4a45f151a77dcfe7660cf4a333852419b68df6f4b21d5acef4dd8cb4facd48a34b1e5eaff35905f62c10a9378c6d5afadcbc9eb17d42edfb435bfa
7
+ data.tar.gz: 71a67c7993e38745ea78880b68abffe0284c6260357585d55b887c11d53be23b805739b15da2a91d520fa53161f8e938e645a15fbef1acacafa988e07a5f2928
data/README.md CHANGED
@@ -39,7 +39,7 @@ SYNOPSIS
39
39
 
40
40
 
41
41
  VERSION
42
- 2.0.0
42
+ 2.1.2
43
43
 
44
44
 
45
45
 
@@ -72,7 +72,7 @@ Show the latest available version of the `getv` gem:
72
72
 
73
73
  ```console
74
74
  $ getv --latest gem getv
75
- 2.0.0
75
+ 2.1.2
76
76
  ```
77
77
 
78
78
  Show all `dep` GitHub release versions in JSON:
@@ -97,7 +97,7 @@ $ getv github_release --invalid_versions wez/atomicparsley
97
97
  Show the latest stable version of Kubernetes using the release text file URL:
98
98
 
99
99
  ```console
100
- $ getv -l get --url=https://storage.googleapis.com/kubernetes-release/release/stable.txt kubernetes
100
+ $ getv -l text --url=https://storage.googleapis.com/kubernetes-release/release/stable.txt kubernetes
101
101
  1.23.2
102
102
  ```
103
103
 
@@ -136,6 +136,13 @@ require 'getv'
136
136
  superset = Getv::Package::Docker.new 'apache/superset', reject: '-'
137
137
  puts superset.versions
138
138
  puts superset.latest_version
139
+
140
+ # You can also use the flexible "create" factory method
141
+ Getv::Package.create 'apache/superset', type: 'docker', reject: '-'
142
+ Getv::Package.create 'golang/dep', type: 'github release'
143
+ Getv::Package.create 'golang/dep', type: 'github_release'
144
+ Getv::Package.create 'golang/dep', type: 'GitHub::Release'
145
+ Getv::Package.create 'rubygem-getv'
139
146
  ```
140
147
 
141
148
  ## Development
@@ -38,10 +38,13 @@ module Getv
38
38
 
39
39
  def retrieve_versions
40
40
  require 'docker_registry2'
41
+ retries ||= 0
41
42
  docker = DockerRegistry2.connect(opts[:url], docker_opts)
42
- docker.tags("#{opts[:owner]}/#{opts[:repo]}")['tags']
43
+ docker.tags("#{opts[:owner]}/#{opts[:repo]}")['tags'] || []
43
44
  rescue DockerRegistry2::NotFound
44
45
  []
46
+ rescue StandardError
47
+ retry if (retries += 1) < 4
45
48
  end
46
49
  end
47
50
  end
@@ -14,9 +14,12 @@ module Getv
14
14
 
15
15
  def retrieve_versions
16
16
  require 'json'
17
+ retries ||= 0
17
18
  JSON.parse(get("https://rubygems.org/api/v1/versions/#{opts[:gem]}.json")).map do |v|
18
19
  v['number']
19
20
  end
21
+ rescue StandardError
22
+ retry if (retries += 1) < 4
20
23
  end
21
24
  end
22
25
  end
@@ -18,10 +18,13 @@ module Getv
18
18
 
19
19
  private
20
20
 
21
- def retrieve_versions
21
+ def retrieve_versions # rubocop:disable Metrics/AbcSize
22
+ retries ||= 0
22
23
  github.commits("#{opts[:owner]}/#{opts[:repo]}", opts[:branch]).map do |c|
23
24
  "#{DateTime.parse(c[:commit][:author][:date].to_s).strftime('%Y%m%d%H%M%S')},#{c[:sha]}"
24
25
  end
26
+ rescue StandardError
27
+ retry if (retries += 1) < 4
25
28
  end
26
29
  end
27
30
  end
@@ -14,7 +14,10 @@ module Getv
14
14
  private
15
15
 
16
16
  def retrieve_versions
17
+ retries ||= 0
17
18
  github.releases("#{opts[:owner]}/#{opts[:repo]}").map(&:tag_name)
19
+ rescue StandardError
20
+ retry if (retries += 1) < 4
18
21
  end
19
22
  end
20
23
  end
@@ -14,7 +14,10 @@ module Getv
14
14
  private
15
15
 
16
16
  def retrieve_versions
17
+ retries ||= 0
17
18
  github.tags("#{opts[:owner]}/#{opts[:repo]}").map { |t| t[:name] }
19
+ rescue StandardError
20
+ retry if (retries += 1) < 4
18
21
  end
19
22
  end
20
23
  end
@@ -14,9 +14,12 @@ module Getv
14
14
 
15
15
  def retrieve_versions
16
16
  require 'yaml'
17
+ retries ||= 0
17
18
  YAML.safe_load(get("#{opts[:url]}/index.yaml")).fetch('entries', {}).fetch(opts[:chart], []).map do |e|
18
19
  e['version']
19
20
  end
21
+ rescue StandardError
22
+ retry if (retries += 1) < 4
20
23
  end
21
24
  end
22
25
  end
@@ -14,7 +14,10 @@ module Getv
14
14
 
15
15
  def retrieve_versions
16
16
  require 'json'
17
+ retries ||= 0
17
18
  JSON.parse(get("https://registry.npmjs.org/#{opts[:npm]}"))['versions'].keys
19
+ rescue StandardError
20
+ retry if (retries += 1) < 4
18
21
  end
19
22
  end
20
23
  end
@@ -14,7 +14,10 @@ module Getv
14
14
 
15
15
  def retrieve_versions
16
16
  require 'json'
17
+ retries ||= 0
17
18
  JSON.parse(get("https://pypi.org/pypi/#{opts[:pypi]}/json"))['releases'].keys
19
+ rescue StandardError
20
+ retry if (retries += 1) < 4
18
21
  end
19
22
  end
20
23
  end
@@ -13,7 +13,10 @@ module Getv
13
13
  private
14
14
 
15
15
  def retrieve_versions
16
+ retries ||= 0
16
17
  get(opts[:url]).split("\n")
18
+ rescue StandardError
19
+ retry if (retries += 1) < 4
17
20
  end
18
21
  end
19
22
  end
@@ -13,8 +13,11 @@ module Getv
13
13
  private
14
14
 
15
15
  def retrieve_versions
16
+ retries ||= 0
16
17
  require 'nokogiri'
17
18
  Nokogiri::XML(get(opts[:url])).xpath(opts[:xpath]).map(&:text)
19
+ rescue StandardError
20
+ retry if (retries += 1) < 4
18
21
  end
19
22
  end
20
23
  end
data/lib/getv/package.rb CHANGED
@@ -6,6 +6,17 @@ module Getv
6
6
  attr_accessor :name, :opts
7
7
 
8
8
  def self.create(name, opts = {})
9
+ if opts.fetch(:type, nil).nil?
10
+ opts.delete(:type)
11
+ create_using_name(name, opts)
12
+ else
13
+ type = opts[:type]
14
+ opts.delete(:type)
15
+ type_to_class(type).new name, opts
16
+ end
17
+ end
18
+
19
+ private_class_method def self.create_using_name(name, opts)
9
20
  case name
10
21
  when /ruby(gem)?-.*/
11
22
  Getv::Package::Gem.new name, opts
@@ -18,6 +29,14 @@ module Getv
18
29
  end
19
30
  end
20
31
 
32
+ private_class_method def self.type_to_class(type)
33
+ sections = type.split(/_|::| |-|:/)
34
+ sections.each(&:capitalize!)
35
+ sections.each { |section| section.sub! 'Github', 'GitHub' }
36
+ type = sections.join '::'
37
+ Object.const_get("Getv::Package::#{type}")
38
+ end
39
+
21
40
  def initialize(name, opts = {})
22
41
  @name = name
23
42
  @opts = opts
data/lib/getv/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Getv
4
- VERSION = '2.0.0'
4
+ VERSION = '2.1.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: getv
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.2
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-03-02 00:00:00.000000000 Z
11
+ date: 2022-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gli
@@ -162,7 +162,7 @@ metadata:
162
162
  homepage_uri: https://github.com/liger1978/getv
163
163
  source_code_uri: https://github.com/liger1978/getv
164
164
  changelog_uri: https://github.com/liger1978/getv
165
- post_install_message:
165
+ post_install_message:
166
166
  rdoc_options: []
167
167
  require_paths:
168
168
  - lib
@@ -177,8 +177,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
177
177
  - !ruby/object:Gem::Version
178
178
  version: '0'
179
179
  requirements: []
180
- rubygems_version: 3.2.22
181
- signing_key:
180
+ rubygems_version: 3.1.2
181
+ signing_key:
182
182
  specification_version: 4
183
183
  summary: Pull package version numbers from the web in various ways.
184
184
  test_files: []