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 no direct dependencies, it won't accomplish 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

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.

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, 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", "~> 0.1"