shard
shard.cr
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.13.0
Usage
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
API
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?
Example
Why don't you dry up src/foo/version.cr
and shard.yml
?
- 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
Creating license sessage
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>
more
Roadmap
0.2.0
- [x] information for git repository
0.3.0
- [ ]
Shard.dependencies
Contributing
- 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
Contributors
- maiha maiha - creator, maintainer