pork_sandwich 0.4.11 → 0.4.12

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.11
1
+ 0.4.12
@@ -6,10 +6,11 @@ module Pork
6
6
  @query = query
7
7
  @desired_count = options[:desired_count] #if nil, will pull as far back as the Search API allows
8
8
  @current_count = 0
9
+ @since_id = options[:since_id]
9
10
  @from_user = options[:from_user]
10
11
  @db_ids_created = []
11
12
  @collect_users = options[:collect_users]
12
- @pulls_per_hour = options[:pulls_per_hour]? options[:pulls_per_hour] : 1500
13
+ @pulls_per_hour = options[:pulls_per_hour]? options[:pulls_per_hour] : 2000
13
14
  end
14
15
 
15
16
  def historical_pull
@@ -35,12 +36,14 @@ module Pork
35
36
  break
36
37
  end
37
38
  end
38
-
39
39
  if reached_desired_count? or @search_params.query[:max_id] == @tweets_pulled.last.id
40
40
  break
41
41
  else
42
42
  @search_params.query[:max_id] = @tweets_pulled.last.id
43
43
  end
44
+ if reached_since_id?
45
+ break
46
+ end
44
47
  manage_pull_rate(time_at_start)
45
48
  end
46
49
  rescue Twitter::Unavailable
@@ -109,5 +112,13 @@ module Pork
109
112
  end
110
113
  end
111
114
 
115
+ def reached_since_id?
116
+ if @since_id
117
+ return @search_params.query[:max_id] <= @since_id
118
+ else
119
+ return false
120
+ end
121
+ end
122
+
112
123
  end
113
124
  end
data/test/fakewebs.rb CHANGED
@@ -7,7 +7,7 @@ FakeWeb.allow_net_connect = false
7
7
  # SEARCH METHOD
8
8
  FakeWeb.register_uri(:any, "http://search.twitter.com/search.json?rpp=100&q=test", :body => '{"results":[{"profile_image_url":"http://a3.twimg.com/profile_images/521281029/DSC01483_-_Kopia_-_Kopia_normal.JPG","created_at":"Wed, 11 Nov 2009 17:52:11 +0000","from_user":"SamIsMarth","to_user_id":10186853,"text":"@sage2526 cool. I have to study to my german test... Have a nice evening ^^","id":5624810553,"from_user_id":72123474,"to_user":"sage2526","geo":null,"iso_language_code":"en","source":"&lt;a href=&quot;http://twitter.com/&quot;&gt;web&lt;/a&gt;"},{"profile_image_url":"http://a3.twimg.com/profile_images/56115537/Andrew_-_small_normal.jpg","created_at":"Wed, 11 Nov 2009 17:52:09 +0000","from_user":"MarthIsGreat","to_user_id":null,"text":"Gearing up yo fail this calculus III test. Wish me luck!","id":5624809937,"from_user_id":842449,"geo":null,"iso_language_code":"en","source":"&lt;a href=&quot;http://help.twitter.com/index.php?pg=kb.page&amp;id=75&quot; rel=&quot;nofollow&quot;&gt;txt&lt;/a&gt;"}],"max_id":5624810553,"since_id":0,"refresh_url":"?since_id=5624810553&q=test","next_page":"?page=2&max_id=5624810553&q=test","results_per_page":15,"page":1,"completed_in":0.040758,"query":"test"}')
9
9
 
10
- FakeWeb.register_uri(:any, "http://search.twitter.com/search.json?max_id=5624809937&rpp=100&q=test", :body => '{"results":[{"profile_image_url":"http://a3.twimg.com/profile_images/521281029/DSC01483_-_Kopia_-_Kopia_normal.JPG","created_at":"Wed, 11 Nov 2009 17:52:11 +0000","from_user":"EvanIsLucas","to_user_id":10186853,"text":"@sage2526 cool. I have to study to my german test... Have a nice evening ^^","id":5624810553,"from_user_id":72123474,"to_user":"sage2526","geo":null,"iso_language_code":"en","source":"&lt;a href=&quot;http://twitter.com/&quot;&gt;web&lt;/a&gt;"},{"profile_image_url":"http://a3.twimg.com/profile_images/56115537/Andrew_-_small_normal.jpg","created_at":"Wed, 11 Nov 2009 17:52:09 +0000","from_user":"LucasIsCheap","to_user_id":null,"text":"Gearing up yo fail this calculus III test. Wish me luck!","id":5555,"from_user_id":842449,"geo":null,"iso_language_code":"en","source":"&lt;a href=&quot;http://help.twitter.com/index.php?pg=kb.page&amp;id=75&quot; rel=&quot;nofollow&quot;&gt;txt&lt;/a&gt;"}],"max_id":5624810553,"since_id":0,"refresh_url":"?since_id=5624810553&q=test","next_page":"?page=2&max_id=5624810553&q=test","results_per_page":15,"page":1,"completed_in":0.040758,"query":"test"}')
10
+ FakeWeb.register_uri(:any, "http://search.twitter.com/search.json?max_id=5624809937&rpp=100&q=test", :body => '{"results":[{"profile_image_url":"http://a3.twimg.com/profile_images/521281029/DSC01483_-_Kopia_-_Kopia_normal.JPG","created_at":"Wed, 11 Nov 2009 17:52:11 +0000","from_user":"EvanIsLucas","to_user_id":10186853,"text":"@sage2526 cool. I have to study to my german test... Have a nice evening ^^","id":1234567,"from_user_id":72123474,"to_user":"sage2526","geo":null,"iso_language_code":"en","source":"&lt;a href=&quot;http://twitter.com/&quot;&gt;web&lt;/a&gt;"},{"profile_image_url":"http://a3.twimg.com/profile_images/56115537/Andrew_-_small_normal.jpg","created_at":"Wed, 11 Nov 2009 17:52:09 +0000","from_user":"LucasIsCheap","to_user_id":null,"text":"Gearing up yo fail this calculus III test. Wish me luck!","id":5555,"from_user_id":842449,"geo":null,"iso_language_code":"en","source":"&lt;a href=&quot;http://help.twitter.com/index.php?pg=kb.page&amp;id=75&quot; rel=&quot;nofollow&quot;&gt;txt&lt;/a&gt;"}],"max_id":5624810553,"since_id":0,"refresh_url":"?since_id=5624810553&q=test","next_page":"?page=2&max_id=5624810553&q=test","results_per_page":15,"page":1,"completed_in":0.040758,"query":"test"}')
11
11
 
12
12
  FakeWeb.register_uri(:any, "http://search.twitter.com/search.json?max_id=5555&rpp=100&q=test", :body => '{"results":[{"profile_image_url":"http://a3.twimg.com/profile_images/56115537/Andrew_-_small_normal.jpg","created_at":"Wed, 11 Nov 2009 17:52:09 +0000","from_user":"LucasIsCheap","to_user_id":null,"text":"Gearing up yo fail this calculus III test. Wish me luck!","id":5555,"from_user_id":842449,"geo":null,"iso_language_code":"en","source":"&lt;a href=&quot;http://help.twitter.com/index.php?pg=kb.page&amp;id=75&quot; rel=&quot;nofollow&quot;&gt;txt&lt;/a&gt;"}],"max_id":5624810553,"since_id":0,"refresh_url":"?since_id=5624810553&q=test","next_page":"?page=2&max_id=5624810553&q=test","results_per_page":15,"page":1,"completed_in":0.040758,"query":"test"}')
13
13
 
data/test/search_test.rb CHANGED
@@ -44,7 +44,16 @@ class SearchTest < Test::Unit::TestCase
44
44
  assert_equal 4, @search.current_count
45
45
  end
46
46
  end
47
-
47
+ context "and since_id = 5624809937" do
48
+ setup do
49
+ @search = Pork::Search.new('test', {:since_id => 5624809937})
50
+ end
51
+ should "be able to do an historical pull for only 2 tweets (because the second tweet id will = 5624809937)" do
52
+ result = @search.historical_pull
53
+ assert_equal true, result
54
+ assert_equal 2, @search.current_count
55
+ end
56
+ end
48
57
  end
49
58
 
50
59
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pork_sandwich
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.11
4
+ version: 0.4.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Gilbert
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2010-02-17 00:00:00 -05:00
13
+ date: 2010-03-07 00:00:00 -05:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency