matching_bundle 0.3.1 → 0.3.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: 75b42c65b3ed9d76d2d79994f218157b871f23011063c4b438f485770427077d
4
- data.tar.gz: bdecd14f3a4058096179c85512b81b500619b6daaf4efa18701271f237562265
3
+ metadata.gz: 9ca9513c79ddc3fc104126b26a8f1e9eef50e4181fad32f99547a4b618d61533
4
+ data.tar.gz: 20d63f0558de27171f15b5aec36994fc32c1a9f092ecc4087c611c693597b592
5
5
  SHA512:
6
- metadata.gz: 8653da4c7b788a4377371f88c57791016b937675088efbcf1f637d8de5d3b06c221a8668e7e29d7f0496be79fd5fbcfeae42fcc64637a904258a7cf844f76a47
7
- data.tar.gz: 5bb8216afc6bc1a67dd718053933aac8bdc242baf97f8376ffbf075b32da6bfca1ad68c0df4c0da5ce1c602cfd8150c34ea81b1d8bb5950520326d94d7fb358d
6
+ metadata.gz: 2c5fa45b739754e5ee18630c91311fb8fd4f52e9ad83878e2135cb87809df03af2017a4d092f34999202272b0fd8dcd33ccd43f8e3c585e0801d062d4674e1e9
7
+ data.tar.gz: 8cb59d7948788bed17a7350e92ed28c5863125045d8930df1636898ef3abf55d4c78183007324ddbbd1d3351bdeeb5fa2c0e036325af0d69df77508867e58e24
@@ -18,6 +18,9 @@ else
18
18
  end
19
19
 
20
20
  require 'matching_bundle'
21
+ # require_relative '../lib/matching_bundle' # use this for local debugging
21
22
  if version = MatchingBundle.find_or_install_matching_version(content)
22
23
  exec "bundle", "_#{version}_", *ARGV
24
+ else
25
+ exec "bundle", *ARGV
23
26
  end
@@ -6,14 +6,17 @@ module MatchingBundle
6
6
  class << self
7
7
  def find_or_install_matching_version(gemfile_content)
8
8
  requirements = bundler_requirements(gemfile_content)
9
- return if requirements.empty?
9
+ return if requirements.empty? # just use whatever
10
10
 
11
11
  if version = find_matching_local_bundler_version(requirements)
12
- warn "Found bundler #{version}"
12
+ warn "Using installed bundler #{version}"
13
13
  return version
14
14
  end
15
15
 
16
- return unless version = find_matching_remote_bundler_version(requirements)
16
+ unless version = find_matching_remote_bundler_version(requirements)
17
+ warn "No remote version of bundler satisfies #{requirements.join(", ")}"
18
+ return
19
+ end
17
20
 
18
21
  warn "Installing bundler #{version}"
19
22
  abort unless system "gem", "install", "bundler", "-v", version
@@ -34,9 +37,10 @@ module MatchingBundle
34
37
 
35
38
  def find_satisfied(requirements, versions)
36
39
  requirement = Gem::Requirement.new(*requirements)
37
- versions.reverse.find do |version|
38
- requirement.satisfied_by? Gem::Version.new(version)
40
+ version = versions.map { |v| Gem::Version.new(v) }.sort!.reverse!.find do |version|
41
+ requirement.satisfied_by? version
39
42
  end
43
+ version.to_s if version
40
44
  end
41
45
 
42
46
  def installed_bundler_versions
@@ -46,11 +50,18 @@ module MatchingBundle
46
50
  end
47
51
 
48
52
  def bundler_requirements(gemfile_content)
49
- gemfile_content.
50
- split("DEPENDENCIES").last.to_s.
51
- split("Current Bundler version").first.to_s.
52
- scan(/^\s*bundler \((.*)\)/).flatten.
53
- flat_map { |r| r.split(", ") }
53
+ requirements =
54
+ gemfile_content.
55
+ split("Current Bundler version").first.to_s.
56
+ scan(/^\s*bundler \((.*)\)/).flatten.
57
+ flat_map { |r| r.split(", ") }
58
+
59
+ # needs to be >= to avoid warnings and the same major version to not fail
60
+ if gemfile_content =~ /BUNDLED WITH\n\s+(.*)/
61
+ requirements += [">= #{$1}", "~> #{$1[/\d+\.\d+/]}"]
62
+ end
63
+
64
+ requirements
54
65
  end
55
66
  end
56
67
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module MatchingBundle
3
- VERSION = "0.3.1"
3
+ VERSION = "0.3.2"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: matching_bundle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-01 00:00:00.000000000 Z
11
+ date: 2019-06-02 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: michael@grosser.it
@@ -40,8 +40,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  requirements: []
43
- rubyforge_project:
44
- rubygems_version: 2.7.6
43
+ rubygems_version: 3.0.3
45
44
  signing_key:
46
45
  specification_version: 4
47
46
  summary: Find a matching bundler version for a Gemfile and use it