talking 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 805d840951ca51ae671a94407b05878786b3a15e
4
- data.tar.gz: 09902d4d942a7ac47cdcd365ace8378fd345d9ce
3
+ metadata.gz: 6a388f7fceabf7ef23972e5a0148f28639be83a8
4
+ data.tar.gz: e9991bd58529fbeae726fe9a4487d46d92a889dc
5
5
  SHA512:
6
- metadata.gz: 24fcca654189b8b68d88cec0836e930ef283cda223601a65ab9b609d3b80d1187138dc233d9b176f732b2192910f588d4688d8c8f02ecb0728d9abc0fe9f6a68
7
- data.tar.gz: 5366a8c4f42eb5d8e37f57d9fae3e28d2149521760ae3ea71f47941a96db437768de7533f7137ae1856af0f95626ac16043b45ba0080fb6faabb17100f6fee4d
6
+ metadata.gz: 5ec1c276c4a0311162c83bfb8dd553b1f5e731d82510cbb00d7e923b5d4f8e6971d79856fd2f5ed70b8da6cf43162296f5532d0de2b2ccb8aec2087d02503f67
7
+ data.tar.gz: ebd8829e21cfc73e459bb9b45a31839c20733ea27e64c4621c855d1cd73efb076d55ec73f9e506db98701797a25e7cc63271f11957ddbb63dffb65a8fabb2c2b
data/README.md CHANGED
@@ -55,6 +55,24 @@ def mouth
55
55
  end
56
56
  ```
57
57
 
58
+ You can also add a proxy to your speaker objects:
59
+
60
+ ```ruby
61
+ module Borat
62
+ class << self
63
+ include Talking::Talkative
64
+ end
65
+ end
66
+
67
+ class Bruno
68
+ include Talking::TalkThrough
69
+ talk_through Borat
70
+ end
71
+
72
+ bruno = Bruno.new
73
+ bruno.say("Hello with Borat's voice!")
74
+ ```
75
+
58
76
  ## Development
59
77
 
60
78
  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.
data/lib/talking.rb CHANGED
@@ -48,4 +48,31 @@ module Talking
48
48
  )
49
49
  end
50
50
  end
51
+
52
+ # Public: A helper mixin that enables talking through other speakers.
53
+ module TalkThrough
54
+ def self.included(klass)
55
+ klass.extend(ClassMethods)
56
+ klass.extend(SingleForwardable)
57
+ end
58
+
59
+ # Forwardable won't work here, we have to meta-define this stuff.
60
+ %w(say debug).each do |method|
61
+ define_method(method.to_sym) do |*args|
62
+ self.class.speaker.send(method, *args)
63
+ end
64
+ end
65
+
66
+ module ClassMethods
67
+ # Public: Defines a speaker to talk through.
68
+ def talk_through(speaker)
69
+ @speaker = speaker
70
+ end
71
+
72
+ # Public: Returns defined speaker.
73
+ def speaker
74
+ @speaker
75
+ end
76
+ end
77
+ end
51
78
  end
@@ -1,3 +1,3 @@
1
1
  module Talking
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: talking
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kris Kovalik