Skip to content

Commit

Permalink
Bump min Crystal version for framework, dotenv, and validator (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Blacksmoke16 authored Jul 30, 2024
1 parent e095b1c commit 242c6c9
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 48 deletions.
2 changes: 1 addition & 1 deletion src/components/dotenv/shard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: athena-dotenv

version: 0.1.2

crystal: '>= 0.36.0'
crystal: ~> 1.13

license: MIT

Expand Down
15 changes: 3 additions & 12 deletions src/components/dotenv/src/athena-dotenv.cr
Original file line number Diff line number Diff line change
Expand Up @@ -506,18 +506,9 @@ class Athena::Dotenv

private def load(override_existing_vars : Bool, paths : Enumerable(String | ::Path)) : Nil
paths.each do |path|
# TODO: Inline this again once 1.13.0 is the new min version
{% begin %}
{% if compare_versions(Crystal::VERSION, "1.13.0-dev") >= 0 %}
is_file_readable = File::Info.readable? path
{% else %}
is_file_readable = File.readable? path
{% end %}

if !is_file_readable || File.directory?(path)
raise Athena::Dotenv::Exceptions::Path.new path
end
{% end %}
if !File::Info.readable?(path) || File.directory?(path)
raise Athena::Dotenv::Exceptions::Path.new path
end

self.populate(self.parse(File.read(path), path), override_existing_vars)
end
Expand Down
2 changes: 1 addition & 1 deletion src/components/framework/shard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: athena

version: 0.19.1

crystal: ~> 1.11
crystal: ~> 1.13

license: MIT

Expand Down
6 changes: 1 addition & 5 deletions src/components/framework/src/athena.cr
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,7 @@ module Athena::Framework
{% end %}

# Handle exiting correctly on interrupt signals
{% if compare_versions(Crystal::VERSION, "1.12.0") >= 0 %}
Process.on_terminate { self.stop }
{% else %}
Process.on_interrupt { self.stop }
{% end %}
Process.on_terminate { self.stop }

Log.info { %(Server has started and is listening at #{@ssl_context ? "https" : "http"}://#{@server.addresses.first}) }

Expand Down
11 changes: 1 addition & 10 deletions src/components/framework/src/binary_file_response.cr
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,7 @@ class Athena::Framework::BinaryFileResponse < Athena::Framework::Response
)
super nil, status, headers

# TODO: Inline this again once 1.13.0 is the new min version
{% begin %}
{% if compare_versions(Crystal::VERSION, "1.13.0-dev") >= 0 %}
is_file_readable = File::Info.readable? file_path
{% else %}
is_file_readable = File.readable? file_path
{% end %}

raise File::Error.new("File '#{file_path}' must be readable.", file: file_path) unless is_file_readable
{% end %}
raise File::Error.new("File '#{file_path}' must be readable.", file: file_path) unless File::Info.readable? file_path

@file_path = Path.new(file_path).expand

Expand Down
2 changes: 1 addition & 1 deletion src/components/validator/shard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: athena-validator

version: 0.3.3

crystal: ~> 1.6
crystal: ~> 1.13

license: MIT

Expand Down
29 changes: 11 additions & 18 deletions src/components/validator/src/constraints/file.cr
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ class Athena::Validator::Constraints::File < Athena::Validator::Constraint

class Validator < Athena::Validator::ConstraintValidator
# :inherit:
#
# ameba:disable Metrics/CyclomaticComplexity
def validate(value : _, constraint : AVD::Constraints::File) : Nil
return if value.nil? || value == ""

Expand All @@ -241,24 +243,15 @@ class Athena::Validator::Constraints::File < Athena::Validator::Constraint
return
end

# TODO: Inline this again once 1.13.0 is the new min version
{% begin %}
{% if compare_versions(Crystal::VERSION, "1.13.0-dev") >= 0 %}
is_file_readable = ::File::Info.readable? path
{% else %}
is_file_readable = ::File.readable? path
{% end %}

unless is_file_readable
self
.context
.build_violation(constraint.not_readable_message, NOT_READABLE_ERROR)
.add_parameter("\{{ file }}", path)
.add

return
end
{% end %}
unless ::File::Info.readable? path
self
.context
.build_violation(constraint.not_readable_message, NOT_READABLE_ERROR)
.add_parameter("{{ file }}", path)
.add

return
end

size_in_bytes = ::File.size path
base_name = ::File.basename path
Expand Down

0 comments on commit 242c6c9

Please sign in to comment.