getv 0.2.2 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/getv/package.rb CHANGED
@@ -1,180 +1,167 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Getv
2
- class Package
4
+ # package class
5
+ class Package # rubocop:disable Metrics/ClassLength
3
6
  attr_accessor :name, :opts
4
7
 
5
- def initialize(name, opts={})
8
+ def initialize(name, opts = {}) # rubocop:disable Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/AbcSize,Metrics/PerceivedComplexity
6
9
  @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)
10
+ case name
11
+ when /rubygem-.*/
12
+ opts = { 'type' => 'gem' }.merge(opts)
13
+ when /nodejs-.*/
14
+ opts = { 'type' => 'npm' }.merge(opts)
15
+ when /python.*-.*/
16
+ opts = { 'type' => 'pypi' }.merge(opts)
13
17
  end
14
18
  if opts[:type] == 'github_commit'
15
19
  opts = {
16
- :branch => 'master',
17
- :select_search => '^((\d{8})(\d{6}),(([a-z\d]{7})(.*)))$',
18
- :semantic_only => false
20
+ branch: 'master',
21
+ select_search: '^((\d{8})(\d{6}),(([a-z\d]{7})(.*)))$',
22
+ semantic_only: false
19
23
  }.merge(opts)
20
24
  end
21
25
  opts = {
22
- :type => 'github_release',
23
- :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*$',
24
- :select_replace => '\1',
25
- :reject => nil,
26
- :semantic_only => true,
27
- :semantic_select => ['*'],
28
- :versions => nil,
29
- :latest_version => nil,
26
+ type: 'github_release',
27
+ 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*$', # rubocop:disable Layout/LineLength
28
+ select_replace: '\1',
29
+ reject: nil,
30
+ semantic_only: true,
31
+ semantic_select: ['*'],
32
+ versions: nil,
33
+ latest_version: nil
30
34
  }.merge(opts)
35
+ if (opts[:type] == 'docker' || opts[:type] =~ /github.*/) && (name.count('/') == 1)
36
+ opts = { owner: name.split('/')[0], repo: name.split('/')[1] }.merge(opts)
37
+ end
31
38
  case opts[:type]
32
39
  when 'docker'
33
- opts = {:owner => 'library', :repo => name, :url=> 'https://registry.hub.docker.com'}.merge(opts)
40
+ opts = { owner: 'library', repo: name, url: 'https://registry.hub.docker.com' }.merge(opts)
34
41
  when 'gem'
35
- opts = {:gem => name[/rubygem-(.*)/, 1] || name}.merge(opts)
42
+ opts = { gem: name[/rubygem-(.*)/, 1] || name }.merge(opts)
36
43
  when /github.*/
37
- opts = {:owner => name, :repo => name,}.merge(opts)
44
+ opts = { owner: name, repo: name }.merge(opts)
38
45
  when 'index'
39
- opts = {:link => 'content'}.merge(opts)
46
+ opts = { link: 'content' }.merge(opts)
40
47
  when 'npm'
41
- opts = {:npm => name[/nodejs-(.*)/, 1] || name}.merge(opts)
48
+ opts = { npm: name[/nodejs-(.*)/, 1] || name }.merge(opts)
42
49
  when 'pypi'
43
- opts = {:npm => name[/python.*-(.*)/, 1] || name}.merge(opts)
50
+ opts = { npm: name[/python.*-(.*)/, 1] || name }.merge(opts)
44
51
  end
45
52
  @opts = opts
46
53
  end
47
-
48
- def get_latest_version
49
- if opts[:latest_version] == nil
50
- self.update_versions
51
- end
54
+
55
+ def latest_version
56
+ update_versions if opts[:latest_version].nil?
52
57
  opts[:latest_version]
53
58
  end
54
59
 
55
- def get_versions
56
- if opts[:version] == nil
57
- self.update_versions
58
- end
60
+ def versions
61
+ update_versions if opts[:versions].nil?
59
62
  opts[:versions]
60
63
  end
61
64
 
62
- def update_versions
63
- case opts[:type]
64
- when 'docker'
65
- versions = get_versions_using_docker
66
- when 'gem'
67
- versions = get_versions_using_gem
68
- when 'get'
69
- versions = get_versions_using_get
70
- when 'github_commit'
71
- versions = get_versions_using_github('commit')
72
- when 'github_release'
73
- versions = get_versions_using_github('release')
74
- when 'github_tag'
75
- versions = get_versions_using_github('tag')
76
- when 'index'
77
- versions = get_versions_using_index
78
- when 'npm'
79
- versions = get_versions_using_npm
80
- when 'pypi'
81
- versions = get_versions_using_pypi
82
- end
83
- if opts[:type] == 'github_commit'
84
- versions.sort!
85
- end
65
+ def update_versions # rubocop:disable Metrics/PerceivedComplexity,Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/AbcSize
66
+ method = opts[:type].split('_')
67
+ method[0] = "versions_using_#{method[0]}"
68
+
69
+ versions = send(*method)
70
+ versions.sort! if opts[:type] == 'github_commit'
86
71
  select_pattern = Regexp.new(opts[:select_search])
87
- versions.select! {|v| v =~ select_pattern}
88
- versions.map! {|v| v.sub(select_pattern, opts[:select_replace])}
89
- unless opts[:reject].nil?
90
- versions.reject! {|v| v =~ Regexp.new(opts[:reject])}
91
- end
72
+ versions.select! { |v| v =~ select_pattern }
73
+ versions.map! { |v| v.sub(select_pattern, opts[:select_replace]) }
74
+ versions.reject! { |v| v =~ Regexp.new(opts[:reject]) } unless opts[:reject].nil?
92
75
  if opts[:semantic_only]
93
76
  require 'semantic'
94
77
  require 'semantic/core_ext'
95
- versions.select! {|v| v.is_version?}
78
+ versions.select!(&:is_version?)
96
79
  opts[:semantic_select].each do |comparator|
97
- versions.select! {|v| Semantic::Version.new(v).satisfies?(comparator)}
80
+ versions.select! { |v| Semantic::Version.new(v).satisfies?(comparator) }
98
81
  end
99
- versions.sort_by! {|v| Semantic::Version.new(v)}
82
+ versions.sort_by! { |v| Semantic::Version.new(v) }
100
83
  else
101
- unless opts[:type] == 'github_commit'
102
- versions.sort!
103
- end
104
- end
105
- opts[:versions] = versions
106
- unless opts[:versions].empty?
107
- opts[:latest_version] = opts[:versions][-1]
84
+ versions.sort! unless opts[:type] == 'github_commit'
108
85
  end
86
+ opts[:versions] = versions.uniq
87
+ opts[:latest_version] = opts[:versions][-1] unless opts[:versions].empty?
109
88
  end
110
89
 
111
90
  private
112
91
 
113
- def get_versions_using_docker
92
+ def versions_using_docker
114
93
  require 'docker_registry2'
115
94
  docker = DockerRegistry2.connect(opts[:url])
116
- return docker.tags("#{opts[:owner]}/#{opts[:repo]}")['tags']
95
+ docker.tags("#{opts[:owner]}/#{opts[:repo]}")['tags']
117
96
  end
118
97
 
119
- def get_versions_using_gem
98
+ def versions_using_gem
120
99
  require 'json'
121
100
  require 'open-uri'
122
101
  require 'net/http'
123
- return JSON.parse(Net::HTTP.get(URI("https://rubygems.org/api/v1/versions/#{opts[:gem]}.json"))).map {|v| v['number']}
102
+ JSON.parse(Net::HTTP.get(URI("https://rubygems.org/api/v1/versions/#{opts[:gem]}.json"))).map do |v|
103
+ v['number']
104
+ end
124
105
  end
125
106
 
126
- def get_versions_using_get
107
+ def versions_using_get
127
108
  require 'open-uri'
128
109
  require 'net/http'
129
- return Net::HTTP.get(URI(opts[:url])).split("\n")
110
+ Net::HTTP.get(URI(opts[:url])).split("\n")
130
111
  end
131
112
 
132
- def get_versions_using_github(method)
113
+ def github
133
114
  require 'octokit'
134
115
  if ENV['GITHUB_TOKEN']
135
- github = Octokit::Client.new(:access_token => ENV['GITHUB_TOKEN'])
116
+ github = Octokit::Client.new(access_token: ENV['GITHUB_TOKEN'])
136
117
  user = github.user
137
118
  user.login
138
119
  else
139
- github = Octokit::Client.new()
120
+ github = Octokit::Client.new
140
121
  end
141
122
  github.auto_paginate = true
142
- if method == 'release'
143
- return github.releases("#{opts[:owner]}/#{opts[:repo]}").map{|r| r.tag_name}
144
- elsif method == 'commit'
145
- return github.commits("#{opts[:owner]}/#{opts[:repo]}",opts[:branch]).map { |c|
123
+ github
124
+ end
125
+
126
+ def versions_using_github(method) # rubocop:disable Metrics/AbcSize
127
+ case method
128
+ when 'release'
129
+ github.releases("#{opts[:owner]}/#{opts[:repo]}").map(&:tag_name)
130
+ when 'commit'
131
+ github.commits("#{opts[:owner]}/#{opts[:repo]}", opts[:branch]).map do |c|
146
132
  "#{DateTime.parse(c[:commit][:author][:date].to_s).strftime('%Y%m%d%H%M%S')},#{c[:sha]}"
147
- }
133
+ end
148
134
  else
149
- return github.tags("#{opts[:owner]}/#{opts[:repo]}").map{|t| t[:name]}
135
+ github.tags("#{opts[:owner]}/#{opts[:repo]}").map { |t| t[:name] }
150
136
  end
151
137
  end
152
138
 
153
- def get_versions_using_index
139
+ def versions_using_index
154
140
  require 'open-uri'
155
141
  require 'net/http'
156
142
  require 'nokogiri'
157
- if opts[:link] == 'value'
158
- versions = Nokogiri::HTML(URI.open(opts[:url])).css('a').map{|a| a.values[0]}
159
- else
160
- versions = Nokogiri::HTML(URI.open(opts[:url])).css('a').map{|a| a.public_send(opts[:link])}
143
+
144
+ Nokogiri::HTML(URI.open(opts[:url])).css('a').map do |a| # rubocop:disable Security/Open
145
+ if opts[:link] == 'value'
146
+ a.values[0]
147
+ else
148
+ a.public_send(opts[:link])
149
+ end
161
150
  end
162
- return versions
163
151
  end
164
152
 
165
- def get_versions_using_npm
153
+ def versions_using_npm
166
154
  require 'json'
167
155
  require 'open-uri'
168
156
  require 'net/http'
169
- return JSON.parse(Net::HTTP.get(URI("https://registry.npmjs.org/#{opts[:npm]}")))['versions'].keys
157
+ JSON.parse(Net::HTTP.get(URI("https://registry.npmjs.org/#{opts[:npm]}")))['versions'].keys
170
158
  end
171
159
 
172
- def get_versions_using_pypi
160
+ def versions_using_pypi
173
161
  require 'json'
174
162
  require 'open-uri'
175
163
  require 'net/http'
176
- return JSON.parse(Net::HTTP.get(URI("https://pypi.org/pypi/#{opts[:pypi]}/json")))['releases'].keys
164
+ JSON.parse(Net::HTTP.get(URI("https://pypi.org/pypi/#{opts[:pypi]}/json")))['releases'].keys
177
165
  end
178
-
179
166
  end
180
167
  end
data/lib/getv/version.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Getv
2
- VERSION = "0.2.2"
4
+ VERSION = '1.2.0'
3
5
  end
data/lib/getv.rb CHANGED
@@ -1,5 +1,7 @@
1
- require "getv/version"
2
- require "getv/package"
1
+ # frozen_string_literal: true
2
+
3
+ require 'getv/version'
4
+ require 'getv/package'
3
5
 
4
6
  module Getv
5
7
  class Error < StandardError; end
metadata CHANGED
@@ -1,57 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: getv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - harbottle
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-16 00:00:00.000000000 Z
11
+ date: 2022-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: nokogiri
14
+ name: gli
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.0.0
19
+ version: 2.20.1
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: 2.0.0
22
+ version: 3.0.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: 1.0.0
29
+ version: 2.20.1
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: 2.0.0
32
+ version: 3.0.0
33
33
  - !ruby/object:Gem::Dependency
34
- name: octokit
34
+ name: docker_registry2
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: 3.0.0
39
+ version: 1.0.0
40
40
  - - "<"
41
41
  - !ruby/object:Gem::Version
42
- version: 5.0.0
42
+ version: 2.0.0
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: 3.0.0
49
+ version: 1.0.0
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
- version: 5.0.0
52
+ version: 2.0.0
53
53
  - !ruby/object:Gem::Dependency
54
- name: semantic
54
+ name: nokogiri
55
55
  requirement: !ruby/object:Gem::Requirement
56
56
  requirements:
57
57
  - - ">="
@@ -71,7 +71,27 @@ dependencies:
71
71
  - !ruby/object:Gem::Version
72
72
  version: 2.0.0
73
73
  - !ruby/object:Gem::Dependency
74
- name: docker_registry2
74
+ name: octokit
75
+ requirement: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: 3.0.0
80
+ - - "<"
81
+ - !ruby/object:Gem::Version
82
+ version: 5.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: 3.0.0
90
+ - - "<"
91
+ - !ruby/object:Gem::Version
92
+ version: 5.0.0
93
+ - !ruby/object:Gem::Dependency
94
+ name: semantic
75
95
  requirement: !ruby/object:Gem::Requirement
76
96
  requirements:
77
97
  - - ">="
@@ -98,26 +118,17 @@ extensions: []
98
118
  extra_rdoc_files: []
99
119
  files:
100
120
  - ".bundle/config"
121
+ - ".github/workflows/ruby.yml"
101
122
  - ".gitignore"
102
123
  - ".rspec"
124
+ - ".rubocop.yml"
103
125
  - ".travis.yml"
104
126
  - Gemfile
105
- - Gemfile.lock
106
127
  - LICENSE.txt
107
128
  - README.md
108
129
  - Rakefile
109
- - bin/bundle
110
130
  - 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
131
+ - bin/getv
121
132
  - bin/setup
122
133
  - getv.gemspec
123
134
  - lib/getv.rb
data/Gemfile.lock DELETED
@@ -1,113 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- getv (0.2.1)
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.2.22
data/bin/bundle DELETED
@@ -1,114 +0,0 @@
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/htmldiff DELETED
@@ -1,29 +0,0 @@
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")