This shard is based on a duscussion I had with @asterite (the retired creator of the Crystal programming language) in this forum thread.
Honestly, all the credit for this goes to him.
NOTICE: Not all helper methods will work in every situation, because I don't fully understand the code myself, I just copied it and made a few tweaks, so, it might not work perfectly.
- Add the dependency to your
shard.yml:
dependencies:
meta:
github: crystal-china/meta- require it directly.
require "meta"There are many methods defined on Class/Object, check spec for usage.
There is another more convenient way to use meta.cr, you even don't need add
meta into shard.yml as dependency!
-
Copy file
meta.crto a local folder, e.g./home/foo/crystal/meta/meta.cr -
Add following code to the file where you want those meta helper methods.
{{ read_file("/home/foo/crystal/meta/meta.cr").id }}This use read_file macro to paste the content of meta.cr into the file where you want to use it.
You can add the folder where meta.cr is located to CRYSTAL_PATH and require it.
- Fork it (https://github.com/crystal-china/meta/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
- Ary Borenszweig
- Billy.Zheng vil963@gmail.com