Project

talking

0.0
No commit activity in last 3 years
No release in over 3 years
This tiny library provides simple talking module for command line apps.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.10
~> 10.0
>= 0
 Project Readme

Talking

Simple talking module for your programs. Don't confuse it with logging. It's not logging. It's just the simplest possible module that allows your application to speak two kinds of messages, natural (standard) and (debug). It's easily configurable and embeddable into your stuff.

Installation

Add this line to your application's Gemfile:

gem 'talking'

And then execute:

$ bundle

Or install it yourself as:

$ gem install talking

Usage

Give voice to your class or module:

require 'talking'

class Person
  include Talking::Talkative
end

borat = Person.new
borat.say('Hello!')
borat.debug('This is niiiice!')

The outputs can be configured using either stream, null or custom voices. Here are defaults:

Person.mouth.natural_voice = Talking::StreamVoice.new(STDERR)
Person.mouth.debug_voice = Talking::NullVoice.instance

Debug mode is actually automatic, whenever you provide DEBUG environment variable set to 1 it will automatically set stream voice for debugging, otherwise the null one will be used. In the end code we have something like this, so you can have an idea:

def mouth
  @mouth ||= Mouth.new(
    StreamVoice.new(STDERR),
    ENV['DEBUG'] == '1' ? StreamVoice.new(STDERR) : NullVoice.instance
  )
end

You can also add a proxy to your speaker objects:

module Borat
  class << self
    include Talking::Talkative
  end
end

class Bruno
  include Talking::TalkThrough
  talk_through Borat
end

bruno = Bruno.new
bruno.say("Hello with Borat's voice!")

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 tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/talking.