attentive 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ed9424d444fc7b37aa1ad0e003fa687a00fc5aa6
4
- data.tar.gz: 031fc365d1be4944cd5c612caa218c7d64cc2e97
3
+ metadata.gz: 83c00c687fb2775e98c9241f3d5b50cfeda1f081
4
+ data.tar.gz: 160136973d7d6f3a6b3c661a0f91259a2b719a4c
5
5
  SHA512:
6
- metadata.gz: 015a425a258acc78e6d0d5b0d99c8af95c0af16ced679de556863219d99a6c59610af1353bf2f92b777b91f69a7fbb727304baa77b7301b5547b842e921d97c1
7
- data.tar.gz: 4f4fc07e43650c108b8f01511485716a17f360d6c8a7d6d2e76ba4fbb81379b4bbcfaa79007f2d280aa45b0dc60c6f214c27c6062b8b28da070cf7bc175960da
6
+ metadata.gz: e4b1788cecb43890e207c919be1061cff04a894035e4fa343bf6b66302d54b8cd20e97b86e384e2626519821e539a34511f27a28c968ad0766330dfaa4166950
7
+ data.tar.gz: 76a8fa1d38d9a6800b07f2fa72fbe47589b1186a87ca779de832627c64edde5c3be48f8dbb013087ba128f5168f826252f0aff915c897bccdbb1353055f4ac7f
data/attentive.gemspec CHANGED
@@ -28,4 +28,5 @@ Gem::Specification.new do |spec|
28
28
  spec.add_development_dependency "minitest-reporters-turn_reporter"
29
29
  spec.add_development_dependency "shoulda-context"
30
30
  spec.add_development_dependency "timecop"
31
+ spec.add_development_dependency "rr"
31
32
  end
@@ -21,6 +21,8 @@ module Attentive
21
21
  end
22
22
 
23
23
  def hear(message)
24
+ message = Attentive::Message.new(message) unless message.is_a?(Attentive::Message)
25
+
24
26
  listeners = select { |listener| listener.matches_context?(message) }
25
27
 
26
28
  # Listen for any known phrase, starting with any token in the message.
@@ -3,13 +3,14 @@ require "attentive/tokenizer"
3
3
 
4
4
  module Attentive
5
5
  class Message
6
- attr_reader :contexts, :text
6
+ attr_reader :contexts, :text, :original_message
7
7
 
8
- def initialize(text, params={})
9
- raise ArgumentError, "Message cannot be initialized without 'text'" unless text
10
- @text = text
8
+ def initialize(original_message, params={})
9
+ @original_message = original_message
10
+ @text = original_message.to_s
11
11
  @contexts = Set.new(params.fetch(:contexts, []))
12
- contexts << :conversation if tokens.grep(Attentive::Tokens::Invocation).any?
12
+ @contexts << :conversation if tokens.grep(Attentive::Tokens::Invocation).any?
13
+ @contexts += Array(original_message.contexts) if original_message.respond_to?(:contexts)
13
14
  end
14
15
 
15
16
  def tokens
@@ -1,3 +1,3 @@
1
1
  module Attentive
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attentive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bob Lail
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-29 00:00:00.000000000 Z
11
+ date: 2016-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thread_safe
@@ -136,6 +136,20 @@ dependencies:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rr
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
139
153
  description:
140
154
  email:
141
155
  - bob.lailfamily@gmail.com