rubygems-runtime 0.0.0.5 → 1.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9c6f940846cff7fb0b1623745160fb4201f96c6771f1b98ecb0693dcecdb673c
4
- data.tar.gz: 2cf37594f49955ea24c15ddc791ff59bf1f2e4e1619f8b8423e8ce008bc104ce
3
+ metadata.gz: c20871859e1565e8df1b72f731901e3754eaf3eeae5c41f7ed4f98dc5f008aa3
4
+ data.tar.gz: 2b71c6bb25305a5424aa2bf00f5538e37fe0f3b81e52577303e5e86f71eccc4b
5
5
  SHA512:
6
- metadata.gz: b88f51c79cf67db184c55fcb6e3b4e333b8bc31f3fe9a4d0822c8bff80514eccc4a7f8b60ba4a63dd7160b56b6634f93000db8157fa91e72d21859d706c17821
7
- data.tar.gz: cf2716732899e3b7c2636832562e8399d2b3590e4984bb5b7a986458dfbd5c21ebf2e6a469ea1d6ba1b4e45e93613a5c476562aa0d0be7648189dfc365b43a98
6
+ metadata.gz: dfa58777a22ac335801471ee9bddd150fd8db128d24c7bfb1b81a49a1c8340725fc2e599fd79b507239c851446ec068b9b45ea17589596591a73e962d0ce329d
7
+ data.tar.gz: d10e0ea2053ecf8fd052964d5a6967ceb20f43c347e5df273f2c5b88659a3e0501cbe19ed41e538eefcb28250cfff2fe7edcb8c58445907eaf921482241bab8c
@@ -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
+ # Generated by https://github.com/ntl/rubygems-runtime/blob/master/generate_gem_extensions.rb
1
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
@@ -0,0 +1,10 @@
1
+ module Rubygems
2
+ module Runtime
3
+ module KernelExtensions
4
+ def gem(*)
5
+ end
6
+
7
+ private :gem
8
+ end
9
+ end
10
+ end
@@ -1,36 +1,20 @@
1
- if defined?(Gem::VERSION)
2
- message = String.new
1
+ require 'rubygems/runtime/detect_rubygems_loaded'
3
2
 
4
- if STDERR.tty?
5
- message << "\e[31m"
6
- else
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/gem_extensions/generated'
36
- require 'rubygems/runtime/runtime'
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 ‘require "rubygems"’ and exit Ruby with a nonzero status
1
+ # Intercept attempts to load RubyGems and aborts the process with a nonzero exit status
2
2
 
3
3
  message = String.new
4
4
 
@@ -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,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubygems-runtime
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0.5
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brightworks Digital
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
11
10
  dependencies:
12
11
  - !ruby/object:Gem::Dependency
13
12
  name: test_bench
@@ -46,11 +45,13 @@ executables: []
46
45
  extensions: []
47
46
  extra_rdoc_files: []
48
47
  files:
49
- - lib/rubygems.rb
50
- - lib/rubygems/runtime.rb
48
+ - lib/rubygems
49
+ - lib/rubygems/runtime
50
+ - lib/rubygems/runtime/detect_rubygems_loaded.rb
51
51
  - lib/rubygems/runtime/gem_extensions.rb
52
- - lib/rubygems/runtime/gem_extensions/generated.rb
53
- - lib/rubygems/runtime/runtime.rb
52
+ - lib/rubygems/runtime/kernel_extensions.rb
53
+ - lib/rubygems/runtime.rb
54
+ - lib/rubygems.rb
54
55
  homepage: http://github.com/ntl/rubygems-runtime
55
56
  licenses:
56
57
  - MIT
@@ -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
@@ -1,16 +0,0 @@
1
- module Rubygems
2
- module Runtime
3
- def self.activate
4
- Gem.module_exec do
5
- extend GemExtensions
6
- end
7
-
8
- Kernel.module_exec do
9
- def gem(*)
10
- end
11
-
12
- private :gem
13
- end
14
- end
15
- end
16
- end