Dcat
English | 日本語
A Ruby gem for creating and searching disk catalogs. Generate searchable catalogs containing file lists and metadata (size, modification date) with efficient gzip compression for storage.
Features
- Create catalogs from directory structures with file metadata
- Search catalogs efficiently using ripgrep
- Compress catalogs with gzip for space-efficient storage
- Cross-platform support with Windows compatibility
- Human-readable file sizes in output
Installation
Install the gem by executing:
$ gem install dcatOr add to your Gemfile:
gem 'dcat'Usage
Configuration
Create a configuration file at ~/.catalogrc:
general:
catalogdir: ./dataCommands
Create a catalog
$ dcatc [directory_path]Creates a catalog file from the specified directory (or current directory if not specified).
Search catalogs
$ dcats [search_pattern]Searches through catalog files for files matching the pattern.
Read compressed catalogs
$ dcatz [catalog_file.gz]Alternative to zcat for reading compressed catalog files, especially useful on Windows.
Catalog File Format
Catalog files are stored as tab-separated values:
- Column 1: Full file path
- Column 2: Modification date (YYYY-MM-DD format)
- Column 3: File size (bytes)
- Column 4: File size rounded up to KB (e.g.
1 KB,120,564 KB)
Files can be compressed with gzip (.gz extension) for efficient storage.
Examples
# Create a catalog of the current directory
$ dcatc
# Create a catalog of a specific directory
$ dcatc /path/to/directory
# Search for files containing "document"
$ dcats document
# Search for files with specific extension
$ dcats "*.pdf"
# Read a compressed catalog
$ dcatz catalog.gzDevelopment
After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests.
# Install dependencies
$ bundle install
# Run tests
$ rake test
# Build the gem
$ bundle exec rake build
# Install locally
$ bundle exec rake install
# Interactive console
$ bin/consoleRequirements
- Ruby >= 2.6.0
-
ripgrep(rg) command for searching functionality
Dependencies
-
sys-filesystem- For disk space information -
zlib- For gzip compression/decompression
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/src256/dcat.
License
The gem is available as open source under the terms of the MIT License.