bootsnap 1.3.1 → 1.3.2

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
- SHA256:
3
- metadata.gz: fc93ed69fb2f50721ee3edbd37bf5f44a617db15ad1d77cf3a675197d7b420e6
4
- data.tar.gz: 370a02dfb9fcb85d3c38ffa26c5ac89720e6ac493f9cb90262da2b096e2f0457
2
+ SHA1:
3
+ metadata.gz: 2479c73ad1318763b74c7091415a87025021cd23
4
+ data.tar.gz: 98730e7d7e4719040c59a8d5bf60f0618b44d878
5
5
  SHA512:
6
- metadata.gz: 14aee751c568fa870b4c8f694274108460a99605b32e355dfa73d25070609c06a0a9531a00f0fe66ea261428c9c0379ff39813168ffa233a5209c39e72f92779
7
- data.tar.gz: e6d2bd977b56bdc5b46d7a335f3f4fef729747527dce035233f2f590c22bb88fe35d79dae68de191ff83cb98fcb7b8a0275639b3a6bc44697c26a3bed5af1b85
6
+ metadata.gz: 85bd04d9117856b2e5615fde67066cbef2b9323b29cf3cd39938cdc3bc1759b0b5903eac9ca91b99e63bd2d3262013064ad5fb551267fd29d77c0dffb348d41d
7
+ data.tar.gz: 44884f5e8d9a003d10cb99270ed4f2101730a1ab9692c6626150da345dcb6b2e7c83c429a3145e784ee13b712b6a4c38d14fa9abe9063e019aafb05f55d011d6
@@ -1,3 +1,10 @@
1
+ # 1.3.2
2
+
3
+ * Fix Spring + Bootsnap incompatibility when there are files with similar names.
4
+ * Fix `YAML.load_file` monkey patch to keep accepting File objects as arguments.
5
+ * Fix the API for `ActiveSupport::Dependencies#autoloadable_module?`.
6
+ * Some performance improvements.
7
+
1
8
  # 1.3.1
2
9
 
3
10
  * Change load path scanning to more correctly follow symlinks.
@@ -269,6 +269,8 @@ cache_key_equal(struct bs_cache_key * k1, struct bs_cache_key * k2)
269
269
  static VALUE
270
270
  bs_rb_fetch(VALUE self, VALUE cachedir_v, VALUE path_v, VALUE handler)
271
271
  {
272
+ FilePathValue(path_v);
273
+
272
274
  Check_Type(cachedir_v, T_STRING);
273
275
  Check_Type(path_v, T_STRING);
274
276
 
@@ -36,7 +36,7 @@ module Bootsnap
36
36
 
37
37
  def self.setup_disable_trace
38
38
  if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.5.0')
39
- warn("This method is not allowed with this Ruby version. current: #{RUBY_VERSION}, allowed version: < 2.5.0")
39
+ warn("from #{caller_locations(1, 1)[0]}: The 'disable_trace' method is not allowed with this Ruby version. current: #{RUBY_VERSION}, allowed version: < 2.5.0")
40
40
  else
41
41
  RubyVM::InstructionSequence.compile_option = { trace_instruction: false }
42
42
  end
@@ -2,11 +2,13 @@ module Bootsnap
2
2
  module_function
3
3
 
4
4
  def bundler?
5
+ return false unless defined?(::Bundler)
6
+
5
7
  # Bundler environment variable
6
8
  ['BUNDLE_BIN_PATH', 'BUNDLE_GEMFILE'].each do |current|
7
9
  return true if ENV.key?(current)
8
10
  end
9
-
11
+
10
12
  false
11
13
  end
12
14
  end
@@ -48,7 +48,7 @@ module Bootsnap
48
48
  klass.send(:define_method, :load_file) do |path|
49
49
  Bootsnap::CompileCache::Native.fetch(
50
50
  cache_dir,
51
- path.to_s,
51
+ path,
52
52
  Bootsnap::CompileCache::YAML
53
53
  )
54
54
  end
@@ -14,10 +14,10 @@ module Bootsnap
14
14
  reinitialize
15
15
  end
16
16
 
17
- # Does this directory exist as a child of one of the path items?
18
- # e.g. given "/a/b/c/d" exists, and the path is ["/a/b"], has_dir?("c/d")
19
- # is true.
20
- def has_dir?(dir)
17
+ # What is the path item that contains the dir as child?
18
+ # e.g. given "/a/b/c/d" exists, and the path is ["/a/b"], load_dir("c/d")
19
+ # is "/a/b".
20
+ def load_dir(dir)
21
21
  reinitialize if stale?
22
22
  @mutex.synchronize { @dirs[dir] }
23
23
  end
@@ -108,7 +108,7 @@ module Bootsnap
108
108
  @path_obj = path_obj
109
109
  ChangeObserver.register(self, @path_obj)
110
110
  @index = {}
111
- @dirs = Hash.new(false)
111
+ @dirs = {}
112
112
  @generated_at = now
113
113
  push_paths_locked(*@path_obj)
114
114
  end
@@ -132,10 +132,11 @@ module Bootsnap
132
132
  p = Path.new(path)
133
133
  @has_relative_paths = true if p.relative?
134
134
  next if p.non_directory?
135
+ expanded_path = p.expanded_path
135
136
  entries, dirs = p.entries_and_dirs(@store)
136
137
  # push -> low precedence -> set only if unset
137
- dirs.each { |dir| @dirs[dir] ||= true }
138
- entries.each { |rel| @index[rel] ||= p.expanded_path }
138
+ dirs.each { |dir| @dirs[dir] ||= path }
139
+ entries.each { |rel| @index[rel] ||= expanded_path }
139
140
  end
140
141
  end
141
142
  end
@@ -145,10 +146,11 @@ module Bootsnap
145
146
  paths.map(&:to_s).reverse_each do |path|
146
147
  p = Path.new(path)
147
148
  next if p.non_directory?
149
+ expanded_path = p.expanded_path
148
150
  entries, dirs = p.entries_and_dirs(@store)
149
151
  # unshift -> high precedence -> unconditional set
150
- dirs.each { |dir| @dirs[dir] = true }
151
- entries.each { |rel| @index[rel] = p.expanded_path }
152
+ dirs.each { |dir| @dirs[dir] = path }
153
+ entries.each { |rel| @index[rel] = expanded_path }
152
154
  end
153
155
  end
154
156
  end
@@ -25,6 +25,14 @@ module Bootsnap
25
25
  super
26
26
  end
27
27
 
28
+ # uniq! keeps the first occurance of each path, otherwise preserving
29
+ # order, preserving the effective load path
30
+ def uniq!(*args)
31
+ ret = super
32
+ @lpc_observer.reinitialize if block_given? || !args.empty?
33
+ ret
34
+ end
35
+
28
36
  # For each method that modifies the array more aggressively, override
29
37
  # the method to also have the observer completely reconstruct its state
30
38
  # after the modification. Many of these could be made to modify the
@@ -34,7 +42,7 @@ module Bootsnap
34
42
  %i(
35
43
  []= clear collect! compact! delete delete_at delete_if fill flatten!
36
44
  insert keep_if map! pop reject! replace reverse! rotate! select!
37
- shift shuffle! slice! sort! sort_by! uniq!
45
+ shift shuffle! slice! sort! sort_by!
38
46
  ).each do |method_name|
39
47
  define_method(method_name) do |*args, &block|
40
48
  ret = super(*args, &block)
@@ -10,6 +10,14 @@ module Bootsnap
10
10
  Thread.current[:without_bootsnap_cache] = prev
11
11
  end
12
12
 
13
+ def self.allow_bootsnap_retry(allowed)
14
+ prev = Thread.current[:without_bootsnap_retry] || false
15
+ Thread.current[:without_bootsnap_retry] = !allowed
16
+ yield
17
+ ensure
18
+ Thread.current[:without_bootsnap_retry] = prev
19
+ end
20
+
13
21
  module ClassMethods
14
22
  def autoload_paths=(o)
15
23
  super
@@ -26,13 +34,19 @@ module Bootsnap
26
34
  end
27
35
 
28
36
  def autoloadable_module?(path_suffix)
29
- Bootsnap::LoadPathCache.autoload_paths_cache.has_dir?(path_suffix)
37
+ Bootsnap::LoadPathCache.autoload_paths_cache.load_dir(path_suffix)
30
38
  end
31
39
 
32
40
  def remove_constant(const)
33
41
  CoreExt::ActiveSupport.without_bootsnap_cache { super }
34
42
  end
35
43
 
44
+ def require_or_load(*)
45
+ CoreExt::ActiveSupport.allow_bootsnap_retry(true) do
46
+ super
47
+ end
48
+ end
49
+
36
50
  # If we can't find a constant using the patched implementation of
37
51
  # search_for_file, try again with the default implementation.
38
52
  #
@@ -40,8 +54,15 @@ module Bootsnap
40
54
  # behaviour. The gymnastics here are a bit awkward, but it prevents
41
55
  # 200+ lines of monkeypatches.
42
56
  def load_missing_constant(from_mod, const_name)
43
- super
57
+ CoreExt::ActiveSupport.allow_bootsnap_retry(false) do
58
+ super
59
+ end
44
60
  rescue NameError => e
61
+ # This function can end up called recursively, we only want to
62
+ # retry at the top-level.
63
+ raise if Thread.current[:without_bootsnap_retry]
64
+ # If we already had cache disabled, there's no use retrying
65
+ raise if Thread.current[:without_bootsnap_cache]
45
66
  # NoMethodError is a NameError, but we only want to handle actual
46
67
  # NameError instances.
47
68
  raise unless e.class == NameError
@@ -58,6 +79,8 @@ module Bootsnap
58
79
  def depend_on(*)
59
80
  super
60
81
  rescue LoadError
82
+ # If we already had cache disabled, there's no use retrying
83
+ raise if Thread.current[:without_bootsnap_cache]
61
84
  CoreExt::ActiveSupport.without_bootsnap_cache { super }
62
85
  end
63
86
  end
@@ -84,7 +84,7 @@ module Bootsnap
84
84
 
85
85
  private
86
86
 
87
- STRIP_EXTENSION = /\..*?$/
87
+ STRIP_EXTENSION = /\.[^.]*?$/
88
88
  private_constant :STRIP_EXTENSION
89
89
 
90
90
  def strip_extension(f)
@@ -1,3 +1,3 @@
1
1
  module Bootsnap
2
- VERSION = "1.3.1"
2
+ VERSION = "1.3.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootsnap
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Burke Libbey
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-11 00:00:00.000000000 Z
11
+ date: 2018-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -160,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
160
160
  version: '0'
161
161
  requirements: []
162
162
  rubyforge_project:
163
- rubygems_version: 2.7.6
163
+ rubygems_version: 2.6.14
164
164
  signing_key:
165
165
  specification_version: 4
166
166
  summary: Boot large ruby/rails apps faster