-
-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* still prevent Rails const from being defined
- Loading branch information
Showing
8 changed files
with
13 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
[submodule "vendor/jets-gems"] | ||
path = vendor/jets-gems | ||
url = https://github.com/tongueroo/jets-gems | ||
[submodule "vendor/rails"] | ||
path = vendor/rails | ||
url = https://github.com/tongueroo/rails.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,13 @@ | ||
# Works with io.rb | ||
# IO.flush # flush output and write to disk for node shim | ||
module Kernel | ||
JETS_OUTPUT = "/tmp/jets-output.log" | ||
@@io_buffer = [] | ||
module_function | ||
|
||
# List from https://ruby-doc.org/core-2.5.1/Kernel.html | ||
# Note, will lose pp format in the @io_buffer but looks like a lot of work to keep the pp format. | ||
# Must override stdout which can be messy quick: https://www.ruby-forum.com/topic/43725 | ||
OVERRIDE_METHODS = %w[ | ||
p | ||
pp | ||
printf | ||
putc | ||
puts | ||
] | ||
# NOTE adding sprintf produces #<%s: %s:%s/%s> with puma? So not including sprintf | ||
OVERRIDE_METHODS.each do |meth| | ||
# Example of generated code: | ||
# | ||
# alias_method :original_puts, :puts | ||
# def puts(*args, &block) | ||
# @@io_buffer << args.first # message | ||
# original_puts(*args, &block) | ||
# end | ||
# | ||
class_eval <<~CODE | ||
alias_method :original_#{meth}, :#{meth} | ||
def #{meth}(*args, &block) | ||
@@io_buffer << args.first # message | ||
original_#{meth}(*args, &block) | ||
end | ||
CODE | ||
end | ||
|
||
def io_buffer | ||
@@io_buffer | ||
end | ||
|
||
# Note: Writing binary data to the log will crash the process with an error like this: | ||
# jets/lib/jets/core_ext/kernel.rb:20:in `write': "\x89" from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError) | ||
# Rescue and discard it to keep the process alive. | ||
def io_flush | ||
chunk = @@io_buffer.join("\n") | ||
chunk += "\n" unless chunk == '' | ||
begin | ||
# since we always append to the file, the node shim is responsible for truncating the file | ||
IO.write(JETS_OUTPUT, chunk, mode: 'a') if chunk | ||
# Writing to log with binary content will crash the process so rescuing it and writing an info message. | ||
rescue Encoding::UndefinedConversionError | ||
IO.write(JETS_OUTPUT, "[BINARY DATA]\n", mode: 'a') | ||
end | ||
@@io_buffer = [] | ||
alias_method :jets_original_require, :require | ||
# @param path [String] | ||
# @return [Boolean] | ||
def require(path) | ||
# Hack to prevent Rails const from being defined | ||
# Actionview requires "rails-html-sanitizer" and that creates a Rails module | ||
path = "jets-html-sanitizer" if path == "rails-html-sanitizer" | ||
jets_original_require(path) | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule rails
deleted from
cde5f3