talking 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 805d840951ca51ae671a94407b05878786b3a15e
4
+ data.tar.gz: 09902d4d942a7ac47cdcd365ace8378fd345d9ce
5
+ SHA512:
6
+ metadata.gz: 24fcca654189b8b68d88cec0836e930ef283cda223601a65ab9b609d3b80d1187138dc233d9b176f732b2192910f588d4688d8c8f02ecb0728d9abc0fe9f6a68
7
+ data.tar.gz: 5366a8c4f42eb5d8e37f57d9fae3e28d2149521760ae3ea71f47941a96db437768de7533f7137ae1856af0f95626ac16043b45ba0080fb6faabb17100f6fee4d
data/.editorconfig ADDED
@@ -0,0 +1,12 @@
1
+ root = true
2
+
3
+ [*]
4
+ indent_style = space
5
+ indent_size = 2
6
+ end_of_line = lf
7
+ charset = utf-8
8
+ trim_trailing_whitespace = true
9
+ insert_final_newline = true
10
+
11
+ [*.md]
12
+ trim_trailing_whitespace = false
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.1
4
+ before_install: gem install bundler -v 1.10.6
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in talking.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,67 @@
1
+ # Talking
2
+
3
+ Simple talking module for your programs. Don't confuse it with logging. It's not logging. It's just
4
+ 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.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'talking'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install talking
21
+
22
+ ## Usage
23
+
24
+ Give voice to your class or module:
25
+
26
+ ```ruby
27
+ require 'talking'
28
+
29
+ class Person
30
+ include Talking::Talkative
31
+ end
32
+
33
+ borat = Person.new
34
+ borat.say('Hello!')
35
+ borat.debug('This is niiiice!')
36
+ ```
37
+
38
+ The outputs can be configured using either stream, null or custom voices. Here are defaults:
39
+
40
+ ```ruby
41
+ Person.mouth.natural_voice = Talking::StreamVoice.new(STDERR)
42
+ Person.mouth.debug_voice = Talking::NullVoice.instance
43
+ ```
44
+
45
+ Debug mode is actually automatic, whenever you provide `DEBUG` environment variable set to `1`
46
+ it will automatically set stream voice for debugging, otherwise the null one will be used. In the
47
+ end code we have something like this, so you can have an idea:
48
+
49
+ ```ruby
50
+ def mouth
51
+ @mouth ||= Mouth.new(
52
+ StreamVoice.new(STDERR),
53
+ ENV['DEBUG'] == '1' ? StreamVoice.new(STDERR) : NullVoice.instance
54
+ )
55
+ end
56
+ ```
57
+
58
+ ## Development
59
+
60
+ 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.
61
+
62
+ 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](https://rubygems.org).
63
+
64
+ ## Contributing
65
+
66
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/talking.
67
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "talking"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,3 @@
1
+ module Talking
2
+ VERSION = "0.1.0"
3
+ end
data/lib/talking.rb ADDED
@@ -0,0 +1,51 @@
1
+ require "talking/version"
2
+ require "forwardable"
3
+ require "singleton"
4
+
5
+ # Public: A talking module. It allows our program to verbosely tell us what he does while
6
+ # performing stuff around.
7
+ module Talking
8
+ # Public: Silence. Mutes our poor program.
9
+ class NullVoice
10
+ include Singleton
11
+
12
+ def puts(msg, *args)
13
+ end
14
+ end
15
+
16
+ # Public: Simple to-stream output voice. It prints stuff up to initialized IO.
17
+ StreamVoice = Struct.new(:stream) do
18
+ def puts(msg, *args)
19
+ stream.puts(format(msg, *args))
20
+ end
21
+ end
22
+
23
+ # Public: Your program should use mouth to speak stuff. Give him this ones.
24
+ Mouth = Struct.new(:natural_voice, :debug_voice) do
25
+ # Public: Says simple stuff with formatted parameters.
26
+ def say(msg, *args)
27
+ natural_voice.puts(msg, *args)
28
+ end
29
+
30
+ # Public: Debug information print. Uses secondary, debug voice output.
31
+ def debug(msg, *args)
32
+ debug_voice.puts("DEBUG: #{msg}", *args)
33
+ end
34
+ end
35
+
36
+ # Public: Incldue this stuff into your class to make it talkative.
37
+ module Talkative
38
+ def self.included(klass)
39
+ klass.extend(Forwardable)
40
+ klass.delegate([:say, :debug] => :mouth)
41
+ end
42
+
43
+ # Public: Configured mouth object.
44
+ def mouth
45
+ @mouth ||= Mouth.new(
46
+ StreamVoice.new(STDERR),
47
+ ENV['DEBUG'] == '1' ? StreamVoice.new(STDERR) : NullVoice.instance
48
+ )
49
+ end
50
+ end
51
+ end
data/talking.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'talking/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "talking"
8
+ spec.version = Talking::VERSION
9
+ spec.authors = ["Kris Kovalik"]
10
+ spec.email = ["hi@kkvlk.me"]
11
+
12
+ spec.summary = %q{Wanna teach your app talking a little?}
13
+ spec.description = %q{This tiny library provides simple talking module for command line apps.}
14
+ spec.homepage = "https://github.com/kkvlk/talking"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.10"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rspec"
24
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: talking
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Kris Kovalik
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-12-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: This tiny library provides simple talking module for command line apps.
56
+ email:
57
+ - hi@kkvlk.me
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".editorconfig"
63
+ - ".gitignore"
64
+ - ".rspec"
65
+ - ".travis.yml"
66
+ - Gemfile
67
+ - README.md
68
+ - Rakefile
69
+ - bin/console
70
+ - bin/setup
71
+ - lib/talking.rb
72
+ - lib/talking/version.rb
73
+ - talking.gemspec
74
+ homepage: https://github.com/kkvlk/talking
75
+ licenses: []
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.4.6
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: Wanna teach your app talking a little?
97
+ test_files: []