chatterbot 0.2.1 → 0.2.2
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.
- data/examples/dsl_test.rb +2 -3
- data/examples/echoes_bot.rb +1 -0
- data/lib/chatterbot/client.rb +1 -0
- data/lib/chatterbot/config.rb +2 -2
- data/lib/chatterbot/dsl.rb +2 -2
- data/lib/chatterbot/search.rb +2 -2
- data/lib/chatterbot/version.rb +1 -1
- data/spec/config_spec.rb +10 -0
- data/spec/dsl_spec.rb +2 -2
- data/spec/search_spec.rb +22 -3
- metadata +16 -16
data/examples/dsl_test.rb
CHANGED
data/examples/echoes_bot.rb
CHANGED
data/lib/chatterbot/client.rb
CHANGED
data/lib/chatterbot/config.rb
CHANGED
@@ -44,7 +44,7 @@ module Chatterbot
|
|
44
44
|
#
|
45
45
|
# Should we run any config updates?
|
46
46
|
def update_config?
|
47
|
-
config[:dry_run]
|
47
|
+
config.has_key?(:dry_run) ? ! config[:dry_run] : true
|
48
48
|
end
|
49
49
|
|
50
50
|
#
|
@@ -69,7 +69,7 @@ module Chatterbot
|
|
69
69
|
#
|
70
70
|
# return the ID of the most recent tweet pulled up in searches
|
71
71
|
def since_id
|
72
|
-
config[:since_id] ||
|
72
|
+
config[:since_id] || 0
|
73
73
|
end
|
74
74
|
|
75
75
|
#
|
data/lib/chatterbot/dsl.rb
CHANGED
data/lib/chatterbot/search.rb
CHANGED
@@ -5,7 +5,7 @@ module Chatterbot
|
|
5
5
|
module Search
|
6
6
|
|
7
7
|
# internal search code
|
8
|
-
def search(queries, &block)
|
8
|
+
def search(queries, opts = {}, &block)
|
9
9
|
return unless init_client
|
10
10
|
|
11
11
|
debug "check for tweets since #{since_id}"
|
@@ -18,7 +18,7 @@ module Chatterbot
|
|
18
18
|
# search twitter
|
19
19
|
#
|
20
20
|
queries.each { |query|
|
21
|
-
search = client.search(query, default_opts)
|
21
|
+
search = client.search(query, opts.merge(default_opts))
|
22
22
|
update_since_id(search)
|
23
23
|
|
24
24
|
if search != nil
|
data/lib/chatterbot/version.rb
CHANGED
data/spec/config_spec.rb
CHANGED
@@ -26,6 +26,16 @@ describe "Chatterbot::Config" do
|
|
26
26
|
@bot.config[:custom].should == :value
|
27
27
|
end
|
28
28
|
|
29
|
+
it "update_config? is true by default" do
|
30
|
+
@bot.update_config?.should == true
|
31
|
+
end
|
32
|
+
|
33
|
+
it "update_config? is false if this is a dry run" do
|
34
|
+
@bot.config[:dry_run] = true
|
35
|
+
@bot.update_config?.should == false
|
36
|
+
end
|
37
|
+
|
38
|
+
|
29
39
|
it "returns a log dest" do
|
30
40
|
@bot.should_receive(:load_config).and_return({:log_dest => :bar})
|
31
41
|
@bot.config = nil
|
data/spec/dsl_spec.rb
CHANGED
@@ -45,12 +45,12 @@ describe "Chatterbot::DSL" do
|
|
45
45
|
|
46
46
|
|
47
47
|
it "#search passes along to bot object" do
|
48
|
-
@bot.should_receive(:search).with("foo")
|
48
|
+
@bot.should_receive(:search).with("foo", { })
|
49
49
|
search("foo")
|
50
50
|
end
|
51
51
|
|
52
52
|
it "#search passes along to bot object" do
|
53
|
-
@bot.should_receive(:search).with(["foo","bar"])
|
53
|
+
@bot.should_receive(:search).with(["foo","bar"], { })
|
54
54
|
search(["foo","bar"])
|
55
55
|
end
|
56
56
|
|
data/spec/search_spec.rb
CHANGED
@@ -27,17 +27,36 @@ describe "Chatterbot::Search" do
|
|
27
27
|
#bot = Chatterbot::Bot.new
|
28
28
|
|
29
29
|
bot.stub!(:client).and_return(fake_search(100))
|
30
|
-
bot.client.should_receive(:search).with("foo", {
|
31
|
-
bot.client.should_receive(:search).with("bar", {
|
30
|
+
bot.client.should_receive(:search).with("foo", {})
|
31
|
+
bot.client.should_receive(:search).with("bar", {})
|
32
32
|
|
33
33
|
bot.search(["foo", "bar"])
|
34
34
|
end
|
35
35
|
|
36
|
+
it "accepts extra params" do
|
37
|
+
bot = test_bot
|
38
|
+
|
39
|
+
bot.stub!(:client).and_return(fake_search(100))
|
40
|
+
bot.client.should_receive(:search).with("foo", {:lang => "en"})
|
41
|
+
|
42
|
+
bot.search("foo", :lang => "en")
|
43
|
+
end
|
44
|
+
|
36
45
|
it "accepts a single search query" do
|
37
46
|
bot = test_bot
|
38
47
|
|
39
48
|
bot.stub!(:client).and_return(fake_search(100))
|
40
|
-
bot.client.should_receive(:search).with("foo", {
|
49
|
+
bot.client.should_receive(:search).with("foo", {})
|
50
|
+
|
51
|
+
bot.search("foo")
|
52
|
+
end
|
53
|
+
|
54
|
+
it "passes along since_id" do
|
55
|
+
bot = test_bot
|
56
|
+
bot.stub!(:since_id).and_return(123)
|
57
|
+
|
58
|
+
bot.stub!(:client).and_return(fake_search(100))
|
59
|
+
bot.client.should_receive(:search).with("foo", {:since_id => 123})
|
41
60
|
|
42
61
|
bot.search("foo")
|
43
62
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chatterbot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-05-
|
12
|
+
date: 2011-05-26 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: twitter_oauth
|
16
|
-
requirement: &
|
16
|
+
requirement: &21124680 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *21124680
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: shoulda
|
27
|
-
requirement: &
|
27
|
+
requirement: &21124180 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *21124180
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &21123700 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *21123700
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rdoc
|
49
|
-
requirement: &
|
49
|
+
requirement: &21123220 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *21123220
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: bundler
|
60
|
-
requirement: &
|
60
|
+
requirement: &21122740 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 1.0.0
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *21122740
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rcov
|
71
|
-
requirement: &
|
71
|
+
requirement: &21122260 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *21122260
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: watchr
|
82
|
-
requirement: &
|
82
|
+
requirement: &21121780 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,7 +87,7 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *21121780
|
91
91
|
description: A framework for writing bots that run on Twitter. Comes with a simple
|
92
92
|
DSL for easy coding.
|
93
93
|
email: colin@muffinlabs.com
|