getv 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: daa14a57206ce36f42d7373647539e9a3718422bade081044c4f6b38129fb23a
4
+ data.tar.gz: a1bbbb5d1c6c5609611d12590760dad98cdb1f2e89a3d6ba92e05ba92d03d0eb
5
+ SHA512:
6
+ metadata.gz: a0329d396ff28c22ddaf272872298b80660d41ad44fe5504740721ae8f4797fcb009e30cda8c334e7f611589b34e82e5f050846865d9ba6a9b0c9c65e2d126ab
7
+ data.tar.gz: 5463da5acef0fe03dd77dd54135ac393f34876c3108d957bd9016fafd2d903754ae725f34c1b41a50300c8c4ab3bd5752066560a59fa997bf6885ee3d25daaa4
data/.bundle/config ADDED
@@ -0,0 +1,4 @@
1
+ ---
2
+ BUNDLE_BIN: "bin"
3
+ BUNDLE_DISABLE_SHARED_GEMS: "true"
4
+ BUNDLE_PATH: "./bundle"
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /*.gem
10
+
11
+ # rspec failure tracking
12
+ .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,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.6.6
6
+ before_install: gem install bundler -v 2.1.4
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in getv.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "rspec", "~> 3.0"
8
+ gem "nokogiri", "~> 1.13"
9
+ gem "irb", "~> 1.4"
10
+ gem "rdoc", "~> 6.4"
11
+ gem "octokit", "~> 4.21"
12
+ gem "semantic", "~> 1.6"
13
+ gem "docker_registry2", "~> 1.10"
data/Gemfile.lock ADDED
@@ -0,0 +1,113 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ getv (0.1.0)
5
+ docker_registry2 (>= 1.0.0, < 2.0.0)
6
+ nokogiri (>= 1.0.0, < 2.0.0)
7
+ octokit (>= 3.0.0, < 5.0.0)
8
+ semantic (>= 1.0.0, < 2.0.0)
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ addressable (2.8.0)
14
+ public_suffix (>= 2.0.2, < 5.0)
15
+ diff-lcs (1.5.0)
16
+ docker_registry2 (1.10.0)
17
+ rest-client (>= 1.8.0)
18
+ domain_name (0.5.20190701)
19
+ unf (>= 0.0.5, < 1.0.0)
20
+ faraday (1.9.3)
21
+ faraday-em_http (~> 1.0)
22
+ faraday-em_synchrony (~> 1.0)
23
+ faraday-excon (~> 1.1)
24
+ faraday-httpclient (~> 1.0)
25
+ faraday-multipart (~> 1.0)
26
+ faraday-net_http (~> 1.0)
27
+ faraday-net_http_persistent (~> 1.0)
28
+ faraday-patron (~> 1.0)
29
+ faraday-rack (~> 1.0)
30
+ faraday-retry (~> 1.0)
31
+ ruby2_keywords (>= 0.0.4)
32
+ faraday-em_http (1.0.0)
33
+ faraday-em_synchrony (1.0.0)
34
+ faraday-excon (1.1.0)
35
+ faraday-httpclient (1.0.1)
36
+ faraday-multipart (1.0.3)
37
+ multipart-post (>= 1.2, < 3)
38
+ faraday-net_http (1.0.1)
39
+ faraday-net_http_persistent (1.2.0)
40
+ faraday-patron (1.0.0)
41
+ faraday-rack (1.0.0)
42
+ faraday-retry (1.0.3)
43
+ http-accept (1.7.0)
44
+ http-cookie (1.0.4)
45
+ domain_name (~> 0.5)
46
+ io-console (0.5.11)
47
+ irb (1.4.1)
48
+ reline (>= 0.3.0)
49
+ mime-types (3.4.1)
50
+ mime-types-data (~> 3.2015)
51
+ mime-types-data (3.2022.0105)
52
+ mini_portile2 (2.7.1)
53
+ multipart-post (2.1.1)
54
+ netrc (0.11.0)
55
+ nokogiri (1.13.0)
56
+ mini_portile2 (~> 2.7.0)
57
+ racc (~> 1.4)
58
+ octokit (4.21.0)
59
+ faraday (>= 0.9)
60
+ sawyer (~> 0.8.0, >= 0.5.3)
61
+ psych (4.0.3)
62
+ stringio
63
+ public_suffix (4.0.6)
64
+ racc (1.6.0)
65
+ rake (12.3.3)
66
+ rdoc (6.4.0)
67
+ psych (>= 4.0.0)
68
+ reline (0.3.1)
69
+ io-console (~> 0.5)
70
+ rest-client (2.1.0)
71
+ http-accept (>= 1.7.0, < 2.0)
72
+ http-cookie (>= 1.0.2, < 2.0)
73
+ mime-types (>= 1.16, < 4.0)
74
+ netrc (~> 0.8)
75
+ rspec (3.10.0)
76
+ rspec-core (~> 3.10.0)
77
+ rspec-expectations (~> 3.10.0)
78
+ rspec-mocks (~> 3.10.0)
79
+ rspec-core (3.10.1)
80
+ rspec-support (~> 3.10.0)
81
+ rspec-expectations (3.10.1)
82
+ diff-lcs (>= 1.2.0, < 2.0)
83
+ rspec-support (~> 3.10.0)
84
+ rspec-mocks (3.10.2)
85
+ diff-lcs (>= 1.2.0, < 2.0)
86
+ rspec-support (~> 3.10.0)
87
+ rspec-support (3.10.3)
88
+ ruby2_keywords (0.0.5)
89
+ sawyer (0.8.2)
90
+ addressable (>= 2.3.5)
91
+ faraday (> 0.8, < 2.0)
92
+ semantic (1.6.1)
93
+ stringio (3.0.1)
94
+ unf (0.1.4)
95
+ unf_ext
96
+ unf_ext (0.0.8)
97
+
98
+ PLATFORMS
99
+ ruby
100
+
101
+ DEPENDENCIES
102
+ docker_registry2 (~> 1.10)
103
+ getv!
104
+ irb (~> 1.4)
105
+ nokogiri (~> 1.13)
106
+ octokit (~> 4.21)
107
+ rake (~> 12.0)
108
+ rdoc (~> 6.4)
109
+ rspec (~> 3.0)
110
+ semantic (~> 1.6)
111
+
112
+ BUNDLED WITH
113
+ 2.1.4
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Richard Grainger
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,62 @@
1
+ # Getv
2
+
3
+ Pull package version numbers from the web in various ways.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'getv'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install getv
20
+
21
+ ## Usage
22
+
23
+ ```
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.get_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.get_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"}>
47
+ ```
48
+
49
+ ## Development
50
+
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.
52
+
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).
54
+
55
+ ## Contributing
56
+
57
+ Bug reports and pull requests are welcome on GitHub at https://github.com/liger1978/getv.
58
+
59
+
60
+ ## License
61
+
62
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
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/bundle ADDED
@@ -0,0 +1,114 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'bundle' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "rubygems"
12
+
13
+ m = Module.new do
14
+ module_function
15
+
16
+ def invoked_as_script?
17
+ File.expand_path($0) == File.expand_path(__FILE__)
18
+ end
19
+
20
+ def env_var_version
21
+ ENV["BUNDLER_VERSION"]
22
+ end
23
+
24
+ def cli_arg_version
25
+ return unless invoked_as_script? # don't want to hijack other binstubs
26
+ return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
27
+ bundler_version = nil
28
+ update_index = nil
29
+ ARGV.each_with_index do |a, i|
30
+ if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
31
+ bundler_version = a
32
+ end
33
+ next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
34
+ bundler_version = $1
35
+ update_index = i
36
+ end
37
+ bundler_version
38
+ end
39
+
40
+ def gemfile
41
+ gemfile = ENV["BUNDLE_GEMFILE"]
42
+ return gemfile if gemfile && !gemfile.empty?
43
+
44
+ File.expand_path("../../Gemfile", __FILE__)
45
+ end
46
+
47
+ def lockfile
48
+ lockfile =
49
+ case File.basename(gemfile)
50
+ when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
51
+ else "#{gemfile}.lock"
52
+ end
53
+ File.expand_path(lockfile)
54
+ end
55
+
56
+ def lockfile_version
57
+ return unless File.file?(lockfile)
58
+ lockfile_contents = File.read(lockfile)
59
+ return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
60
+ Regexp.last_match(1)
61
+ end
62
+
63
+ def bundler_version
64
+ @bundler_version ||=
65
+ env_var_version || cli_arg_version ||
66
+ lockfile_version
67
+ end
68
+
69
+ def bundler_requirement
70
+ return "#{Gem::Requirement.default}.a" unless bundler_version
71
+
72
+ bundler_gem_version = Gem::Version.new(bundler_version)
73
+
74
+ requirement = bundler_gem_version.approximate_recommendation
75
+
76
+ return requirement unless Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.7.0")
77
+
78
+ requirement += ".a" if bundler_gem_version.prerelease?
79
+
80
+ requirement
81
+ end
82
+
83
+ def load_bundler!
84
+ ENV["BUNDLE_GEMFILE"] ||= gemfile
85
+
86
+ activate_bundler
87
+ end
88
+
89
+ def activate_bundler
90
+ gem_error = activation_error_handling do
91
+ gem "bundler", bundler_requirement
92
+ end
93
+ return if gem_error.nil?
94
+ require_error = activation_error_handling do
95
+ require "bundler/version"
96
+ end
97
+ return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
98
+ warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
99
+ exit 42
100
+ end
101
+
102
+ def activation_error_handling
103
+ yield
104
+ nil
105
+ rescue StandardError, LoadError => e
106
+ e
107
+ end
108
+ end
109
+
110
+ m.load_bundler!
111
+
112
+ if m.invoked_as_script?
113
+ load Gem.bin_path("bundler", "bundle")
114
+ end
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/htmldiff ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'htmldiff' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("diff-lcs", "htmldiff")
data/bin/irb ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'irb' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("irb", "irb")
data/bin/ldiff ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'ldiff' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("diff-lcs", "ldiff")
data/bin/nokogiri ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'nokogiri' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("nokogiri", "nokogiri")
data/bin/racc ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'racc' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("racc", "racc")
data/bin/rake ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rake' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rake", "rake")
data/bin/rdoc ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rdoc' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rdoc", "rdoc")
data/bin/restclient ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'restclient' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rest-client", "restclient")
data/bin/ri ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'ri' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rdoc", "ri")
data/bin/rspec ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rspec' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rspec-core", "rspec")
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 ADDED
@@ -0,0 +1,31 @@
1
+ require_relative 'lib/getv/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "getv"
5
+ spec.version = Getv::VERSION
6
+ spec.authors = ["harbottle"]
7
+ spec.email = ["harbottle@room3d3.com"]
8
+
9
+ spec.summary = "Pull package version numbers from the web in various ways."
10
+ spec.description = "Pull package version numbers from the web in various ways."
11
+ spec.homepage = "https://github.com/liger1978/getv"
12
+ spec.license = "MIT"
13
+
14
+ spec.metadata["homepage_uri"] = spec.homepage
15
+ spec.metadata["source_code_uri"] = "https://github.com/liger1978/getv"
16
+ spec.metadata["changelog_uri"] = "https://github.com/liger1978/getv"
17
+
18
+ # Specify which files should be added to the gem when it is released.
19
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
20
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
21
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
+ end
23
+ spec.bindir = "exe"
24
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
+ spec.require_paths = ["lib"]
26
+
27
+ spec.add_dependency("nokogiri", ">= 1.0.0", "< 2.0.0")
28
+ spec.add_dependency("octokit", ">= 3.0.0", "< 5.0.0")
29
+ spec.add_dependency("semantic", ">= 1.0.0", "< 2.0.0")
30
+ spec.add_dependency("docker_registry2", ">= 1.0.0", "< 2.0.0")
31
+ end
@@ -0,0 +1,163 @@
1
+ module Getv
2
+ class Package
3
+ attr_accessor :name, :opts
4
+
5
+ def initialize(name, opts={})
6
+ @name = name
7
+ if /rubygem-.*/.match?(name)
8
+ opts = {'type' => 'gem'}.merge(opts)
9
+ elsif /nodejs-.*/.match?(name)
10
+ opts = {'type' => 'npm'}.merge(opts)
11
+ elsif /python.*-.*/.match?(name)
12
+ opts = {'type' => 'pypi'}.merge(opts)
13
+ end
14
+ opts = {
15
+ :type => 'github_release',
16
+ :select => {
17
+ :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*$',
18
+ :replace => '\1'
19
+ },
20
+ :reject => nil,
21
+ :semantic_only => true,
22
+ :semantic_select => ['*'],
23
+ :versions => nil,
24
+ :latest_version => nil,
25
+ }.merge(opts)
26
+ case opts[:type]
27
+ when 'docker'
28
+ opts = {:owner => 'library', :repo => name, :url=> 'https://registry.hub.docker.com'}.merge(opts)
29
+ when 'gem'
30
+ opts = {:gem => name[/rubygem-(.*)/, 1] || name}.merge(opts)
31
+ when /github.*/
32
+ opts = {:owner => name, :repo => name,}.merge(opts)
33
+ when 'index'
34
+ opts = {:link => 'content'}.merge(opts)
35
+ when 'npm'
36
+ opts = {:npm => name[/nodejs-(.*)/, 1] || name}.merge(opts)
37
+ when 'pypi'
38
+ opts = {:npm => name[/python.*-(.*)/, 1] || name}.merge(opts)
39
+ end
40
+ @opts = opts
41
+ end
42
+
43
+ def get_latest_version
44
+ if opts[:latest_version] == nil
45
+ self.update_versions
46
+ end
47
+ opts[:latest_version]
48
+ end
49
+
50
+ def get_versions
51
+ if opts[:version] == nil
52
+ self.update_versions
53
+ end
54
+ opts[:versions]
55
+ end
56
+
57
+ def update_versions
58
+ case opts[:type]
59
+ when 'docker'
60
+ versions = get_versions_using_docker
61
+ when 'gem'
62
+ versions = get_versions_using_gem
63
+ when 'get'
64
+ versions = get_versions_using_get
65
+ when 'github_release'
66
+ versions = get_versions_using_github('release')
67
+ when 'github_tag'
68
+ versions = get_versions_using_github('tag')
69
+ when 'index'
70
+ versions = get_versions_using_index
71
+ when 'npm'
72
+ versions = get_versions_using_npm
73
+ when 'pypi'
74
+ versions = get_versions_using_pypi
75
+ end
76
+ select_pattern = Regexp.new(opts[:select][:search])
77
+ versions.select! {|v| v =~ select_pattern}
78
+ versions.map! {|v| v.sub(select_pattern, opts[:select][:replace])}
79
+ unless opts[:reject].nil?
80
+ versions.reject! {|v| v =~ Regexp.new(opts[:reject])}
81
+ end
82
+ if opts[:semantic_only]
83
+ require 'semantic'
84
+ require 'semantic/core_ext'
85
+ versions.select! {|v| v.is_version?}
86
+ opts[:semantic_select].each do |comparator|
87
+ versions.select! {|v| Semantic::Version.new(v).satisfies?(comparator)}
88
+ end
89
+ versions.sort_by! {|v| Semantic::Version.new(v)}
90
+ else
91
+ versions.sort!
92
+ end
93
+ opts[:versions] = versions
94
+ unless opts[:versions].empty?
95
+ opts[:latest_version] = opts[:versions][-1]
96
+ end
97
+ end
98
+
99
+ private
100
+
101
+ def get_versions_using_docker
102
+ require 'docker_registry2'
103
+ docker = DockerRegistry2.connect(opts[:url])
104
+ return docker.tags("#{opts[:owner]}/#{opts[:repo]}")['tags']
105
+ end
106
+
107
+ def get_versions_using_gem
108
+ require 'json'
109
+ require 'open-uri'
110
+ require 'net/http'
111
+ return JSON.parse(Net::HTTP.get(URI("https://rubygems.org/api/v1/versions/#{opts[:gem]}.json"))).map {|v| v['number']}
112
+ end
113
+
114
+ def get_versions_using_get
115
+ require 'open-uri'
116
+ require 'net/http'
117
+ return Net::HTTP.get(URI(opts[:url])).split("\n")
118
+ end
119
+
120
+ def get_versions_using_github(method)
121
+ require 'octokit'
122
+ if ENV['GITHUB_TOKEN']
123
+ github = Octokit::Client.new(:access_token => ENV['GITHUB_TOKEN'])
124
+ user = github.user
125
+ user.login
126
+ else
127
+ github = Octokit::Client.new()
128
+ end
129
+ if method == 'release'
130
+ return github.releases("#{opts[:owner]}/#{opts[:repo]}").map{|r| r.tag_name}
131
+ else
132
+ return github.tags("#{opts[:owner]}/#{opts[:repo]}").map{|t| t[:name]}
133
+ end
134
+ end
135
+
136
+ def get_versions_using_index
137
+ require 'open-uri'
138
+ require 'net/http'
139
+ require 'nokogiri'
140
+ if opts[:link] == 'value'
141
+ versions = Nokogiri::HTML(URI.open(opts[:url])).css('a').map{|a| a.values[0]}
142
+ else
143
+ versions = Nokogiri::HTML(URI.open(opts[:url])).css('a').map{|a| a.public_send(opts[:link])}
144
+ end
145
+ return versions
146
+ end
147
+
148
+ def get_versions_using_npm
149
+ require 'json'
150
+ require 'open-uri'
151
+ require 'net/http'
152
+ return JSON.parse(Net::HTTP.get(URI("https://registry.npmjs.org/#{opts[:npm]}")))['versions'].keys
153
+ end
154
+
155
+ def get_versions_using_pypi
156
+ require 'json'
157
+ require 'open-uri'
158
+ require 'net/http'
159
+ return JSON.parse(Net::HTTP.get(URI("https://pypi.org/pypi/#{opts[:pypi]}/json")))['releases'].keys
160
+ end
161
+
162
+ end
163
+ end
@@ -0,0 +1,3 @@
1
+ module Getv
2
+ VERSION = "0.1.0"
3
+ end
data/lib/getv.rb ADDED
@@ -0,0 +1,7 @@
1
+ require "getv/version"
2
+ require "getv/package"
3
+
4
+ module Getv
5
+ class Error < StandardError; end
6
+ # Your code goes here...
7
+ end
metadata ADDED
@@ -0,0 +1,152 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: getv
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - harbottle
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-01-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: nokogiri
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.0
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: 2.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: 1.0.0
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: 2.0.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: octokit
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: 3.0.0
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: 5.0.0
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 3.0.0
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: 5.0.0
53
+ - !ruby/object:Gem::Dependency
54
+ name: semantic
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: 1.0.0
60
+ - - "<"
61
+ - !ruby/object:Gem::Version
62
+ version: 2.0.0
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: 1.0.0
70
+ - - "<"
71
+ - !ruby/object:Gem::Version
72
+ version: 2.0.0
73
+ - !ruby/object:Gem::Dependency
74
+ name: docker_registry2
75
+ requirement: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: 1.0.0
80
+ - - "<"
81
+ - !ruby/object:Gem::Version
82
+ version: 2.0.0
83
+ type: :runtime
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 1.0.0
90
+ - - "<"
91
+ - !ruby/object:Gem::Version
92
+ version: 2.0.0
93
+ description: Pull package version numbers from the web in various ways.
94
+ email:
95
+ - harbottle@room3d3.com
96
+ executables: []
97
+ extensions: []
98
+ extra_rdoc_files: []
99
+ files:
100
+ - ".bundle/config"
101
+ - ".gitignore"
102
+ - ".rspec"
103
+ - ".travis.yml"
104
+ - Gemfile
105
+ - Gemfile.lock
106
+ - LICENSE.txt
107
+ - README.md
108
+ - Rakefile
109
+ - bin/bundle
110
+ - bin/console
111
+ - bin/htmldiff
112
+ - bin/irb
113
+ - bin/ldiff
114
+ - bin/nokogiri
115
+ - bin/racc
116
+ - bin/rake
117
+ - bin/rdoc
118
+ - bin/restclient
119
+ - bin/ri
120
+ - bin/rspec
121
+ - bin/setup
122
+ - getv.gemspec
123
+ - lib/getv.rb
124
+ - lib/getv/package.rb
125
+ - lib/getv/version.rb
126
+ homepage: https://github.com/liger1978/getv
127
+ licenses:
128
+ - MIT
129
+ metadata:
130
+ homepage_uri: https://github.com/liger1978/getv
131
+ source_code_uri: https://github.com/liger1978/getv
132
+ changelog_uri: https://github.com/liger1978/getv
133
+ post_install_message:
134
+ rdoc_options: []
135
+ require_paths:
136
+ - lib
137
+ required_ruby_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ required_rubygems_version: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ requirements: []
148
+ rubygems_version: 3.0.3
149
+ signing_key:
150
+ specification_version: 4
151
+ summary: Pull package version numbers from the web in various ways.
152
+ test_files: []