Merge pull request #971 from N-006/patch-2

Make exclude_replies configurable

Andrew Cantino %!s(int64=9) %!d(string=hace) años
padre
commit
b88e20d0a8
Se han modificado 2 ficheros con 10 adiciones y 1 borrados
  1. 8 1
      app/models/agents/twitter_user_agent.rb
  2. 2 0
      spec/models/agents/twitter_user_agent_spec.rb

+ 8 - 1
app/models/agents/twitter_user_agent.rb

@@ -13,6 +13,8 @@ module Agents
13 13
       You must also provide the `username` of the Twitter user to monitor.
14 14
 
15 15
       Set `include_retweets` to `false` to not include retweets (default: `true`)
16
+      
17
+      Set `exclude_replies` to `true` to exclude replies (default: `false`)
16 18
 
17 19
       Set `expected_update_period_in_days` to the maximum amount of time that you'd expect to pass between Events being created by this Agent.
18 20
 
@@ -53,6 +55,7 @@ module Agents
53 55
       {
54 56
         'username' => 'tectonic',
55 57
         'include_retweets' => 'true',
58
+        'exclude_replies' => 'false',
56 59
         'expected_update_period_in_days' => '2'
57 60
       }
58 61
     end
@@ -81,10 +84,14 @@ module Agents
81 84
     def include_retweets?
82 85
       interpolated[:include_retweets] != "false"
83 86
     end
87
+    
88
+    def exclude_replies?
89
+      boolify(interpolated[:exclude_replies]) || false
90
+    end
84 91
 
85 92
     def check
86 93
       since_id = memory['since_id'] || nil
87
-      opts = {:count => 200, :include_rts => include_retweets?, :exclude_replies => false, :include_entities => true, :contributor_details => true}
94
+      opts = {:count => 200, :include_rts => include_retweets?, :exclude_replies => exclude_replies?, :include_entities => true, :contributor_details => true}
88 95
       opts.merge! :since_id => since_id unless since_id.nil?
89 96
 
90 97
       # http://rdoc.info/gems/twitter/Twitter/REST/Timelines#user_timeline-instance_method

+ 2 - 0
spec/models/agents/twitter_user_agent_spec.rb

@@ -7,6 +7,8 @@ describe Agents::TwitterUserAgent do
7 7
 
8 8
     @opts = {
9 9
       :username => "tectonic",
10
+      :include_retweets => "true",
11
+      :exclude_replies => "false",
10 12
       :expected_update_period_in_days => "2",
11 13
       :starting_at => "Jan 01 00:00:01 +0000 2000",
12 14
       :consumer_key => "---",