getv 2.0.0 → 2.1.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: 519a4f5ae5d2129555292f828f3f60ec48f600b738ff2841477d3366502851c7
4
- data.tar.gz: 23a08397b4fe40ca7512b1939ba43dd5262c404d09f8e08f4332e114ab184a0f
3
+ metadata.gz: db69c25dd1811c324c47e3cce6a8d3ce4622ad2fcad25ae4a3703924ac332419
4
+ data.tar.gz: ba83a11669af015add4a7b35269d5c16e187fc81020adac07c0fb8de116ab431
5
5
  SHA512:
6
- metadata.gz: 2c076cf15bee2101cfa3c1c53657c39a75e9d5accec6dc0c1949c82e459f925b7c51156c8ee1f8ee49d2c46a1d5811ddeba7dc83ad4a194285769db51ee629dd
7
- data.tar.gz: d4624767daa67dd937992b6da9ce2c909fc26d5eb67267dc2c6b70cf40f29291edf37fc991f9c29e21fa034c65e0524a0fa22575141297453e42acfa461b8a17
6
+ metadata.gz: 966f194d7fdaa930a8f60ca9500b46d756b3d67d735c1cc5a64c8fc6ec802cde7a3bf8ce6b1c8d0707acd59f7d6d2c9120b7a1c167089514cc72589dd6837120
7
+ data.tar.gz: ae5a6bee53a79a2902522126c83c30664195793c47f6148a32c663dc87a577527e0c9fbaf8b7ba6a99a64c8e1b0752213d47f73bf418c8512e7e2f20ef973f4d
data/README.md CHANGED
@@ -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
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.0'
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.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-03-02 00:00:00.000000000 Z
11
+ date: 2022-03-10 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: []