bumbler 0.7.0 → 0.8.0

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: c3c424f5491aa2f8ccc79cbf4f5825c477af3e77b74b85f6adcae5e3b522bebf
4
- data.tar.gz: 63a03128fe7576578c5aa5a1486f261276c352d863607b687ba683033a950a8d
3
+ metadata.gz: c89d49c4a06405dfb85e410e301dc1c38b963b8fb3d01516a74c0653262c5ab4
4
+ data.tar.gz: 5166819a1081467131e185a596c0d3f2d3ed6110cf97bcf24d3c79f9389297e6
5
5
  SHA512:
6
- metadata.gz: d186ef879c97e124d3cef56d8b0241ab90730da9746ee46560861c973ab48189197f3efb94be5e9093421996401a03aa50df6c001589985960a28c697044868f
7
- data.tar.gz: c5decf76369edd662024404e7fa657d59ba3c99fa5918a37af57d3efbd9122d1b8a12c005794bff9ee44407abe3f8395f8fa878a19b668fedd9c95a6e244f98b
6
+ metadata.gz: 924cde7931d93dedc918501e2a151da50157983e8c9cc7fed393884c7af99ffe811d44274aba939dbc439e3b463ef21cd3b25170ceaf703d31121c529f0c9791
7
+ data.tar.gz: 2ea0410b258aa50a912979c061735ed08a8f83b800e2ed2eee061d2f488740049b9f8a8126e763e8ce8125c72674291703b67cbc6d2342bdb2560fc92fb1f89a
@@ -37,7 +37,7 @@ if options[:initializers]
37
37
  add_load_path.call # bundler kicks us out
38
38
  require 'bumbler/track_initializers'
39
39
  require './config/environment'
40
- elsif File.exist?('./config/environment')
40
+ elsif File.exist?('./config/environment.rb')
41
41
  require 'bumbler/go'
42
42
  require './config/environment'
43
43
  add_load_path.call # bundler kicks us out
@@ -22,7 +22,7 @@ module Bumbler
22
22
  @require_map = {}
23
23
  @gem_state = {}
24
24
 
25
- ::Bundler.environment.current_dependencies.each do |spec|
25
+ ::Bundler.load.current_dependencies.each do |spec|
26
26
  gem_name = spec.name
27
27
  @gem_state[gem_name] = {}
28
28
 
@@ -5,12 +5,6 @@ module Bumbler
5
5
  @started_items = {}
6
6
  @slow_requires = {}
7
7
 
8
- module RequireLogger
9
- def require(path, *args)
10
- ::Bumbler::Hooks.handle_require(path) { super }
11
- end
12
- end
13
-
14
8
  # Everything's a class method (we're a singleton)
15
9
  class << self
16
10
  attr_writer :slow_threshold
@@ -19,13 +13,41 @@ module Bumbler
19
13
 
20
14
  # Inject our custom handling of require into the Kernel.
21
15
  def hook_require!
22
- @hooking_require = true
16
+ hook_instance_require!
17
+ hook_singleton_require!
18
+ end
19
+
20
+ def hook_instance_require!
21
+ @hooking_instance_require = true
22
+
23
+ ::Kernel.module_eval do
24
+ orig_instance_require = instance_method(:require)
25
+ define_method(:require) do |path, *args|
26
+ ::Bumbler::Hooks.handle_require(path) do
27
+ orig_instance_require.bind(self).call(path, *args)
28
+ end
29
+ end
30
+ private :require # rubocop:disable Style/AccessModifierDeclarations
31
+ end
32
+
33
+ @hooking_instance_require = nil
34
+ end
35
+
36
+ def hook_singleton_require!
37
+ @hooking_singleton_require = true
23
38
 
24
- # There are two independent require methods. Joy!
25
- ::Kernel.prepend RequireLogger
26
- (class << ::Kernel; self; end).prepend RequireLogger
39
+ ::Kernel.module_eval do
40
+ class << self
41
+ orig_public_require = Kernel.public_method(:require)
42
+ define_method(:require) do |path, *args|
43
+ ::Bumbler::Hooks.handle_require(path) do
44
+ orig_public_require.call(path, *args)
45
+ end
46
+ end
47
+ end
48
+ end
27
49
 
28
- @hooking_require = nil
50
+ @hooking_singleton_require = nil
29
51
  end
30
52
 
31
53
  # Even better: Other gems hook require as well. The instance method one at least.
@@ -33,16 +55,25 @@ module Bumbler
33
55
  ::Kernel.module_eval do
34
56
  # It isn't previously defined in Kernel. This could be a bit dangerous, though.
35
57
  def self.method_added(method_name, *_args)
36
- if method_name == :require && !::Bumbler::Hooks.hooking_require?
37
- # Fix those hooks.
38
- ::Bumbler::Hooks.hook_require!
58
+ if method_name == :require && !Bumbler::Hooks.hooking_instance_require?
59
+ ::Bumbler::Hooks.hook_instance_require!
60
+ end
61
+ end
62
+
63
+ def self.singleton_method_added(method_name, *_args)
64
+ if method_name == :require && !Bumbler::Hooks.hooking_singleton_require?
65
+ ::Bumbler::Hooks.hook_singleton_require!
39
66
  end
40
67
  end
41
68
  end
42
69
  end
43
70
 
44
- def hooking_require?
45
- @hooking_require
71
+ def hooking_instance_require?
72
+ @hooking_instance_require
73
+ end
74
+
75
+ def hooking_singleton_require?
76
+ @hooking_singleton_require
46
77
  end
47
78
 
48
79
  # Actually do something about a require here.
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Bumbler
3
- VERSION = '0.7.0'
3
+ VERSION = '0.8.0'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bumbler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian MacLeod
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-09 00:00:00.000000000 Z
11
+ date: 2020-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bump
@@ -104,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
104
  - !ruby/object:Gem::Version
105
105
  version: '0'
106
106
  requirements: []
107
- rubygems_version: 3.0.3
107
+ rubygems_version: 3.1.3
108
108
  signing_key:
109
109
  specification_version: 4
110
110
  summary: Find slowly loading gems for your Bundler-based projects