crystal_plus
Version, currently 0.1.25 versions
- 0.1.4latestJul 25, 2017
- 0.1.3not indexedJul 25, 2017
- 0.1.2not indexedJul 25, 2017
- 0.1.1not indexedJul 25, 2017
- 0.1.0not indexedJul 25, 2017
github.com/mosop/crystal_plus
An extension of the Crystal standard library.
5 stars
1 dependent
License: MIT
Nothing has been indexed for 0.1.2 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.
Installation
# Add this to your shard.yml
dependencies:
crystal_plus:
github: mosop/crystal_plus
version: ~> 0.1.2Then run:
shards installshard.yml
No shard.yml has been indexed for 0.1.2. You can read it on the repository.
Dependencies
Unknown: the shard.yml for this version has not been read yet.
README
This README is the one indexed from the repository at its latest ref, not from the tag for this version.
# Crystal Plus
An extension of the Crystal standard library.
[](https://travis-ci.org/mosop/crystal_plus)
## Installation
Add this to your application's `shard.yml`:
```yaml
dependencies:
crystal_plus:
github: mosop/crystal_plus
```
## Index
* [Dir](#dir)
* [.tmp](#dir.tmp) : makes a uniquely-named and temporary directory
* [NamedTuple](#named_tuple)
* [#to_h?](#named_tuple#to_h?) : is a safe to_h
* [#merge](#naemd_tuple#merge) : merges two named tuples
* [String](#string)
* [#empty_to_nil](#string#empty_to_nil) : returns nil if empty
## Dir
<a name="dir"></a>
### .tmp
<a name="dir.tmp"></a>
Makes a uniquely-named directory and yields a passed block with the directory's path. The directory is to be deleted before this method returns.
```crystal
Dir.tmp do |dir|
# The dir argument points to a new temporary directory.
end
# The directory is already deleted here.
```
#### Parameters
* base : a base directory's path whose a temporary directory will be created (default: `"/tmp"`)
* cleanup : whether to delete a created temporary directory before .tmp returns (default: `true`)
## NamedTuple
<a name="named_tuple"></a>
### #to_h?
<a name="naemd_tuple#to_h?"></a>
```crystal
def test_to_h(**options)
options.to_h
end
test_to_h # compile error
```
```crystal
require "cyrstal_plus/named_tuple/#to_h?"
def test_to_h?(**options)
options.to_h?
end
test_to_h? # => nil
```
## #merge
<a name="named_tuple#merge"></a>
```crystal
require "cyrstal_plus/named_tuple/#merge"
def merge(tuple, **options)
tuple.merge(options)
end
def reverse_merge(tuple, **options)
options.merge(tuple)
end
smile = {face: ":)"}
frown = {face: ":("}
other = {other: ":P"}
merge(smile) # => {face: ":)"}
merge(smile, **frown) # => {face: ":("}
merge(smile, **other) # => ArgumentError
reverse_merge(smile) # => ArgumentError
```
## String
<a name="string"></a>
### #empty_to_nil
<a name="string#empty_to_nil"></a>
Returns nil if self is empty. Otherwise, self.
```crystal
require "cyrstal_plus/string/#empty_to_nil"
"abc".empty_to_nil # => "abc"
"".empty_to_nil # => nil
```
## Release Notes
* v0.1.2
* String#empty_to_nil
* v0.1.1
* Dir.tmp
## Contributing
1. Fork it ( https://github.com/mosop/crystal_plus/fork )
2. Create your feature branch (git checkout -b my-new-feature)
3. Commit your changes (git commit -am 'Add some feature')
4. Push to the branch (git push origin my-new-feature)
5. Create a new Pull Request
## Contributors
- [mosop](https://github.com/mosop) - creator, maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.1.2- Tagged
- Jul 25, 2017
- Commit
54ab424f1248- Indexed
- not yet
Dependents
Repository
github.com/mosop/crystal_plus
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 12, 2026
- Synced
- Aug 12, 2026
- Versions
- 5