I’m looking into using frozen string literals as it appears to be the future and so on.
However, I’m having issues in my registrar when trying to force the encoding to get around that old Windows bug. If I understand it correctly __FILE__
uses correct UTF-8 encoding for its content, but the encoding property of the string is wrongly set. This is why we just want to change the encoding property without converting the string content.
The problem is that force_encoding isn’t allowed under frozen_string_literal. The following file gives me a FrozenError and wont load.
Is there anyway around this?
# frozen_string_literal: true
require "extensions.rb"
# Eneroth Extensions
module Eneroth
# Scaled Tape Measure
module ScaledTapeMeasure
path = __FILE__
path.force_encoding("UTF-8") if path.respond_to?(:force_encoding)
# Identifier for this extension.
PLUGIN_ID = File.basename(path, ".*")
# Root directory of this extension.
PLUGIN_ROOT = File.join(File.dirname(path), PLUGIN_ID)
# Extension object for this extension.
EXTENSION = SketchupExtension.new(
"Eneroth Scaled Tape Measure",
File.join(PLUGIN_ROOT, "main")
)
EXTENSION.creator = "Eneroth"
EXTENSION.description = "Measure model with respect to customs scale."
EXTENSION.version = "1.0.0"
EXTENSION.copyright = "2019, #{EXTENSION.creator}"
Sketchup.register_extension(EXTENSION, true)
end
end