From 9ac374481be3cab441107156d9696b5b3bf910b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20M=C3=BCller?= Date: Tue, 8 Feb 2022 17:13:07 +0100 Subject: [PATCH 1/2] Refactor target clauses for system implementations Co-Authored-By: Guilherme Bernal --- src/crystal/system/env.cr | 6 ++++-- src/crystal/system/file_descriptor.cr | 6 ++++-- src/crystal/system/time.cr | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/crystal/system/env.cr b/src/crystal/system/env.cr index 6c6b5cf375e6..b7593c856857 100644 --- a/src/crystal/system/env.cr +++ b/src/crystal/system/env.cr @@ -12,8 +12,10 @@ module Crystal::System::Env # def self.each(&block : String, String ->) end -{% if flag?(:win32) %} +{% if flag?(:unix) %} + require "./unix/env" +{% elsif flag?(:win32) %} require "./win32/env" {% else %} - require "./unix/env" + {% raise "No implementation of Crystal::System::Env available" %} {% end %} diff --git a/src/crystal/system/file_descriptor.cr b/src/crystal/system/file_descriptor.cr index f36e3e79e750..c484503d711c 100644 --- a/src/crystal/system/file_descriptor.cr +++ b/src/crystal/system/file_descriptor.cr @@ -1,5 +1,7 @@ -{% if flag?(:win32) %} +{% if flag?(:unix) %} + require "./unix/file_descriptor" +{% elsif flag?(:win32) %} require "./win32/file_descriptor" {% else %} - require "./unix/file_descriptor" + {% raise "No Crystal::System::FileDescriptor implementation available" %} {% end %} diff --git a/src/crystal/system/time.cr b/src/crystal/system/time.cr index 340a9e06f19e..1cd635c13218 100644 --- a/src/crystal/system/time.cr +++ b/src/crystal/system/time.cr @@ -12,8 +12,10 @@ module Crystal::System::Time # def self.load_localtime : ::Time::Location? end -{% if flag?(:win32) %} +{% if flag?(:unix) %} + require "./unix/time" +{% elsif flag?(:win32) %} require "./win32/time" {% else %} - require "./unix/time" + {% raise "No implementation of Crystal::System::Time available" %} {% end %} From 8cc861bf8bb3b83ad7a5cb2d9575cd313754846d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20M=C3=BCller?= Date: Tue, 8 Feb 2022 21:46:42 +0100 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Sijawusz Pur Rahnama --- src/crystal/system/env.cr | 2 +- src/crystal/system/time.cr | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/crystal/system/env.cr b/src/crystal/system/env.cr index b7593c856857..99a6d7518648 100644 --- a/src/crystal/system/env.cr +++ b/src/crystal/system/env.cr @@ -17,5 +17,5 @@ end {% elsif flag?(:win32) %} require "./win32/env" {% else %} - {% raise "No implementation of Crystal::System::Env available" %} + {% raise "No Crystal::System::Env implementation available" %} {% end %} diff --git a/src/crystal/system/time.cr b/src/crystal/system/time.cr index 1cd635c13218..c61074437ab4 100644 --- a/src/crystal/system/time.cr +++ b/src/crystal/system/time.cr @@ -17,5 +17,5 @@ end {% elsif flag?(:win32) %} require "./win32/time" {% else %} - {% raise "No implementation of Crystal::System::Time available" %} + {% raise "No Crystal::System::Time implementation available" %} {% end %}