cognition 2.0.4 → 2.0.5

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: 1b37fef34af5c88fc16e34dd5855d50d6c214ec4
4
- data.tar.gz: aab660a7e21a9324369638de7fd663d39c32efda
3
+ metadata.gz: 9f69c16258ad17a29dd1f7ee7353d331b36c9a37
4
+ data.tar.gz: c4c31934035e95b8ce435bc7fd885e892e22c08a
5
5
  SHA512:
6
- metadata.gz: 5b34e06406f19030648972a5b1fa157b33fde810306d11a948f74ae8f306edb5a99552d06df855387f327b96f49b91ea8464ca1769c0596abbbe7380a8cf1943
7
- data.tar.gz: 793bab140adef11717fba95d70d6cc625b6c20ea5f2d89b0628931288d231b8fab91a80892116615300d77a8815b2b5e17ebb946fc0ca4f6fd1710f2ac0747a2
6
+ metadata.gz: 8f5d6226701ffe0397d560df2dd3ba32d4979cb04e216f6164d65120bcd7e16804dee9bbc7ded759cb07a698d785554ea6fd74ace914662d17a07022bd46c916
7
+ data.tar.gz: 383bfa407321bd36ab89f1bfb692aceed77f9ae917c2a36220c031dd08182e59347187aba4a8ce9375bcd31f79558ad52eee784f4f31cbad5b65b10ae8a62ce6
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in Cognition.gemspec
4
4
  gemspec
data/README.md CHANGED
@@ -66,7 +66,7 @@ matches and logic that should be run:
66
66
  ```ruby
67
67
  class Hello < Cognition::Plugins::Base
68
68
  # Simple string based matcher. Must match *EXACTLY*
69
- match 'hello', 'hello: Returns Hello World', :hello
69
+ match 'hello', :hello, help: { 'hello' => 'Returns Hello World' }
70
70
 
71
71
  # Advanced Regexp based matcher. Capture groups are made available
72
72
  # via MatchData in the matches method
@@ -74,7 +74,6 @@ class Hello < Cognition::Plugins::Base
74
74
  'hello <name>' => 'Greets you by name!'
75
75
  }
76
76
 
77
-
78
77
  def hello(*)
79
78
  'Hello World'
80
79
  end
data/Rakefile CHANGED
@@ -1,9 +1,9 @@
1
- require 'bundler/gem_tasks'
2
- require 'rake/testtask'
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
3
 
4
4
  Rake::TestTask.new do |t|
5
- t.libs << 'test'
5
+ t.libs << "test"
6
6
  end
7
7
 
8
- desc 'Run tests'
8
+ desc "Run tests"
9
9
  task :default => :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "cognition"
5
+
6
+ puts "Get started with your Cognition bot by registering the 'Hello' test plugin!"
7
+ puts "> test_bot = Cognition::Bot.new"
8
+ puts '> require_relative "../test/fixtures/hello"'
9
+ puts "> test_bot.register(Hello)\n\n"
10
+ puts "Process commands with: "
11
+ puts "> test_bot.process('message')\n\n"
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,5 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
data/cognition.gemspec CHANGED
@@ -1,16 +1,16 @@
1
1
  # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
2
+ lib = File.expand_path("../lib", __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'cognition/version'
4
+ require "cognition/version"
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "cognition"
8
8
  spec.version = Cognition::VERSION
9
9
  spec.authors = ["Nathan Anderson"]
10
10
  spec.email = ["andnat@gmail.com"]
11
- spec.summary = %q{A rules engine for running commands.}
12
- spec.description = %q{Match text; run commands. Works great for building a chatbot!}
13
- spec.homepage = "https://github.com/anoldguy/Cognition"
11
+ spec.summary = "A rules engine for running commands."
12
+ spec.description = "Match text; run commands. Works great for building a chatbot!"
13
+ spec.homepage = "https://github.com/basecamp/cognition"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
data/lib/cognition/bot.rb CHANGED
@@ -1,15 +1,15 @@
1
- require 'cognition/message'
2
- require 'cognition/matcher'
3
- require 'cognition/responder'
4
- require 'cognition/plugins/base'
5
- require 'cognition/plugins/default'
1
+ require "cognition/message"
2
+ require "cognition/matcher"
3
+ require "cognition/responder"
4
+ require "cognition/plugins/base"
5
+ require "cognition/plugins/default"
6
6
 
7
7
  module Cognition
8
8
  class Bot
9
9
  attr_accessor :plugins, :matchers
10
10
 
11
11
  def initialize
12
- # Default plugin, responds to 'ping' with 'PONG' and provides help text
12
+ # Default plugin, responds to "ping" with "PONG" and provides help text
13
13
  register(Cognition::Plugins::Default)
14
14
  end
15
15
 
@@ -42,31 +42,31 @@ module Cognition
42
42
 
43
43
  private
44
44
 
45
- def process_msg(msg)
46
- response = false
47
- matchers.each do |matcher|
48
- if matcher.attempt(msg)
49
- response = matcher.response
50
- break
51
- end
45
+ def process_msg(msg)
46
+ response = false
47
+ matchers.each do |matcher|
48
+ if matcher.attempt(msg)
49
+ response = matcher.response
50
+ break
52
51
  end
53
- response ? response : not_found(msg.command)
54
52
  end
53
+ response ? response : not_found(msg.command)
54
+ end
55
55
 
56
- def process_string(message, metadata = {})
57
- process_msg(Cognition::Message.new(message.strip, metadata))
58
- end
56
+ def process_string(message, metadata = {})
57
+ process_msg(Cognition::Message.new(message.strip, metadata))
58
+ end
59
59
 
60
- def matchers
61
- plugins.flat_map(&:matchers).compact
62
- end
60
+ def matchers
61
+ plugins.flat_map(&:matchers).compact
62
+ end
63
63
 
64
- def plugins
65
- @plugins ||= []
66
- end
64
+ def plugins
65
+ @plugins ||= []
66
+ end
67
67
 
68
- def not_found(message)
69
- "No such command: #{message}\nUse 'help' for available commands!"
70
- end
68
+ def not_found(message)
69
+ "No such command: #{message}\nUse 'help' for available commands!"
70
+ end
71
71
  end
72
72
  end
@@ -3,8 +3,8 @@ module Cognition
3
3
  attr_reader :trigger, :action, :response, :help, :match_data
4
4
 
5
5
  def initialize(trigger, options = {}, &action)
6
- raise ArgumentError, 'matcher must have a trigger' unless trigger
7
- raise ArgumentError, 'matcher must have a action' unless action
6
+ fail ArgumentError, "matcher must have a trigger" unless trigger
7
+ fail ArgumentError, "matcher must have a action" unless action
8
8
  @trigger = trigger
9
9
  @help = options[:help] ||= {}
10
10
  @action = action
@@ -5,11 +5,11 @@ module Cognition
5
5
  def initialize(command, metadata = {})
6
6
  @command = command
7
7
  @metadata = metadata
8
- @responder = Cognition::Responder.new(metadata['callback_url']) if metadata['callback_url']
8
+ @responder = Cognition::Responder.new(metadata["callback_url"]) if metadata["callback_url"]
9
9
  end
10
10
 
11
11
  def reply(text)
12
- return 'No Callback URL provided' unless @responder
12
+ return "No Callback URL provided" unless @responder
13
13
  @responder.reply(text)
14
14
  end
15
15
  end
@@ -1,6 +1,6 @@
1
- require 'erb'
2
- require 'tilt'
3
- require 'cgi'
1
+ require "erb"
2
+ require "tilt"
3
+ require "cgi"
4
4
 
5
5
  module Cognition
6
6
  module Plugins
@@ -20,7 +20,7 @@ module Cognition
20
20
  # subclass, since we can't use __FILE__ here, and have it use the
21
21
  # subclass's location.
22
22
  def self.inherited(plugin)
23
- plugin.view_root = File.dirname(caller[0].split(':',2).first)
23
+ plugin.view_root = File.dirname(caller[0].split(":", 2).first)
24
24
  end
25
25
 
26
26
  attr_accessor :matchers, :bot
@@ -51,23 +51,23 @@ module Cognition
51
51
 
52
52
  private
53
53
 
54
- def template_file(name, type, extension)
55
- # Defaults to html ERB for now. Override when calling #render(path_to_file)
56
- File.join(templates_path, "#{name}.#{type}.#{extension}")
57
- end
54
+ def template_file(name, type, extension)
55
+ # Defaults to html ERB for now. Override when calling #render(path_to_file)
56
+ File.join(templates_path, "#{name}.#{type}.#{extension}")
57
+ end
58
58
 
59
- def underscore(string)
60
- word = string.to_s.gsub(/::/, '/')
61
- word.gsub!(/([A-Z\d]+)([A-Z][a-z])/,'\1_\2')
62
- word.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
63
- word.tr!("-", "_")
64
- word.downcase!
65
- word
66
- end
59
+ def underscore(string)
60
+ word = string.to_s.gsub(/::/, "/")
61
+ word.gsub!(/([A-Z\d]+)([A-Z][a-z])/, "\1_\2")
62
+ word.gsub!(/([a-z\d])([A-Z])/, "\1_\2")
63
+ word.tr!("-", "_")
64
+ word.downcase!
65
+ word
66
+ end
67
67
 
68
- def templates_path
69
- File.expand_path("#{underscore(self.class.name)}/views", self.class.view_root)
70
- end
68
+ def templates_path
69
+ File.expand_path("#{underscore(self.class.name)}/views", self.class.view_root)
70
+ end
71
71
  end
72
72
  end
73
73
  end
@@ -1,17 +1,19 @@
1
1
  module Cognition
2
2
  module Plugins
3
3
  class Default < Cognition::Plugins::Base
4
+ # rubocop:disable Lint/AmbiguousRegexpLiteral
4
5
  match /^ping/i, :pong, help: {
5
- 'ping' => 'Test if the endpoint is responding. Returns PONG.'
6
+ "ping" => "Test if the endpoint is responding. Returns PONG."
6
7
  }
7
8
 
8
9
  match /^help\s*(?<command>.*)/i, :help, help: {
9
- 'help' => 'Lists all commands with help',
10
- 'help <command>' => 'Lists help for <command>'
10
+ "help" => "Lists all commands with help",
11
+ "help <command>" => "Lists help for <command>"
11
12
  }
13
+ # rubocop:enable Lint/AmbiguousRegexpLiteral
12
14
 
13
- def pong(msg, match_data = nil)
14
- 'PONG'
15
+ def pong(*)
16
+ "PONG"
15
17
  end
16
18
 
17
19
  def help(msg, match_data = nil)
@@ -1,4 +1,4 @@
1
- require 'httparty'
1
+ require "httparty"
2
2
  module Cognition
3
3
  class Responder
4
4
  include HTTParty
@@ -11,7 +11,7 @@ module Cognition
11
11
 
12
12
  def reply(text)
13
13
  self.class.post(@uri, @options.merge(body: { content: text }))
14
- rescue Timeout::Error => e
14
+ rescue Timeout::Error
15
15
  "Request to #{@uri} timed out."
16
16
  end
17
17
  end
@@ -1,3 +1,3 @@
1
1
  module Cognition
2
- VERSION = "2.0.4"
2
+ VERSION = "2.0.5"
3
3
  end
data/lib/cognition.rb CHANGED
@@ -1,5 +1,5 @@
1
- require 'cognition/version'
2
- require 'cognition/bot'
1
+ require "cognition/version"
2
+ require "cognition/bot"
3
3
 
4
4
  module Cognition
5
5
  end
@@ -1,37 +1,37 @@
1
- require 'tilt/haml'
2
- require 'tilt/erb'
3
- require 'haml'
1
+ require "tilt/haml"
2
+ require "tilt/erb"
3
+ require "haml"
4
4
  class Hello < Cognition::Plugins::Base
5
- match 'hello', :hello, help: {
6
- 'hello' => 'Returns Hello World'
5
+ match "hello", :hello, help: {
6
+ "hello" => "Returns Hello World"
7
7
  }
8
8
 
9
- def hello(msg, match_data = nil)
10
- 'Hello World'
9
+ def hello(*)
10
+ "Hello World"
11
11
  end
12
12
 
13
- def hi(msg, match_data = nil)
14
- @message = 'Hi'
13
+ def hi(*)
14
+ @message = "Hi"
15
15
  render
16
16
  end
17
17
 
18
- def hola(msg, match_data = nil)
19
- @message = 'Hola'
20
- render(template: File.expand_path('../hello/views/hola.haml', __FILE__))
18
+ def hola(*)
19
+ @message = "Hola"
20
+ render(template: File.expand_path("../hello/views/hola.haml", __FILE__))
21
21
  end
22
22
 
23
- def bonjour(msg, match_data = nil)
24
- @message = 'Bonjour'
23
+ def bonjour(*)
24
+ @message = "Bonjour"
25
25
  render(type: "text")
26
26
  end
27
27
 
28
- def hey(msg, match_data = nil)
29
- @message = 'Hey'
28
+ def hey(*)
29
+ @message = "Hey"
30
30
  render(extension: "haml")
31
31
  end
32
32
 
33
- def yo(msg, match_data = nil)
34
- @message = 'Yo'
35
- render(locals: {num_yos: 3})
33
+ def yo(*)
34
+ @message = "Yo"
35
+ render(locals: { num_yos: 3 })
36
36
  end
37
37
  end
@@ -1,6 +1,6 @@
1
- require 'minitest/autorun'
2
- require 'cognition'
3
- require_relative 'fixtures/hello'
1
+ require "minitest/autorun"
2
+ require "cognition"
3
+ require_relative "fixtures/hello"
4
4
 
5
5
  class CognitionTest < Minitest::Test
6
6
  def setup
@@ -21,21 +21,21 @@ class CognitionTest < Minitest::Test
21
21
  end
22
22
 
23
23
  def test_processes_messages
24
- msg = Cognition::Message.new('ping')
25
- assert_equal 'PONG', @bot.process(msg)
24
+ msg = Cognition::Message.new("ping")
25
+ assert_equal "PONG", @bot.process(msg)
26
26
  end
27
27
 
28
28
  def test_processes_strings
29
- assert_equal 'PONG', @bot.process('ping')
29
+ assert_equal "PONG", @bot.process("ping")
30
30
  end
31
31
 
32
32
  def test_processes_strings_with_metadata
33
- assert_equal 'PONG', @bot.process('ping', foo: 'bar')
33
+ assert_equal "PONG", @bot.process("ping", foo: "bar")
34
34
  end
35
35
 
36
36
  def test_shows_help_if_no_matches
37
37
  @bot.register(Hello)
38
- msg = Cognition::Message.new('pong')
38
+ msg = Cognition::Message.new("pong")
39
39
  output = @bot.process(msg)
40
40
  assert_match "No such command: pong\nUse 'help' for available commands!", output
41
41
  end
@@ -1,5 +1,5 @@
1
- require 'minitest/autorun'
2
- require 'cognition'
1
+ require "minitest/autorun"
2
+ require "cognition"
3
3
 
4
4
  class DefaultPluginTest < Minitest::Test
5
5
  def setup
data/test/test_helper.rb CHANGED
@@ -1,5 +1,7 @@
1
- require 'webmock/minitest'
1
+ require "webmock/minitest"
2
2
 
3
- class Minitest::Test
4
- include WebMock::API
3
+ module Minitest
4
+ class Test
5
+ include WebMock::API
6
+ end
5
7
  end
data/test/test_matcher.rb CHANGED
@@ -1,88 +1,88 @@
1
- require 'minitest/autorun'
2
- require 'cognition'
1
+ require "minitest/autorun"
2
+ require "cognition"
3
3
 
4
4
  class MatcherTest < Minitest::Test
5
5
  def test_raises_error_without_a_trigger
6
6
  assert_raises ArgumentError do
7
- _ = Cognition::Matcher.new(action: 'foo')
7
+ _ = Cognition::Matcher.new(action: "foo")
8
8
  end
9
9
  end
10
10
 
11
11
  def test_raises_error_without_an_action
12
12
  assert_raises ArgumentError do
13
- _ = Cognition::Matcher.new(trigger: 'foo')
13
+ _ = Cognition::Matcher.new(trigger: "foo")
14
14
  end
15
15
  end
16
16
 
17
17
  def test_matches_string
18
- msg = Cognition::Message.new('help')
19
- matcher = Cognition::Matcher.new('help', {}, &Proc.new {})
18
+ msg = Cognition::Message.new("help")
19
+ matcher = Cognition::Matcher.new("help", {}, &proc {})
20
20
  assert matcher.matches?(msg)
21
21
  end
22
22
 
23
23
  def test_string_fails_with_invalid_message
24
- msg = Cognition::Message.new('Help')
25
- matcher = Cognition::Matcher.new('help', {}, &Proc.new {})
24
+ msg = Cognition::Message.new("Help")
25
+ matcher = Cognition::Matcher.new("help", {}, &proc {})
26
26
  refute matcher.matches?(msg)
27
27
  end
28
28
 
29
29
  def test_matches_regexp
30
- msg = Cognition::Message.new('ping')
31
- matcher = Cognition::Matcher.new(/ping/, {}, &Proc.new {})
30
+ msg = Cognition::Message.new("ping")
31
+ matcher = Cognition::Matcher.new(/ping/, {}, &proc {})
32
32
  assert matcher.matches?(msg)
33
33
  end
34
34
 
35
35
  def test_regexp_fails_with_invalid_message
36
- msg = Cognition::Message.new('pink')
37
- matcher = Cognition::Matcher.new(/ping/, {}, &Proc.new {})
36
+ msg = Cognition::Message.new("pink")
37
+ matcher = Cognition::Matcher.new(/ping/, {}, &proc {})
38
38
  refute matcher.matches?(msg)
39
39
  end
40
40
 
41
41
  def test_sets_response_on_attemp_if_matches
42
- msg = Cognition::Message.new('ping')
43
- matcher = Cognition::Matcher.new(/ping/, {}, &Proc.new {'PONG'})
42
+ msg = Cognition::Message.new("ping")
43
+ matcher = Cognition::Matcher.new(/ping/, {}, &proc { "PONG" })
44
44
  matcher.attempt(msg)
45
- assert_equal 'PONG', matcher.response
45
+ assert_equal "PONG", matcher.response
46
46
  end
47
47
 
48
48
  def test_returns_false_on_attemp_if_no_match
49
- msg = Cognition::Message.new('pink')
50
- matcher = Cognition::Matcher.new(/ping/, {}, &Proc.new {'PONG'})
49
+ msg = Cognition::Message.new("pink")
50
+ matcher = Cognition::Matcher.new(/ping/, {}, &proc { "PONG" })
51
51
  refute matcher.attempt(msg)
52
52
  end
53
53
 
54
54
  def test_sets_match_data
55
- msg = Cognition::Message.new('hello john')
56
- matcher = Cognition::Matcher.new(/hello\s*(?<name>.*)/, {}, &Proc.new {'PONG'})
55
+ msg = Cognition::Message.new("hello john")
56
+ matcher = Cognition::Matcher.new(/hello\s*(?<name>.*)/, {}, &proc { "PONG" })
57
57
  matcher.matches?(msg)
58
58
  assert_equal "john", matcher.match_data[:name]
59
59
  end
60
60
 
61
61
  def test_captures_response
62
- msg = Cognition::Message.new('hello john')
63
- matcher = Cognition::Matcher.new(/hello\s*(?<name>.*)/, {}, &Proc.new(&method(:dummy_method)))
62
+ msg = Cognition::Message.new("hello john")
63
+ matcher = Cognition::Matcher.new(/hello\s*(?<name>.*)/, {}, &proc(&method(:dummy_method)))
64
64
  matcher.attempt(msg)
65
65
  assert_equal "Hello john", matcher.response
66
66
  end
67
67
 
68
68
  def test_only_sets_help_when_help_provided
69
- matcher_without_help = Cognition::Matcher.new(/hello\s*(?<name>.*)/, {}, &Proc.new(&method(:dummy_method)))
69
+ matcher_without_help = Cognition::Matcher.new(/hello\s*(?<name>.*)/, {}, &proc(&method(:dummy_method)))
70
70
  assert_equal [], matcher_without_help.help
71
71
  end
72
72
 
73
73
  def test_sets_help
74
- matcher_with_help = Cognition::Matcher.new(/hello\s*(?<name>.*)/, {help: {'hello' => 'says hello'}}, &Proc.new(&method(:dummy_method)))
75
- assert_equal ['hello - says hello'], matcher_with_help.help
74
+ matcher_with_help = Cognition::Matcher.new(/hello\s*(?<name>.*)/, { help: { "hello" => "says hello" } }, &proc(&method(:dummy_method)))
75
+ assert_equal ["hello - says hello"], matcher_with_help.help
76
76
  end
77
77
 
78
78
  def test_returns_error_if_method_returns_an_error
79
- msg = Cognition::Message.new('error')
80
- matcher_with_error = Cognition::Matcher.new(/error/, &Proc.new(&method(:error_method)))
79
+ msg = Cognition::Message.new("error")
80
+ matcher_with_error = Cognition::Matcher.new(/error/, &proc(&method(:error_method)))
81
81
  assert matcher_with_error.attempt(msg).match("'error' found, but raised")
82
82
  end
83
83
  end
84
84
 
85
- def dummy_method(msg, match_data)
85
+ def dummy_method(_, match_data)
86
86
  "Hello #{match_data['name']}"
87
87
  end
88
88
 
data/test/test_message.rb CHANGED
@@ -1,20 +1,20 @@
1
- require 'minitest/autorun'
2
- require 'cognition'
1
+ require "minitest/autorun"
2
+ require "cognition"
3
3
 
4
4
  class CognitionTest < Minitest::Test
5
5
  def test_sets_metadata
6
- msg = Cognition::Message.new('test', user_id: 15, foo: 'bar')
6
+ msg = Cognition::Message.new("test", user_id: 15, foo: "bar")
7
7
  assert_equal 15, msg.metadata[:user_id]
8
- assert_equal 'bar', msg.metadata[:foo]
8
+ assert_equal "bar", msg.metadata[:foo]
9
9
  end
10
10
 
11
11
  def test_sets_responder_if_callback_url
12
- msg = Cognition::Message.new('ping', 'callback_url' => 'http://foo.bar/')
12
+ msg = Cognition::Message.new("ping", "callback_url" => "http://foo.bar/")
13
13
  assert_kind_of Cognition::Responder, msg.responder
14
14
  end
15
15
 
16
16
  def test_no_responder_if_no_callback_url
17
- msg = Cognition::Message.new('ping', user: { name: 'foo', id: 123456 })
17
+ msg = Cognition::Message.new("ping", user: { name: "foo", id: 123_456 })
18
18
  refute msg.responder
19
19
  end
20
20
  end
data/test/test_plugin.rb CHANGED
@@ -1,5 +1,5 @@
1
- require 'minitest/autorun'
2
- require 'cognition'
1
+ require "minitest/autorun"
2
+ require "cognition"
3
3
 
4
4
  class PluginTest < Minitest::Test
5
5
  def setup
@@ -1,20 +1,20 @@
1
- require 'minitest/autorun'
2
- require 'cognition'
3
- require 'test_helper'
1
+ require "minitest/autorun"
2
+ require "cognition"
3
+ require "test_helper"
4
4
 
5
5
  class ResponderTest < Minitest::Test
6
6
  def test_sends_reply
7
- stub_request(:any, "http://foo.bar/path").
8
- to_return(status: 200)
9
- responder = Cognition::Responder.new('http://foo.bar/path')
7
+ stub_request(:any, "http://foo.bar/path")
8
+ .to_return(status: 200)
9
+ responder = Cognition::Responder.new("http://foo.bar/path")
10
10
 
11
- assert_equal 200, responder.reply('foobar').code
11
+ assert_equal 200, responder.reply("foobar").code
12
12
  end
13
13
 
14
14
  def test_handles_timeouts
15
15
  stub_request(:any, "http://foo.bar/path").to_timeout
16
- responder = Cognition::Responder.new('http://foo.bar/path')
16
+ responder = Cognition::Responder.new("http://foo.bar/path")
17
17
 
18
- assert_equal 'Request to http://foo.bar/path timed out.', responder.reply('foobar')
18
+ assert_equal "Request to http://foo.bar/path timed out.", responder.reply("foobar")
19
19
  end
20
20
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cognition
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.4
4
+ version: 2.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Anderson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-19 00:00:00.000000000 Z
11
+ date: 2016-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -111,7 +111,9 @@ dependencies:
111
111
  description: Match text; run commands. Works great for building a chatbot!
112
112
  email:
113
113
  - andnat@gmail.com
114
- executables: []
114
+ executables:
115
+ - console
116
+ - setup
115
117
  extensions: []
116
118
  extra_rdoc_files: []
117
119
  files:
@@ -120,6 +122,8 @@ files:
120
122
  - LICENSE.txt
121
123
  - README.md
122
124
  - Rakefile
125
+ - bin/console
126
+ - bin/setup
123
127
  - cognition.gemspec
124
128
  - lib/cognition.rb
125
129
  - lib/cognition/bot.rb
@@ -144,7 +148,7 @@ files:
144
148
  - test/test_message.rb
145
149
  - test/test_plugin.rb
146
150
  - test/test_responder.rb
147
- homepage: https://github.com/anoldguy/Cognition
151
+ homepage: https://github.com/basecamp/cognition
148
152
  licenses:
149
153
  - MIT
150
154
  metadata: {}