Releases: wyhaines/defined.cr
Fix Environment Variable Checks
Some ill-conceived specs led to a false sense of security about the correct implementation of the environment variable checks. This release hopefully fixes them, so that none of the checks result in a positive result if the environment variable is not defined at all. i.e. if_disabled? should not be true if the environment variable is not defined. It should only be true if the variable is defined, and the value is a falsey value.
This may be a breaking change.
Internals Refactor & BugFix
I discovered that the internals had flaws and didn't do the right things in some cases. This refactor should be much more correct.
It Handles (Mostly) MacroExpressions
This release works around a challenge that is posed by version specifications that use a macro which is not itself in a {% begin %} ... {% end %}
block:
class Foo
VERSION = {{ `shards version "#{__DIR__}"`.chomp.stringify }}
end
Please read the docs about some caveats around this, however.
Environment Variable Checks & Better Documentation
All of the recent changes are documented, and the ability to check based on environment variables has been implemented.
Version Checks
This release adds the ability to check versions and conditionally compile based on the result of those checks.
Breaking change -- improve the if/unless macros
Originally, the macros took code as text. I don't know why I did that. One can take code via block syntax, and I don't think there should be any problems with that since the evaluation is in the context of the macro, so even blocks that reference things that they can't know about, out of context, will be fine because the code doesn't actually get compiled or interpreted out of context.
So:
if_defined("Foo") do
puts "#{Foo} is defined"
end
Will work.
Add (if|unless)_defined? to make conditionals easier
This release adds a little more documentation, and it adds `#if_defined?" and "#unless_defined?" which can be used to do things conditionally that are not normally possible conditionally. i.e. conditional class definitions or conditional requires.
Initial Release
This is the simplest thing that can possibly work, for defining a defined?
function.