bootsnap 1.3.0-java → 1.3.1-java

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
  SHA1:
3
- metadata.gz: cdde006d5130b8c6d3dc1a923e94139e91f39796
4
- data.tar.gz: 228ae04f056fbd5c5b3a18c1fbb6588fd37198c6
3
+ metadata.gz: cd5c47eb0d49337b4fbdcc59a5265f1287d07532
4
+ data.tar.gz: fa734ba3ca1004392713d93da4761d562d431a54
5
5
  SHA512:
6
- metadata.gz: 79ce8fc873239e8346261347f88247c18d4edc30003747c65c29f3e1d696714cee69c3261d86fe30e93c0a7f754ddc759c817cad4233a54b71da670555c7824a
7
- data.tar.gz: 74b41e0b71d7c2e94a63a6f9b095acd21a1d3987e50fd7f4e5f36544344044a7129ec77d9643d0f28d3f174ad7dde003b437ca0e73f9faebaf641715e6d845ff
6
+ metadata.gz: 9de9aa3c282c663c6b2d7bdd1d620f5d84b5f676090a7aaa9579e046345ee8342a58e2716434fb67c2ce5875a87f678891da318b1a9654ecd16887675e5d4e33
7
+ data.tar.gz: 7eef7fb5e4946d5eb3b0082bedf9eb8b81561e89c61c8c9d53f6616de01c7096b72a7c673b572f807d75f18fa8107cdd45f6b56f943f930663db457049816081
@@ -1,3 +1,7 @@
1
+ # 1.3.1
2
+
3
+ * Change load path scanning to more correctly follow symlinks.
4
+
1
5
  # 1.3.0
2
6
 
3
7
  * Handle cases where load path entries are symlinked (https://github.com/Shopify/bootsnap/pull/136)
@@ -56,11 +56,11 @@ Bootsnapのすべての機能はセットアップ時の設定に従って開発
56
56
  Bootsnap は、処理に時間のかかるメソッドの結果をキャッシュすることで最適化しています。これは、大きく分けて2つのカテゴリに分けられます。
57
57
 
58
58
  * [Path Pre-Scanning](#path-pre-scanning)
59
- * `Kernel#require` と `Kernel#load` を `$LOAD_PATH` フルスキャンを行わないように変更します。
60
-   * `ActiveSupport::Dependencies.{autoloadable_module?,load_missing_constant,depend_on}` を `ActiveSupport::Dependencies.autoload_paths` のフルスキャンを行わないようにオーバーライドします。
59
+ * `Kernel#require` と `Kernel#load` を `$LOAD_PATH` フルスキャンを行わないように変更します。
60
+ * `ActiveSupport::Dependencies.{autoloadable_module?,load_missing_constant,depend_on}` を `ActiveSupport::Dependencies.autoload_paths` のフルスキャンを行わないようにオーバーライドします。
61
61
  * [Compilation caching](#compilation-caching)
62
-  * Ruby バイトコードのコンパイル結果をキャッシュするためのメソッド `RubyVM::InstructionSequence.load_iseq` が実装されています。
63
-   * `YAML.load_file` を YAML オブジェクトのロード結果を MessagePack でキャッシュするように変更します。 MessagePack でサポートされていないタイプが使われている場合は Marshal が使われます。
62
+ * Ruby バイトコードのコンパイル結果をキャッシュするためのメソッド `RubyVM::InstructionSequence.load_iseq` が実装されています。
63
+ * `YAML.load_file` を YAML オブジェクトのロード結果を MessagePack でキャッシュするように変更します。 MessagePack でサポートされていないタイプが使われている場合は Marshal が使われます。
64
64
 
65
65
  ### Path Pre-Scanning
66
66
 
@@ -35,6 +35,10 @@ module Bootsnap
35
35
  end
36
36
 
37
37
  def self.setup_disable_trace
38
- RubyVM::InstructionSequence.compile_option = { trace_instruction: false }
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")
40
+ else
41
+ RubyVM::InstructionSequence.compile_option = { trace_instruction: false }
42
+ end
39
43
  end
40
44
  end
@@ -103,14 +103,6 @@ module Bootsnap
103
103
  @mutex.synchronize { push_paths_locked(*paths) }
104
104
  end
105
105
 
106
- def each_requirable
107
- @mutex.synchronize do
108
- @index.each do |rel, entry|
109
- yield "#{entry}/#{rel}"
110
- end
111
- end
112
- end
113
-
114
106
  def reinitialize(path_obj = @path_obj)
115
107
  @mutex.synchronize do
116
108
  @path_obj = path_obj
@@ -1,37 +1,28 @@
1
1
  module Bootsnap
2
2
  module LoadPathCache
3
3
  module ChangeObserver
4
- def self.register(observer, arr)
5
- # Re-overriding these methods on an array that already has them would
6
- # cause StackOverflowErrors
7
- return if arr.respond_to?(:push_without_lpc)
8
-
4
+ module ArrayMixin
9
5
  # For each method that adds items to one end or another of the array
10
6
  # (<<, push, unshift, concat), override that method to also notify the
11
7
  # observer of the change.
12
- sc = arr.singleton_class
13
- sc.send(:alias_method, :shovel_without_lpc, :<<)
14
- arr.define_singleton_method(:<<) do |entry|
15
- observer.push_paths(self, entry.to_s)
16
- shovel_without_lpc(entry)
8
+ def <<(entry)
9
+ @lpc_observer.push_paths(self, entry.to_s)
10
+ super
17
11
  end
18
12
 
19
- sc.send(:alias_method, :push_without_lpc, :push)
20
- arr.define_singleton_method(:push) do |*entries|
21
- observer.push_paths(self, *entries.map(&:to_s))
22
- push_without_lpc(*entries)
13
+ def push(*entries)
14
+ @lpc_observer.push_paths(self, *entries.map(&:to_s))
15
+ super
23
16
  end
24
17
 
25
- sc.send(:alias_method, :unshift_without_lpc, :unshift)
26
- arr.define_singleton_method(:unshift) do |*entries|
27
- observer.unshift_paths(self, *entries.map(&:to_s))
28
- unshift_without_lpc(*entries)
18
+ def unshift(*entries)
19
+ @lpc_observer.unshift_paths(self, *entries.map(&:to_s))
20
+ super
29
21
  end
30
22
 
31
- sc.send(:alias_method, :concat_without_lpc, :concat)
32
- arr.define_singleton_method(:concat) do |entries|
33
- observer.push_paths(self, *entries.map(&:to_s))
34
- concat_without_lpc(entries)
23
+ def concat(entries)
24
+ @lpc_observer.push_paths(self, *entries.map(&:to_s))
25
+ super
35
26
  end
36
27
 
37
28
  # For each method that modifies the array more aggressively, override
@@ -41,16 +32,22 @@ module Bootsnap
41
32
  # accounting cost would be greater than the hit from these, since we
42
33
  # actively discourage calling them.
43
34
  %i(
44
- collect! compact! delete delete_at delete_if fill flatten! insert map!
45
- reject! reverse! select! shuffle! shift slice! sort! sort_by!
46
- ).each do |meth|
47
- sc.send(:alias_method, :"#{meth}_without_lpc", meth)
48
- arr.define_singleton_method(meth) do |*a|
49
- send(:"#{meth}_without_lpc", *a)
50
- observer.reinitialize
35
+ []= clear collect! compact! delete delete_at delete_if fill flatten!
36
+ insert keep_if map! pop reject! replace reverse! rotate! select!
37
+ shift shuffle! slice! sort! sort_by! uniq!
38
+ ).each do |method_name|
39
+ define_method(method_name) do |*args, &block|
40
+ ret = super(*args, &block)
41
+ @lpc_observer.reinitialize
42
+ ret
51
43
  end
52
44
  end
53
45
  end
46
+
47
+ def self.register(observer, arr)
48
+ arr.instance_variable_set(:@lpc_observer, observer)
49
+ arr.extend(ArrayMixin)
50
+ end
54
51
  end
55
52
  end
56
53
  end
@@ -11,7 +11,7 @@ module Bootsnap
11
11
  end
12
12
 
13
13
  module Kernel
14
- private
14
+ module_function
15
15
 
16
16
  alias_method :require_without_bootsnap, :require
17
17
 
@@ -63,56 +63,6 @@ module Kernel
63
63
  end
64
64
  end
65
65
 
66
- class << Kernel
67
- alias_method :require_without_bootsnap, :require
68
-
69
- def require_with_bootsnap_lfi(path, resolved = nil)
70
- Bootsnap::LoadPathCache.loaded_features_index.register(path, resolved) do
71
- require_without_bootsnap(resolved || path)
72
- end
73
- end
74
-
75
- def require(path)
76
- return false if Bootsnap::LoadPathCache.loaded_features_index.key?(path)
77
-
78
- if resolved = Bootsnap::LoadPathCache.load_path_cache.find(path)
79
- return require_with_bootsnap_lfi(path, resolved)
80
- end
81
-
82
- raise Bootsnap::LoadPathCache::CoreExt.make_load_error(path)
83
- rescue Bootsnap::LoadPathCache::ReturnFalse
84
- return false
85
- rescue Bootsnap::LoadPathCache::FallbackScan
86
- require_with_bootsnap_lfi(path)
87
- end
88
-
89
- alias_method :require_relative_without_bootsnap, :require_relative
90
- def require_relative(path)
91
- realpath = Bootsnap::LoadPathCache.realpath_cache.call(
92
- caller_locations(1..1).first.absolute_path, path
93
- )
94
- require(realpath)
95
- end
96
-
97
- alias_method :load_without_bootsnap, :load
98
- def load(path, wrap = false)
99
- if resolved = Bootsnap::LoadPathCache.load_path_cache.find(path)
100
- return load_without_bootsnap(resolved, wrap)
101
- end
102
-
103
- # load also allows relative paths from pwd even when not in $:
104
- if File.exist?(relative = File.expand_path(path))
105
- return load_without_bootsnap(relative, wrap)
106
- end
107
-
108
- raise Bootsnap::LoadPathCache::CoreExt.make_load_error(path)
109
- rescue Bootsnap::LoadPathCache::ReturnFalse
110
- return false
111
- rescue Bootsnap::LoadPathCache::FallbackScan
112
- load_without_bootsnap(path, wrap)
113
- end
114
- end
115
-
116
66
  class Module
117
67
  alias_method :autoload_without_bootsnap, :autoload
118
68
  def autoload(const, path)
@@ -3,16 +3,8 @@ require_relative '../explicit_require'
3
3
  module Bootsnap
4
4
  module LoadPathCache
5
5
  module PathScanner
6
- # Glob pattern to find requirable files and subdirectories in given path.
7
- # It expands to:
8
- #
9
- # * `/*{.rb,.so,/}` - It matches requirable files, directories and
10
- # symlinks to directories at given path.
11
- # * `/*/**/*{.rb,.so,/}` - It matches requirable files and
12
- # subdirectories in any (even symlinked) directory at given path at
13
- # any directory tree depth.
14
- #
15
- REQUIRABLES_AND_DIRS = "/{,*/**/}*{#{DOT_RB},#{DL_EXTENSIONS.join(',')},/}"
6
+ ALL_FILES = "/{,**/*/**/}*"
7
+ REQUIRABLE_EXTENSIONS = [DOT_RB] + DL_EXTENSIONS
16
8
  NORMALIZE_NATIVE_EXTENSIONS = !DL_EXTENSIONS.include?(LoadPathCache::DOT_SO)
17
9
  ALTERNATIVE_NATIVE_EXTENSIONS_PATTERN = /\.(o|bundle|dylib)\z/
18
10
  BUNDLE_PATH = Bootsnap.bundler? ?
@@ -34,13 +26,13 @@ module Bootsnap
34
26
  dirs = []
35
27
  requirables = []
36
28
 
37
- Dir.glob(path + REQUIRABLES_AND_DIRS).each do |absolute_path|
29
+ Dir.glob(path + ALL_FILES).each do |absolute_path|
38
30
  next if contains_bundle_path && absolute_path.start_with?(BUNDLE_PATH)
39
- relative_path = absolute_path.slice!(relative_slice)
31
+ relative_path = absolute_path.slice(relative_slice)
40
32
 
41
- if relative_path.end_with?('/')
42
- dirs << relative_path[0..-2]
43
- else
33
+ if File.directory?(absolute_path)
34
+ dirs << relative_path
35
+ elsif REQUIRABLE_EXTENSIONS.include?(File.extname(relative_path))
44
36
  requirables << relative_path
45
37
  end
46
38
  end
@@ -3,7 +3,7 @@ require_relative '../bootsnap'
3
3
  env = ENV['RAILS_ENV'] || ENV['RACK_ENV'] || ENV['ENV']
4
4
  development_mode = ['', nil, 'development'].include?(env)
5
5
 
6
- # only enable on 'ruby' (MRI), POSIX (darin, linux, *bsd), and >= 2.3.0
6
+ # only enable on 'ruby' (MRI), POSIX (darwin, linux, *bsd), and >= 2.3.0
7
7
  enable_cc =
8
8
  RUBY_ENGINE == 'ruby' &&
9
9
  RUBY_PLATFORM =~ /darwin|linux|bsd/ &&
@@ -1,3 +1,3 @@
1
1
  module Bootsnap
2
- VERSION = "1.3.0"
2
+ VERSION = "1.3.1"
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.0
4
+ version: 1.3.1
5
5
  platform: java
6
6
  authors:
7
7
  - Burke Libbey
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-09 00:00:00.000000000 Z
11
+ date: 2018-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement