Skip to content

Commit 7cc4a89

Browse files
authored
chore (file_response): implement macro for crystal version check (#1918)
* chore (file): implement macro for crystal version check * refactor (file_response): improve version check macro
1 parent ff1bebd commit 7cc4a89

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/lucky/file_response.cr

+9-3
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,13 @@ class Lucky::FileResponse < Lucky::Response
120120
File.expand_path(path, Dir.current)
121121
end
122122

123-
private def file_exists? : Bool
124-
File.file?(full_path) && File.readable?(full_path)
125-
end
123+
{% if compare_versions(Crystal::VERSION, "1.13.0") >= 0 %}
124+
private def file_exists? : Bool
125+
File.file?(full_path) && File::Info.readable?(full_path)
126+
end
127+
{% else %}
128+
private def file_exists? : Bool
129+
File.file?(full_path) && File.readable?(full_path)
130+
end
131+
{% end %}
126132
end

0 commit comments

Comments
 (0)