-
-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC: shards version
to obtain current version defined in shard.yml
#147
Comments
Sth like this? :) module Foo
VERSION = begin
YAML.parse(File.read(File.join(__DIR__, "../..", "shard.yml")))["version"].as_s
end
end |
That needs to be read at compile time, if not it will depend on shard.yml
being present when executed, which is why suggested something that can be
used with macros.
Sorry for top posting, sent from mobile.
…On Jan 21, 2017 14:43, "Sijawusz Pur Rahnama" ***@***.***> wrote:
Sth like this? :)
module Foo
VERSION = begin
YAML.parse(File.read(File.join(__DIR__, "../..", "shard.yml")))["version"].as_s
endend
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#147 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAQVtFmF0MjwSsoOpd09_ICNmKELmQLks5rUkPMgaJpZM4Lp4gl>
.
|
I think it's a valuable addition. @ysbaddaden, would you be against adding this? |
No strong opinion. That would allow something like: module Wonderful
VERSION = {{ `shards version` }}
end Thought, how to be sure that the folder the command is run in, is the one with the expected Or maybe the following would work, granted that the command would search the parent folders recursively for a module Wonderful
VERSION = {{ `shards version __DIR__` }}
end |
Thank you @ysbaddaden for taking the time to look into this. Really didn't put a lot of thought into the idea, which got exposed by the issue you described for libs (and what could be a problem). I think that Will you accept such contribution? Will try to find some time to hack on this during the weekend. Thank you. ❤️ ❤️ ❤️ |
Please do ❤️ |
Done!, submitted #148. Cheers! 😸 |
Sometimes is useful to obtain the current version string of the library/project you're working on, either to help you determine if was bumped (when preparing for a new release) or when integrating it within the library's `VERSION` constant (through macros). This change introduces `version` command for such purpose, allowing you retrieve from current directory (by default) or be able to provide a different path. Usage example module Foo VERSION = {{ `shards version #{__DIR__}`.chomp.stringify }} end Resulting in a `Foo::VERSION` matching the `version` defined in `shard.yml`. Fixes crystal-lang#147
For some libraries I define
VERSION
constant to help me obtain version information at runtime of the components used by other tools.The issue I found is that on every release, I have to update
version.cr
,shard.yml
and match with the tag used in Git.Was thinking that could be possible to introduce a way to read
shard.yml
(provided by shards itself) so a macro can be used to generate theVERSION
constant.Not sure about the name of the command, but if approved I can send a pull request to introduce it.
Thank you. ❤️ ❤️ ❤️
The text was updated successfully, but these errors were encountered: