compile-time shard.yml reader for Crystal.
supported versions : 0.27.2
.. 1.5.0
- Are you still dawdling in
version.cr
? - example: https://github.com/maiha/pcap.cr/commit/8a1f26e49223c431d7091b696ca72b9c2353276f
dependencies:
shard:
github: maiha/shard.cr
version: 1.1.0
Shard.xxx
returns the value.
require "shard"
Shard.name # => "foo"
Shard.version # => "0.1.0"
Shard.git_version # => "0.1.0+2"
Shard.git_description # => "foo 0.1.0+2 [0d23415] (2017-01-13)"
Shard.git_branch # => "main"
where assumed that we have following shard.yml
and git repo.
name: foo
version: 0.1.0
0d23415 2017-01-13 04:01 maiha o [master] WIP
83e1f9b 2017-01-13 04:00 maiha o fix typo
536accd 2017-01-13 03:49 maiha I <v0.1.0> first release
Shard.name : String
Shard.version : String
Shard.authors : Array(String)
Shard.program : String
Shard.time : Time
Shard.git_version : String
Shard.git_description : String
Shard.git_branch : String
Shard[key] : YAML::Type
Shard[key]? : YAML::Type?
Shard.str(key) : String
Shard.str?(key) : String?
Shard.int(key) : Int32
Shard.int?(key) : Int32?
Shard.array(key) : Int32?
- Delete
src/foo/version.cr
- Use
Shard.version
in anywhere you want.
Otherwise, use it in src/foo/version.cr
.
module Foo
VERSION = Shard.version
end
license = Shard.license
year = Shard.time.to_s("%Y")
author = Shard.authors.first.to_s
puts "The %s License (%s)" % [license, license]
puts "Copyright (c) %s %s" % [year, author]
would print
The MIT License (MIT)
Copyright (c) 2016 maiha <maiha@wota.jp>
- information for git repository
-
Shard.dependencies
- Fork it ( https://github.com/maiha/shard.cr/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
- maiha maiha - creator, maintainer