From af6f7f6411c55ebc9590f2a0b12bb11de259fa9d Mon Sep 17 00:00:00 2001 From: Jeremy Woertink Date: Fri, 15 Sep 2023 15:37:19 -0700 Subject: [PATCH] Bump ameba and apply suggestions. Fixing up some code (#32) --- shard.yml | 2 +- spec/lucky_env_spec.cr | 4 ++-- src/lucky_env.cr | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/shard.yml b/shard.yml index 69e0fa1..de6a94d 100644 --- a/shard.yml +++ b/shard.yml @@ -11,4 +11,4 @@ license: MIT development_dependencies: ameba: github: crystal-ameba/ameba - version: ~> 1.0.0 + version: ~> 1.5.0 diff --git a/spec/lucky_env_spec.cr b/spec/lucky_env_spec.cr index a66f692..120629d 100644 --- a/spec/lucky_env_spec.cr +++ b/spec/lucky_env_spec.cr @@ -36,7 +36,7 @@ describe LuckyEnv do it "loads the ENV if the file exists" do results = LuckyEnv.load?("./spec/support/.env.test") results.should_not eq(nil) - data = results.not_nil! + data = results.as(Hash(String, String)) data["LUCKY_ENV"].should eq "test" ENV["LUCKY_ENV"].should eq "test" end @@ -141,7 +141,7 @@ describe LuckyEnv do end end -private def restore_env(env) +private def restore_env(env, &) yield ensure ENV.clear diff --git a/src/lucky_env.cr b/src/lucky_env.cr index 7a756f8..72b06bb 100644 --- a/src/lucky_env.cr +++ b/src/lucky_env.cr @@ -6,7 +6,7 @@ module LuckyEnv VERSION = {{ `shards version "#{__DIR__}"`.chomp.stringify }} macro add_env(name) - def LuckyEnv.{{ name.id }}? + def LuckyEnv.{{ name.id }}? : Bool environment == {{ name.id.stringify }} end end @@ -30,11 +30,11 @@ module LuckyEnv end end - def self.task? + def self.task? : Bool ENV["LUCKY_TASK"]? == "true" || ENV["LUCKY_TASK"]? == "1" end - def self.environment + def self.environment : String ENV.fetch("LUCKY_ENV", "development") end