Zachary's Tool Kit contains a collection of reusable classes meant to simplify development of complex systems in Ruby. These classes provide functionality I often find myself needing from project to project. Instead of reinventing the wheel each time, I've started building a collection of reusable classes. Easy-bake DSLs, parallel processing, complex logging, templating and many other useful design patterns, for example are all contained in simple, reusable classes with a common interface and configuration style.
Add this line to your application's Gemfile:
gem 'ztk'
And then execute:
$ bundle
Or install it yourself as:
$ gem install ztk
Then run the pry console to play with it:
$ bundle exec ztk
-
ZTK::ANSI
This mixin module gives you the ability to easily add ANSI colors to strings. It also has a method for stripping all ANSI codes out of a string. Read more at the ZTK::ANSI documentation.
-
ZTK::Background
Easily run a processes in the background. Read more at the ZTK::Background documentation.
-
ZTK::Benchmark
Benchmark your code and optionally display messages and/or an "activity" indicator (i.e. spinning cursor). Read more at the ZTK::Benchmark documentation.
-
ZTK::Command
Execute local commands controlling STDOUT, STDERR and STDIN as needed plus enhanced Logger support. Read more at the ZTK::Command documentation.
-
ZTK::Config
Use Ruby based configuration files with ease. Inspired by Chef's mixlib-config. Read more at the ZTK::Config documentation.
-
ZTK::DSL
Create your own DSL in seconds by inheriting this DSL class. Featuring ActiveRecord style associations where DSL objects can
belong_to
orhas_many
other DSL objects. Read more at the ZTK::DSL::Base documentation. -
ZTK::Locator
Search for files or directories backwards up the present working directory tree. Read more at the ZTK::Locator documentation.
-
ZTK::Logger
Based off the core Ruby logger, this is meant to be a drop in replacement. Features added logging information, including PID, uSec time resolution, method and line numbers of logging statements (i.e. the caller). One can seamlessly chain Ruby loggers using ZTK:Logger, for example to output logs to both STDOUT and a log file on disk at the same time; all while maintaining compatibility with the core Ruby logger. Read more at the ZTK::Logger documentation.
-
ZTK::Parallel
Easily turn linear iterative tasks into parallel tasks and leverage multiple cores to speed up processing of your large sets of data. Read more at the ZTK::Parallel documentation.
-
ZTK::Profiler
Build timing profiles easily with this class. Allows for arbitrary nesting of profiles and provides full reporting. Read more at the ZTK::Profiler documentation.
-
ZTK::Report
Console based reporting class which allows you to easily output either list or spreadsheet based reports from sets of data. Read more at the ZTK::Report documentation.
-
ZTK::RescueRetry
Certain cases warrant retries when exceptions occur. With this class you can wrap code allowing retries in certain scenarios. The class allows for full customization so you can fit it easily to your needs. Read more at the ZTK::RescueRetry documentation.
-
ZTK::Spinner
The spinner
ZTK::Benchmark
relies on. With this class you can bend it to YOUR will! Read more at ZTK::Spinner documentation. -
ZTK::SSH
An SSH class that nicely wraps up all of the SSH gems into a nice uniform interface, complete with transfer progress callbacks and enhanced Logger support. It is meant to function as a drop in replacement, but I admit this has not been heavily tested like in the case of the ZTK::Logger class. It provides the ability to switch between SCP and SFTP for file transfers seamlessly. Full SSH proxy support as well, plus methods to spawn up interactive SSH consoles via
Kernel.exec
. Read more at the ZTK::SSH documentation. -
ZTK::TCPSocketCheck
This class provides a convient way to test if something is listening on a TCP port. One can test a varity of scenarios, including sending data across the socket and waiting for a response. Read more at the ZTK::TCPSocketCheck documentation.
-
ZTK::Template
Easily create Erubis based content with this class. Read more at the ZTK::Template documentation.
-
ZTK::UI
UI management; this class encapsulates STDOUT, STDERR, STDIN and a Ruby logger; as well as some other helpful flags. This allows you to easily present a unified UI interface and allows for easy redirection of that interface (really helpful when using StringIO's with rspec to test program output for example). Read more at the ZTK::UI documentation.
I await your pull request.
- Ruby 2.0.0
- Ruby 2.2.4
- Ruby 2.3.0
IRC:
- #jovelabs on irc.freenode.net
Documentation:
Source:
Issues:
ZTK - Zachary's Tool Kit
- Author: Zachary Patten
- Copyright: Copyright (c) Zachary Patten
- License: Apache License, Version 2.0
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.