gem_pre_unversioned_install 1.0.1 → 1.0.2
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 +4 -4
- data/gem_pre_unversioned_install.gemspec +1 -1
- data/lib/gem_pre_unversioned_install.rb +24 -16
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47600b79f1ce0e5464b3e17ff16a1469e7474bc2
|
4
|
+
data.tar.gz: ad49a17321ea12ec9f1c31d4be0b945383f0e3a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51ca024efbe8af603931725b722cc44c5f9db8f75f3a5f5c57ca78ac0c82c68058c4ccf9b378634b29e25bc696d196da3b44f6e25ee2593548525800275f2782
|
7
|
+
data.tar.gz: 7d4eb996d3cf6b7e5b391dcf5b540b404937d7ea41e7cb2b6e83a24e0d16e2443458dad4db2dafabd5e277e3d29460bbaa639ba26e8a135cf6a9e310a3dc817c
|
@@ -9,7 +9,7 @@ $LOAD_PATH.merge! [File.expand_path('../lib', __FILE__)]
|
|
9
9
|
Gem::Specification.new do |spec|
|
10
10
|
raise 'RubyGems 2.0 or newer is required.' unless spec.respond_to?(:metadata)
|
11
11
|
spec.name = 'gem_pre_unversioned_install'
|
12
|
-
spec.version = '1.0.
|
12
|
+
spec.version = '1.0.2'
|
13
13
|
spec.authors = ['Andrew Smith']
|
14
14
|
spec.email = ['andrew.smith at moneysupermarket.com']
|
15
15
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# Gem.pre_unversioned_install hook
|
2
2
|
require 'rubygems'
|
3
|
+
require 'rubygems/dependency'
|
3
4
|
|
4
5
|
# Extend Gem module
|
5
6
|
module Gem
|
@@ -22,19 +23,32 @@ module Gem
|
|
22
23
|
@_unversioned_hooks |= [hook]
|
23
24
|
end
|
24
25
|
|
25
|
-
#
|
26
|
-
def self.
|
27
|
-
|
28
|
-
|
26
|
+
# Dispatch unversioned hooks
|
27
|
+
def self.fire_unversioned_hooks(name, version)
|
28
|
+
rval = nil
|
29
|
+
# pre_install hooks can cause gem install to abort if they return false
|
30
|
+
# so we allow our plugins to do the same and trigger this behaviour
|
31
|
+
@_unversioned_hooks.each do |hook|
|
32
|
+
break if (rval = hook.call(name, version)) == false
|
33
|
+
end
|
34
|
+
rval
|
29
35
|
end
|
30
36
|
|
31
|
-
# Monkey patch
|
32
|
-
class Dependency
|
33
|
-
alias _latest_version? latest_version?
|
37
|
+
# Monkey patch through subclassing
|
38
|
+
class Dependency < remove_const(:Dependency)
|
34
39
|
|
35
|
-
#
|
40
|
+
# Newer RubyGems use >=0 as a default requirement
|
41
|
+
def initialize(_name, *requirements)
|
42
|
+
super
|
43
|
+
return unless requirements.find do |req|
|
44
|
+
req.is_a?(Requirement) && req.none?
|
45
|
+
end
|
46
|
+
Gem.unversioned(@name)
|
47
|
+
end
|
48
|
+
|
49
|
+
# For older RubyGems versions
|
36
50
|
def latest_version?
|
37
|
-
if (res =
|
51
|
+
if (res = super)
|
38
52
|
Gem.unversioned(@name)
|
39
53
|
end
|
40
54
|
res
|
@@ -46,11 +60,5 @@ end
|
|
46
60
|
Gem.pre_install do |installer|
|
47
61
|
spec = installer.spec
|
48
62
|
next unless Gem.unversioned?(spec.name)
|
49
|
-
|
50
|
-
# so we allow our plugins to do the same and trigger this behaviour
|
51
|
-
rval = nil
|
52
|
-
Gem._unversioned_hooks.each do |hook|
|
53
|
-
break if (rval = hook.call(spec.name, spec.version)) == false
|
54
|
-
end
|
55
|
-
rval
|
63
|
+
Gem.fire_unversioned_hooks(spec.name, spec.version)
|
56
64
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gem_pre_unversioned_install
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Smith
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Allows custom actions in delivery pipelines for RubyGem installations
|
14
14
|
that have no version specifications
|