lib/spoom/sorbet/sigils.rb in spoom-1.0.7 vs lib/spoom/sorbet/sigils.rb in spoom-1.0.8
- old
+ new
@@ -54,18 +54,18 @@
# returns a string containing the strictness of a sigil in a file at the passed path
# * returns nil if no sigil
sig { params(path: T.any(String, Pathname)).returns(T.nilable(String)) }
def self.file_strictness(path)
return nil unless File.exist?(path)
- content = File.read(path)
+ content = File.read(path, encoding: Encoding::ASCII_8BIT)
strictness_in_content(content)
end
# changes the sigil in the file at the passed path to the specified new strictness
sig { params(path: T.any(String, Pathname), new_strictness: String).returns(T::Boolean) }
def self.change_sigil_in_file(path, new_strictness)
- content = File.read(path)
+ content = File.read(path, encoding: Encoding::ASCII_8BIT)
new_content = update_sigil(content, new_strictness)
File.write(path, new_content)
strictness_in_content(new_content) == new_strictness
@@ -85,10 +85,10 @@
directory: T.any(String, Pathname),
strictness: String,
extension: String
).returns(T::Array[String])
end
- def self.files_with_sigil_strictness(directory, strictness, extension = ".rb")
+ def self.files_with_sigil_strictness(directory, strictness, extension: ".rb")
paths = Dir.glob("#{File.expand_path(directory)}/**/*#{extension}").sort.uniq
paths.filter do |path|
file_strictness(path) == strictness
end
end