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 +4 -4
- data/bin/bumbler +1 -1
- data/lib/bumbler/bundler.rb +1 -1
- data/lib/bumbler/hooks.rb +47 -16
- data/lib/bumbler/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c89d49c4a06405dfb85e410e301dc1c38b963b8fb3d01516a74c0653262c5ab4
|
4
|
+
data.tar.gz: 5166819a1081467131e185a596c0d3f2d3ed6110cf97bcf24d3c79f9389297e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 924cde7931d93dedc918501e2a151da50157983e8c9cc7fed393884c7af99ffe811d44274aba939dbc439e3b463ef21cd3b25170ceaf703d31121c529f0c9791
|
7
|
+
data.tar.gz: 2ea0410b258aa50a912979c061735ed08a8f83b800e2ed2eee061d2f488740049b9f8a8126e763e8ce8125c72674291703b67cbc6d2342bdb2560fc92fb1f89a
|
data/bin/bumbler
CHANGED
@@ -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
|
data/lib/bumbler/bundler.rb
CHANGED
data/lib/bumbler/hooks.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
25
|
-
|
26
|
-
|
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
|
-
@
|
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 &&
|
37
|
-
|
38
|
-
|
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
|
45
|
-
@
|
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.
|
data/lib/bumbler/version.rb
CHANGED
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.
|
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-
|
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.
|
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
|