0.0
The project is in a healthy, maintained state
PrettyFeed provides a modulizer you can include in a job, worker, class, rake task, etc, which allows for simple pass/fail logging colorization. Defaults are `truthy: 'green'` and `falsey: 'red'`.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 13.0
~> 3.12
~> 1.0, >= 1.0.5
~> 0.9, >= 0.9.34
~> 2.4
~> 1.0, >= 1.0.1
~> 16.1, >= 16.1.1
~> 0.5, >= 0.5.2
~> 0.0

Runtime

~> 1.1, >= 1.1.3
 Project Readme

PrettyFeed

PrettyFeed is a modulizer you can include in a job, worker, class, rake task, etc, which allows for simple pass/fail logging colorization. Defaults are truthy: 'green' and falsey: 'red'.

While this gem has few direct dependencies, it won't do much for you unless you are using a "console output coloring" gem of some kind.

Installation

Install the gem and add to the application's Gemfile by executing:

$ bundle add pretty_feed

If bundler is not being used to manage dependencies, install the gem by executing:

$ gem install pretty_feed

Usage

namespace :scrub do
  task blurb: :environment do |_t, _args|
    include PrettyFeed::PfTf.new(truthy: "green", falsey: "blue")
    pftf("this will be green: ", true)
    # => "this will be green: true" # in the console
    pftf("this will be blue: ", false)
    # => "this will be blue: false" # in the console
  end
end

Instead of passing truthy or falsey values, you can pass a proc that will be evaluated with the value passed to it as an argument.

namespace :scrub do
  task blurb: :environment do |_t, someth|
    include PrettyFeed::PfTf.new(truthy: "green", falsey: "blue")
    pftf("might be green or blue: ", someth, ->(a) { a })
    # => "might be green or blue: #{someth}" # in the console
    #     NOTE: the color will depend on what someth is and whether the proc evaluates as truthy or falsey.
  end
end

Options

Released v1.0.0 has new features, all tested at 100% line & branch coverage. Overall I'm sure the library maintains >= 90% line & branch coverage, and probably 100%, but combining the various runs with each String color library is hard.

  • pftf now accepts a block, and when given:
    • [BEG] #{msg}#{value} is logged before executing the block
    • [FIN] #{msg}#{value} is logged after executing the block
  • options hash as fourth parameter to pftf!
    • :rescue_logged - Error classes that should be rescued and logged. Default: []
    • :backtrace_logged - When truthy, rescued errors log a full backtrace. Default: nil
    • :reraise - When truthy, rescued errors will be re-raised. Default: nil
    • :benchmark - When truthy, prints realtime spent executing block. Default: nil

Find examples of these options in use, with and without blocks, in pf_tf_spec.rb, as all options are fully tested.

Library Defaults

ColorizedString (from the colorize gem) will be used if it is defined?. I prefer it because it doesn't pollute the String class with color methods.

Library Options

It will also work with strings that respond to the colors you select as methods on the String instance. This means it should work with colored2, awesome_print, term-ansicolor, and many other similar gems. If your strings do not respond to color methods there will be a warn message printed to STDERR. Colors available depend on the gem you use to provide the color methods! The various gems do not have uniform sets of colors, nor names of colors.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.

Contributing

See CONTRIBUTING.md

Contributors

Contributors

Made with contributors-img.

License

The gem is available as open source under the terms of the MIT License License: MIT. See LICENSE for the official Copyright Notice.

Code of Conduct

Everyone interacting in the PrettyFeed project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

Versioning

This library aims to adhere to Semantic Versioning 2.0.0. Violations of this scheme should be reported as bugs. Specifically, if a minor or patch version is released that breaks backward compatibility, a new version should be immediately released that restores compatibility. Breaking changes to the public API will only be introduced with new major versions.

As a result of this policy, you can (and should) specify a dependency on this gem using the Pessimistic Version Constraint with two digits of precision.

For example:

spec.add_dependency("pretty_feed", "~> 1.0")