Commit Graph

20 Commits

Author SHA1 Message Date
Jean Boussier 070151f130 Fix require and include call style 2023-12-14 10:48:35 +01:00
Randy Stauner c094e57b2f
Remove custom permission error code and restore path in read error
Add a test to prove that if there is an error reading a file
the message contains the problematic path.

The custom permission error class and method were designed
to warn about errors with the cache path
but we stopped reporting write errors in
d878622782
and read errors in
503e9d5080
2023-07-24 15:35:22 -07:00
Randy Stauner 91977e3f22
Guard against unsupported platforms so that code can still be loaded
With this change the test suite can finish on unsupported platforms.

131 runs, 22 assertions, 0 failures, 0 errors, 114 skips
2023-06-30 14:31:03 -07:00
Jean Boussier 566dd18f5b Fix the `YAML.load_file` decorator to be as strict as regular YAML.load_file
Fix: #434

Our strictness was based on the incorrect assumption that all extra types
would use a tag, which is incorrect as `Time` and `Date` objects can be
expressed in regular YAML syntax without the use of `!ruby/object`.
2023-01-22 08:18:13 -05:00
Jean Boussier 9e1a126f4f Drop Ruby 2.4 support 2022-06-01 10:37:37 +02:00
Jean Boussier 31dce79bdb Fix Regexp and Date handling in YAML compile cache 2022-02-01 17:59:22 +01:00
Jean Boussier 487d46cfcc Appease rubocop 2022-01-31 10:48:34 +01:00
Jean byroot Boussier 2e61f8d2b2
Merge pull request #398 from Shopify/symbol-encoding
YAML compile cache: encoding aware symbols
2022-01-28 16:30:32 +01:00
Jean Boussier 647969fff5 Code style and CI improvements 2022-01-28 15:21:40 +01:00
Jean Boussier 76a05dbbca YAML compile cache: encoding aware symbols
Ref: https://github.com/msgpack/msgpack-ruby/pull/211

The default msgpack Symbol packer/unpacker is not encoding
aware which cause all non-ASCII symbols to be unpacked with
ASCII-8BIT encoding aka BINARY.

So we define a custom packer that prefix the symbol name with `1`
for UTF-8 symbols, and `0` for the others (ASCII or binary)

If `Encoding.default_internal` is set to something MessagePack
doesn't support, we entirely disable the YAML cache.
2022-01-28 13:54:45 +01:00
Jean Boussier f210df9492 Handle YAML.load_file on Psych 4 2022-01-14 17:58:35 +01:00
Jean Boussier 4366d6b54d Return a special UNCOMPILABLE value instead of raising Uncompilable
Context: https://bugs.ruby-lang.org/issues/18492

Rescuing exceptions from a C-extension is complicated, and even seem
a bit broken on Windows.

It's much simpler to return a special unique value, and likely is more performant
too.
2022-01-14 17:35:11 +01:00
Jean Boussier b277e75e85 Cleanup the rubocop config
Go back to rubocop 0.80 for Ruby 2.3 support.
Stop depending on the company style guide, as it needs a newer
rubocop.
2022-01-13 10:05:10 +01:00
Jean Boussier ee5982e589 Only disable the compile cache for source files impacted by Ruby 3.0.3 [Bug #18250] 2021-11-24 16:37:15 +01:00
Jean Boussier 33d39d2cc0 Implement a JSON compilation cache
Now that the `json` gem added a `JSON.load_file` method,
we can apply the same optimization than for YAML.
2021-09-16 14:28:07 +02:00
Pavel Rosický b13dfc9b76 psych < 4 fix 2021-08-27 02:15:06 +02:00
Jean Boussier 1d14e25824 Fix Psych 4 compatibility and add caching for YAML.unsafe_load_file
Psych 4 now load in safe mode by default, which means many
features such as aliases are disabled by default.

This makes it complicated for Bootsnap to cache, and pretty
much impossible to precompile.

So until we figure out a better solution, we're better to
entirely disable that cache for Psych 4+. However it
can stay active for `YAML.unsafe_load_file`.
2021-08-26 14:18:54 +02:00
Jean Boussier aa9b800c6b YAML cache: do not cache documents containing tags 2021-03-19 18:35:33 +01:00
Jean Boussier 68bf00ac66 Rework support for YAML symbolize_names and drop the Marshal fallback 2021-01-27 11:24:24 +01:00
Jean Boussier cfe5b4b195 CompileCache::YAML add support for symbolize_names and freeze options 2020-09-11 15:25:13 +02:00