ptools
Version, currently 0.1.12 versions
- 0.2.0latestMay 9, 2026
- 0.1.1not indexedMay 9, 2026
github.com/djberg96/crystal-ptools
Extra methods for the File class based on Unix command line tools
Nothing has been indexed for 0.1.1 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:
ptools:
github: djberg96/crystal-ptools
version: ~> 0.1.1Then run:
shards installshard.yml
No shard.yml has been indexed for 0.1.1. 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-ptools
This is a Crystal port of the "ptools" library originally written for Ruby. It contains additional singleton methods for the File class.
Installation
-
Add the dependency to your
shard.yml:dependencies: crystal-ptools: github: djberg96/crystal-ptools -
Run
shards install
Usage
require "crystal-ptools"
# Simulate the "which" command:
File.which("crystal") # => "/opt/homebrew/bin/crystal"
File.which("bogus") # => nil
# Simulate the "whereis" command (minus the man pages):
File.whereis("crystal") # => ["/opt/homebrew/bin/crystal"]
File.whereis("bogus") # => []
# Test to see if a file is an image:
File.image?("/path/to/some_image.bmp") # Is the file an image
# Or check for a specific type of image:
File.bmp?("/path/to/some_file.bmp") # Is the file a bitmap file?
File.jpg?("/path/to/some_file.jpg") # Is the file a JPEG file?
File.ico?("/path/to/some_file.ico") # Is the file an ICO file?
File.png?("/path/to/some_file.png") # Is the file a PNG file?
File.tiff?("/path/to/some_file.tiff") # Is the file a TIFF file?
# Test to see if a file is a binary file:
File.binary?("/bin/ls") # true
File.binary?("/path/to/some_file.jpg") # false
# Simulate the "wc" command:
File.wc("/path/to/some_file.txt", "words")
File.wc("/path/to/some_file.txt", "chars")
File.wc("/path/to/some_file.txt", "lines")
File.wc("/path/to/some_file.txt", "bytes")
Development
To run the specs, simply clone the repo and run crystal spec.
Contributing
- Fork it (https://github.com/djberg96/crystal-ptools/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
- Daniel Berger - creator and maintainer
Copyright
(C) 2022-2025, Daniel J. Berger All Rights Reserved
Author
Daniel J. Berger
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.1- Tagged
- May 9, 2026
- Commit
b268d40c024b- Indexed
- not yet
Dependents
No indexed shard depends on this one yet.
Repository
github.com/djberg96/crystal-ptools
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 14, 2026
- Synced
- Aug 14, 2026
- Versions
- 2