cognition 2.0.5 → 2.0.6

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: 9f69c16258ad17a29dd1f7ee7353d331b36c9a37
4
- data.tar.gz: c4c31934035e95b8ce435bc7fd885e892e22c08a
3
+ metadata.gz: 0fee2a13ff5efc9bdd6be1a8c4be10b980d1e641
4
+ data.tar.gz: fea3717ab564a976080201025d641ab65e584980
5
5
  SHA512:
6
- metadata.gz: 8f5d6226701ffe0397d560df2dd3ba32d4979cb04e216f6164d65120bcd7e16804dee9bbc7ded759cb07a698d785554ea6fd74ace914662d17a07022bd46c916
7
- data.tar.gz: 383bfa407321bd36ab89f1bfb692aceed77f9ae917c2a36220c031dd08182e59347187aba4a8ce9375bcd31f79558ad52eee784f4f31cbad5b65b10ae8a62ce6
6
+ metadata.gz: 789570221b292d985f550719c978135d3cd976c27dc4544859dcb1ca4d786d83de866a4d1f5ffb60a20610022484ee42fb6dc0059825cb1dab44b815d69a621f
7
+ data.tar.gz: 7f1dfa3993d8ee9cb3fc7b03e880a0ca8b84ac4f7c6ee764cfa5626cded7aa5d3eb56e4e46ad20502f77e581be922e145621e4aba920b0738d32d4af7aecccea
@@ -22,10 +22,16 @@ module Cognition
22
22
  run(msg)
23
23
  end
24
24
 
25
- def run(msg)
26
- @response = action.call(msg, match_data)
27
- rescue => e
28
- @response = "'#{msg.command}' found, but raised #{e.inspect}"
25
+ if ENV and ENV["RAILS_ENV"] == "production"
26
+ def run(msg)
27
+ @response = action.call(msg, match_data)
28
+ rescue => e
29
+ @response = "'#{msg.command}' found, but raised #{e.inspect}"
30
+ end
31
+ else
32
+ def run(msg)
33
+ @response = action.call(msg, match_data)
34
+ end
29
35
  end
30
36
 
31
37
  def matches?(msg)
@@ -58,8 +58,8 @@ module Cognition
58
58
 
59
59
  def underscore(string)
60
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")
61
+ word.gsub!(/([A-Z\d]+)([A-Z][a-z])/, "\\1_\\2")
62
+ word.gsub!(/([a-z\d])([A-Z])/, "\\1_\\2")
63
63
  word.tr!("-", "_")
64
64
  word.downcase!
65
65
  word
@@ -1,3 +1,3 @@
1
1
  module Cognition
2
- VERSION = "2.0.5"
2
+ VERSION = "2.0.6"
3
3
  end
data/test/test_matcher.rb CHANGED
@@ -74,18 +74,8 @@ class MatcherTest < Minitest::Test
74
74
  matcher_with_help = Cognition::Matcher.new(/hello\s*(?<name>.*)/, { help: { "hello" => "says hello" } }, &proc(&method(:dummy_method)))
75
75
  assert_equal ["hello - says hello"], matcher_with_help.help
76
76
  end
77
-
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(&method(:error_method)))
81
- assert matcher_with_error.attempt(msg).match("'error' found, but raised")
82
- end
83
77
  end
84
78
 
85
79
  def dummy_method(_, match_data)
86
80
  "Hello #{match_data['name']}"
87
81
  end
88
-
89
- def error_method(*)
90
- foobarcall
91
- end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cognition
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.5
4
+ version: 2.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Anderson