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 +4 -4
- data/bin/matching_bundle +3 -0
- data/lib/matching_bundle.rb +21 -10
- data/lib/matching_bundle/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ca9513c79ddc3fc104126b26a8f1e9eef50e4181fad32f99547a4b618d61533
|
4
|
+
data.tar.gz: 20d63f0558de27171f15b5aec36994fc32c1a9f092ecc4087c611c693597b592
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c5fa45b739754e5ee18630c91311fb8fd4f52e9ad83878e2135cb87809df03af2017a4d092f34999202272b0fd8dcd33ccd43f8e3c585e0801d062d4674e1e9
|
7
|
+
data.tar.gz: 8cb59d7948788bed17a7350e92ed28c5863125045d8930df1636898ef3abf55d4c78183007324ddbbd1d3351bdeeb5fa2c0e036325af0d69df77508867e58e24
|
data/bin/matching_bundle
CHANGED
@@ -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
|
data/lib/matching_bundle.rb
CHANGED
@@ -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 "
|
12
|
+
warn "Using installed bundler #{version}"
|
13
13
|
return version
|
14
14
|
end
|
15
15
|
|
16
|
-
|
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
|
38
|
-
requirement.satisfied_by?
|
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
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
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
|
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.
|
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-
|
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
|
-
|
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
|