rubygems-runtime 0.0.0.5 → 1.0.1
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/lib/rubygems/runtime/detect_rubygems_loaded.rb +48 -0
- data/lib/rubygems/runtime/gem_extensions.rb +67 -1
- data/lib/rubygems/runtime/kernel_extensions.rb +10 -0
- data/lib/rubygems/runtime.rb +13 -29
- data/lib/rubygems.rb +3 -4
- metadata +4 -4
- data/lib/rubygems/runtime/gem_extensions/generated.rb +0 -63
- data/lib/rubygems/runtime/runtime.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2aac207603348e72b9be01d6688376ac0a5b0f6492256d4b6ff26e5305b2308f
|
4
|
+
data.tar.gz: 9ad02439e50ff7169aadb47f3a656fcd6f4e5d2668efd174211cabdf65506b51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3706b032d233591382812fec05e49b7372f3f993b9bfea2f78b2f4282528d9749b2d8d4c62f83a01128f8ef7e686fb8c715c8a9857fd2432f1116b658626d12
|
7
|
+
data.tar.gz: deed56d7d0fa83a81b3e9463630b854c8403c0639f208a440c3d9e8b9c3cf6d833bf959883b34e190c707a5e8e77dce14213ec7a5e475e85e247670adf9acd36
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# Print a warning if RubyGems has already been loaded
|
2
|
+
# If RUBYGEMS_RUNTIME_STRICT is set to ‘on’, abort the process with a nonzero exit status
|
3
|
+
|
4
|
+
if not defined?(Gem::VERSION)
|
5
|
+
return
|
6
|
+
end
|
7
|
+
|
8
|
+
message = String.new
|
9
|
+
|
10
|
+
if STDERR.tty?
|
11
|
+
message << "\e[31m"
|
12
|
+
else
|
13
|
+
message << "ERROR: "
|
14
|
+
end
|
15
|
+
|
16
|
+
message << "RubyGems has already been required; ‘"
|
17
|
+
|
18
|
+
if STDERR.tty?
|
19
|
+
message << "\e[1m"
|
20
|
+
end
|
21
|
+
|
22
|
+
message << "rubygems/runtime"
|
23
|
+
|
24
|
+
if STDERR.tty?
|
25
|
+
message << "\e[22m"
|
26
|
+
end
|
27
|
+
|
28
|
+
message << "’ won't load"
|
29
|
+
|
30
|
+
if STDERR.tty?
|
31
|
+
message << "\e[m"
|
32
|
+
end
|
33
|
+
|
34
|
+
env_strict = ENV.fetch('RUBYGEMS_RUNTIME_STRICT') do
|
35
|
+
default = 'off'
|
36
|
+
|
37
|
+
warn "RUBYGEMS_RUNTIME_STRICT isn't set. Using '#{default}' by default"
|
38
|
+
|
39
|
+
default
|
40
|
+
end
|
41
|
+
|
42
|
+
strict = env_strict == 'on'
|
43
|
+
|
44
|
+
if strict
|
45
|
+
abort message
|
46
|
+
else
|
47
|
+
warn message
|
48
|
+
end
|
@@ -1,6 +1,11 @@
|
|
1
|
-
|
1
|
+
# Generated by https://github.com/ntl/rubygems-runtime/blob/master/generate_gem_extensions.rb
|
2
|
+
module RubyGems
|
2
3
|
module Runtime
|
3
4
|
module GemExtensions
|
5
|
+
@@win_platform = nil
|
6
|
+
|
7
|
+
WIN_PATTERNS = [/bccwin/i, /cygwin/i, /djgpp/i, /mingw/i, /mswin/i, /wince/i]
|
8
|
+
|
4
9
|
def ruby
|
5
10
|
::RbConfig.ruby
|
6
11
|
end
|
@@ -12,6 +17,67 @@ module Rubygems
|
|
12
17
|
def path
|
13
18
|
[default_dir]
|
14
19
|
end
|
20
|
+
|
21
|
+
# Copied from RubyGems v3.6.9 lib/rubygems.rb:855
|
22
|
+
def ruby_api_version
|
23
|
+
@ruby_api_version ||= target_rbconfig["ruby_version"].dup
|
24
|
+
end
|
25
|
+
|
26
|
+
# Copied from RubyGems v3.6.9 lib/rubygems.rb:479
|
27
|
+
def extension_api_version # :nodoc:
|
28
|
+
if target_rbconfig["ENABLE_SHARED"] == "no"
|
29
|
+
"#{ruby_api_version}-static"
|
30
|
+
else
|
31
|
+
ruby_api_version
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# Copied from RubyGems v3.6.9 lib/rubygems/defaults/operating_system.rb:10
|
36
|
+
def default_dir
|
37
|
+
path = [
|
38
|
+
"/opt/homebrew",
|
39
|
+
"lib",
|
40
|
+
"ruby",
|
41
|
+
"gems",
|
42
|
+
RbConfig::CONFIG['ruby_version']
|
43
|
+
]
|
44
|
+
|
45
|
+
@homebrew_path ||= File.join(*path)
|
46
|
+
end
|
47
|
+
|
48
|
+
# Copied from RubyGems v3.6.9 lib/rubygems.rb:653
|
49
|
+
def location_of_caller(depth = 1)
|
50
|
+
caller[depth] =~ /(.*?):(\d+).*?$/i
|
51
|
+
file = $1
|
52
|
+
lineno = $2.to_i
|
53
|
+
|
54
|
+
[file, lineno]
|
55
|
+
end
|
56
|
+
|
57
|
+
# Copied from RubyGems v3.6.9 lib/rubygems.rb:1035
|
58
|
+
def win_platform?
|
59
|
+
if @@win_platform.nil?
|
60
|
+
ruby_platform = RbConfig::CONFIG["host_os"]
|
61
|
+
@@win_platform = !WIN_PATTERNS.find {|r| ruby_platform =~ r }.nil?
|
62
|
+
end
|
63
|
+
|
64
|
+
@@win_platform
|
65
|
+
end
|
66
|
+
|
67
|
+
# Copied from RubyGems v3.6.9 lib/rubygems.rb:1047
|
68
|
+
def java_platform?
|
69
|
+
RUBY_PLATFORM == "java"
|
70
|
+
end
|
71
|
+
|
72
|
+
# Copied from RubyGems v3.6.9 lib/rubygems.rb:1054
|
73
|
+
def solaris_platform?
|
74
|
+
RUBY_PLATFORM.include?("solaris")
|
75
|
+
end
|
76
|
+
|
77
|
+
# Copied from RubyGems v3.6.9 lib/rubygems.rb:1061
|
78
|
+
def freebsd_platform?
|
79
|
+
RbConfig::CONFIG["host_os"].to_s.include?("bsd")
|
80
|
+
end
|
15
81
|
end
|
16
82
|
end
|
17
83
|
end
|
data/lib/rubygems/runtime.rb
CHANGED
@@ -1,36 +1,20 @@
|
|
1
|
-
|
2
|
-
message = String.new
|
1
|
+
require 'rubygems/runtime/detect_rubygems_loaded'
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
message << "ERROR: "
|
8
|
-
end
|
9
|
-
|
10
|
-
message << "Rubygems has already been required; ‘"
|
11
|
-
|
12
|
-
if STDERR.tty?
|
13
|
-
message << "\e[1m"
|
14
|
-
end
|
15
|
-
|
16
|
-
message << "rubygems/runtime"
|
17
|
-
|
18
|
-
if STDERR.tty?
|
19
|
-
message << "\e[22m"
|
20
|
-
end
|
21
|
-
|
22
|
-
message << "’ won't proceed"
|
23
|
-
|
24
|
-
if STDERR.tty?
|
25
|
-
message << "\e[m"
|
26
|
-
end
|
27
|
-
|
28
|
-
abort message
|
3
|
+
# If RubyGems has been loaded, requiring this library must not modify RubyGems
|
4
|
+
if defined?(Gem)
|
5
|
+
return
|
29
6
|
end
|
30
7
|
|
31
8
|
require 'rubygems/platform'
|
32
9
|
require 'rubygems/version'
|
33
10
|
|
34
11
|
require 'rubygems/runtime/gem_extensions'
|
35
|
-
require 'rubygems/runtime/
|
36
|
-
|
12
|
+
require 'rubygems/runtime/kernel_extensions'
|
13
|
+
|
14
|
+
module Gem
|
15
|
+
extend RubyGems::Runtime::GemExtensions
|
16
|
+
end
|
17
|
+
|
18
|
+
module Kernel
|
19
|
+
include RubyGems::Runtime::KernelExtensions
|
20
|
+
end
|
data/lib/rubygems.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Intercept
|
1
|
+
# Intercept attempts to load RubyGems and aborts the process with a nonzero exit status
|
2
2
|
|
3
3
|
message = String.new
|
4
4
|
|
@@ -8,7 +8,7 @@ else
|
|
8
8
|
message << "ERROR: "
|
9
9
|
end
|
10
10
|
|
11
|
-
message << "An attempt to require
|
11
|
+
message << "An attempt to require RubyGems was made; ‘"
|
12
12
|
|
13
13
|
if STDERR.tty?
|
14
14
|
message << "\e[1m"
|
@@ -28,9 +28,8 @@ end
|
|
28
28
|
|
29
29
|
STDERR.puts(message)
|
30
30
|
|
31
|
-
random_feature = 'rubygems-' + rand(2 ** 64).to_s(36)
|
32
|
-
|
33
31
|
begin
|
32
|
+
random_feature = 'random-feature-' + rand(2 ** 64).to_s(36)
|
34
33
|
require random_feature
|
35
34
|
rescue LoadError => random_feature_load_error
|
36
35
|
message = random_feature_load_error.message.sub(random_feature, 'rubygems')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubygems-runtime
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brightworks Digital
|
@@ -48,9 +48,9 @@ extra_rdoc_files: []
|
|
48
48
|
files:
|
49
49
|
- lib/rubygems.rb
|
50
50
|
- lib/rubygems/runtime.rb
|
51
|
+
- lib/rubygems/runtime/detect_rubygems_loaded.rb
|
51
52
|
- lib/rubygems/runtime/gem_extensions.rb
|
52
|
-
- lib/rubygems/runtime/
|
53
|
-
- lib/rubygems/runtime/runtime.rb
|
53
|
+
- lib/rubygems/runtime/kernel_extensions.rb
|
54
54
|
homepage: http://github.com/ntl/rubygems-runtime
|
55
55
|
licenses:
|
56
56
|
- MIT
|
@@ -58,7 +58,7 @@ metadata:
|
|
58
58
|
homepage_uri: http://github.com/ntl/rubygems-runtime
|
59
59
|
source_code_uri: https://github.com/ntl/rubygems-runtime
|
60
60
|
allowed_push_host: https://rubygems.org
|
61
|
-
namespace:
|
61
|
+
namespace: RubyGems::Runtime
|
62
62
|
rdoc_options: []
|
63
63
|
require_paths:
|
64
64
|
- lib
|
@@ -1,63 +0,0 @@
|
|
1
|
-
# Generated by ./generate_gem_extensions.rb
|
2
|
-
module Rubygems
|
3
|
-
module Runtime
|
4
|
-
module GemExtensions
|
5
|
-
@@win_platform = nil
|
6
|
-
|
7
|
-
WIN_PATTERNS = [/bccwin/i, /cygwin/i, /djgpp/i, /mingw/i, /mswin/i, /wince/i]
|
8
|
-
|
9
|
-
def ruby_api_version
|
10
|
-
@ruby_api_version ||= target_rbconfig["ruby_version"].dup
|
11
|
-
end
|
12
|
-
|
13
|
-
def extension_api_version # :nodoc:
|
14
|
-
if target_rbconfig["ENABLE_SHARED"] == "no"
|
15
|
-
"#{ruby_api_version}-static"
|
16
|
-
else
|
17
|
-
ruby_api_version
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def default_dir
|
22
|
-
path = [
|
23
|
-
"/opt/homebrew",
|
24
|
-
"lib",
|
25
|
-
"ruby",
|
26
|
-
"gems",
|
27
|
-
RbConfig::CONFIG['ruby_version']
|
28
|
-
]
|
29
|
-
|
30
|
-
@homebrew_path ||= File.join(*path)
|
31
|
-
end
|
32
|
-
|
33
|
-
def location_of_caller(depth = 1)
|
34
|
-
caller[depth] =~ /(.*?):(\d+).*?$/i
|
35
|
-
file = $1
|
36
|
-
lineno = $2.to_i
|
37
|
-
|
38
|
-
[file, lineno]
|
39
|
-
end
|
40
|
-
|
41
|
-
def win_platform?
|
42
|
-
if @@win_platform.nil?
|
43
|
-
ruby_platform = RbConfig::CONFIG["host_os"]
|
44
|
-
@@win_platform = !WIN_PATTERNS.find {|r| ruby_platform =~ r }.nil?
|
45
|
-
end
|
46
|
-
|
47
|
-
@@win_platform
|
48
|
-
end
|
49
|
-
|
50
|
-
def java_platform?
|
51
|
-
RUBY_PLATFORM == "java"
|
52
|
-
end
|
53
|
-
|
54
|
-
def solaris_platform?
|
55
|
-
RUBY_PLATFORM.include?("solaris")
|
56
|
-
end
|
57
|
-
|
58
|
-
def freebsd_platform?
|
59
|
-
RbConfig::CONFIG["host_os"].to_s.include?("bsd")
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|