bootsnap 1.9.2 → 1.10.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/bootsnap.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative('bootsnap/version')
4
- require_relative('bootsnap/bundler')
5
- require_relative('bootsnap/load_path_cache')
6
- require_relative('bootsnap/compile_cache')
3
+ require_relative("bootsnap/version")
4
+ require_relative("bootsnap/bundler")
5
+ require_relative("bootsnap/load_path_cache")
6
+ require_relative("bootsnap/compile_cache")
7
7
 
8
8
  module Bootsnap
9
9
  InvalidConfiguration = Class.new(StandardError)
@@ -18,10 +18,10 @@ module Bootsnap
18
18
 
19
19
  def self.logger=(logger)
20
20
  @logger = logger
21
- if logger.respond_to?(:debug)
22
- self.instrumentation = ->(event, path) { @logger.debug("[Bootsnap] #{event} #{path}") }
21
+ self.instrumentation = if logger.respond_to?(:debug)
22
+ ->(event, path) { @logger.debug("[Bootsnap] #{event} #{path}") }
23
23
  else
24
- self.instrumentation = ->(event, path) { @logger.call("[Bootsnap] #{event} #{path}") }
24
+ ->(event, path) { @logger.call("[Bootsnap] #{event} #{path}") }
25
25
  end
26
26
  end
27
27
 
@@ -57,63 +57,42 @@ module Bootsnap
57
57
  "If you use Ruby 2.5 or newer this option is useless, if not upgrading is recommended."
58
58
  end
59
59
 
60
- if compile_cache_iseq
61
- if iseq_cache_tracing_bug?
62
- warn "Ruby 2.5 has a bug that break code tracing when code is loaded from cache. It is recommended " \
63
- "to turn `compile_cache_iseq` off on Ruby 2.5"
64
- end
65
-
66
- if iseq_cache_anonymous_params_bug?
67
- warn "Your version of Ruby 3.1.0-dev has a bug that break bytecode caching (https://github.com/ruby/ruby/pull/4961)."
68
- end
60
+ if compile_cache_iseq && !iseq_cache_supported?
61
+ warn "Ruby 2.5 has a bug that break code tracing when code is loaded from cache. It is recommened " \
62
+ "to turn `compile_cache_iseq` off on Ruby 2.5"
69
63
  end
70
64
 
71
- Bootsnap::LoadPathCache.setup(
72
- cache_path: cache_dir + '/bootsnap/load-path-cache',
73
- development_mode: development_mode,
74
- ) if load_path_cache
65
+ if load_path_cache
66
+ Bootsnap::LoadPathCache.setup(
67
+ cache_path: cache_dir + "/bootsnap/load-path-cache",
68
+ development_mode: development_mode,
69
+ )
70
+ end
75
71
 
76
72
  Bootsnap::CompileCache.setup(
77
- cache_dir: cache_dir + '/bootsnap/compile-cache',
73
+ cache_dir: cache_dir + "/bootsnap/compile-cache",
78
74
  iseq: compile_cache_iseq,
79
75
  yaml: compile_cache_yaml,
80
76
  json: compile_cache_json,
81
77
  )
82
78
  end
83
79
 
84
- def self.iseq_cache_tracing_bug?
85
- return @iseq_cache_tracing_bug if defined? @iseq_cache_tracing_bug
80
+ def self.iseq_cache_supported?
81
+ return @iseq_cache_supported if defined? @iseq_cache_supported
86
82
 
87
83
  ruby_version = Gem::Version.new(RUBY_VERSION)
88
- @iseq_cache_tracing_bug = ruby_version < Gem::Version.new('2.5.0') || ruby_version >= Gem::Version.new('2.6.0')
89
- end
90
-
91
- def self.iseq_cache_anonymous_params_bug?
92
- return @iseq_cache_anonymous_params_bug if defined? @iseq_cache_anonymous_params_bug
93
- begin
94
- if defined? RubyVM::InstructionSequence
95
- RubyVM::InstructionSequence.compile("def foo(*); ->{ super }; end").to_binary
96
- RubyVM::InstructionSequence.compile("def foo(**); ->{ super }; end").to_binary
97
- end
98
- false
99
- rescue TypeError
100
- true
101
- end
102
- end
103
-
104
- def self.iseq_cache_supported?
105
- !(iseq_cache_tracing_bug? || iseq_cache_anonymous_params_bug?)
84
+ @iseq_cache_supported = ruby_version < Gem::Version.new("2.5.0") || ruby_version >= Gem::Version.new("2.6.0")
106
85
  end
107
86
 
108
87
  def self.default_setup
109
- env = ENV['RAILS_ENV'] || ENV['RACK_ENV'] || ENV['ENV']
110
- development_mode = ['', nil, 'development'].include?(env)
88
+ env = ENV["RAILS_ENV"] || ENV["RACK_ENV"] || ENV["ENV"]
89
+ development_mode = ["", nil, "development"].include?(env)
111
90
 
112
- unless ENV['DISABLE_BOOTSNAP']
113
- cache_dir = ENV['BOOTSNAP_CACHE_DIR']
91
+ unless ENV["DISABLE_BOOTSNAP"]
92
+ cache_dir = ENV["BOOTSNAP_CACHE_DIR"]
114
93
  unless cache_dir
115
94
  config_dir_frame = caller.detect do |line|
116
- line.include?('/config/')
95
+ line.include?("/config/")
117
96
  end
118
97
 
119
98
  unless config_dir_frame
@@ -125,25 +104,34 @@ module Bootsnap
125
104
  end
126
105
 
127
106
  path = config_dir_frame.split(/:\d+:/).first
128
- path = File.dirname(path) until File.basename(path) == 'config'
107
+ path = File.dirname(path) until File.basename(path) == "config"
129
108
  app_root = File.dirname(path)
130
109
 
131
- cache_dir = File.join(app_root, 'tmp', 'cache')
110
+ cache_dir = File.join(app_root, "tmp", "cache")
132
111
  end
133
112
 
134
-
135
113
  setup(
136
- cache_dir: cache_dir,
137
- development_mode: development_mode,
138
- load_path_cache: !ENV['DISABLE_BOOTSNAP_LOAD_PATH_CACHE'],
139
- compile_cache_iseq: !ENV['DISABLE_BOOTSNAP_COMPILE_CACHE'] && iseq_cache_supported?,
140
- compile_cache_yaml: !ENV['DISABLE_BOOTSNAP_COMPILE_CACHE'],
141
- compile_cache_json: !ENV['DISABLE_BOOTSNAP_COMPILE_CACHE'],
114
+ cache_dir: cache_dir,
115
+ development_mode: development_mode,
116
+ load_path_cache: !ENV["DISABLE_BOOTSNAP_LOAD_PATH_CACHE"],
117
+ compile_cache_iseq: !ENV["DISABLE_BOOTSNAP_COMPILE_CACHE"] && iseq_cache_supported?,
118
+ compile_cache_yaml: !ENV["DISABLE_BOOTSNAP_COMPILE_CACHE"],
119
+ compile_cache_json: !ENV["DISABLE_BOOTSNAP_COMPILE_CACHE"],
142
120
  )
143
121
 
144
- if ENV['BOOTSNAP_LOG']
122
+ if ENV["BOOTSNAP_LOG"]
145
123
  log!
146
124
  end
147
125
  end
148
126
  end
127
+
128
+ if RbConfig::CONFIG["host_os"] =~ /mswin|mingw|cygwin/
129
+ def self.absolute_path?(path)
130
+ path[1] == ":"
131
+ end
132
+ else
133
+ def self.absolute_path?(path)
134
+ path.start_with?("/")
135
+ end
136
+ end
149
137
  end
metadata CHANGED
@@ -1,99 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootsnap
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.2
4
+ version: 1.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Burke Libbey
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-11-24 00:00:00.000000000 Z
11
+ date: 2022-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: rake-compiler
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: minitest
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '5.0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '5.0'
69
- - !ruby/object:Gem::Dependency
70
- name: mocha
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '1.2'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '1.2'
83
13
  - !ruby/object:Gem::Dependency
84
14
  name: msgpack
85
15
  requirement: !ruby/object:Gem::Requirement
86
16
  requirements:
87
17
  - - "~>"
88
18
  - !ruby/object:Gem::Version
89
- version: '1.0'
19
+ version: '1.2'
90
20
  type: :runtime
91
21
  prerelease: false
92
22
  version_requirements: !ruby/object:Gem::Requirement
93
23
  requirements:
94
24
  - - "~>"
95
25
  - !ruby/object:Gem::Version
96
- version: '1.0'
26
+ version: '1.2'
97
27
  description: Boot large ruby/rails apps faster
98
28
  email:
99
29
  - burke.libbey@shopify.com
@@ -136,7 +66,7 @@ licenses:
136
66
  - MIT
137
67
  metadata:
138
68
  bug_tracker_uri: https://github.com/Shopify/bootsnap/issues
139
- changelog_uri: https://github.com/Shopify/bootsnap/blob/master/CHANGELOG.md
69
+ changelog_uri: https://github.com/Shopify/bootsnap/blob/main/CHANGELOG.md
140
70
  source_code_uri: https://github.com/Shopify/bootsnap
141
71
  allowed_push_host: https://rubygems.org
142
72
  post_install_message: