pork_sandwich 0.4.20 → 0.4.21

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.20
1
+ 0.4.21
@@ -2,11 +2,21 @@ module Pork
2
2
  class Puller
3
3
  attr_accessor :auth_object
4
4
 
5
+ def self.rate_check
6
+ rate_hash = JSON.parse(Net::HTTP.get(URI.parse("http://twitter.com/account/rate_limit_status.json")))
7
+ if rate_hash["remaining_hits"] == 0
8
+ $PORK_LOG.write("You've hit your rate limit, sleeping for 2 mins then checking the rate limit again. Should reset at #{rate_hash['reset_time']}") if $PORK_LOG
9
+ sleep 120
10
+ Pork::Puller.rate_check
11
+ end
12
+ end
13
+
5
14
  def initialize(auth_object = nil)
6
15
  @auth_object = auth_object ? auth_object.auth : auth_object
7
16
  end
8
17
 
9
18
  def pull(user_object, &pull_type)
19
+ Pork::Puller.rate_check
10
20
  @user = user_object
11
21
  begin
12
22
  pull_type.call(@user, @auth_object)
data/test/fakewebs.rb CHANGED
@@ -6,6 +6,9 @@ auth_and_no_auth = [http_auth_string, ""]
6
6
 
7
7
  FakeWeb.allow_net_connect = false
8
8
 
9
+
10
+ FakeWeb.register_uri(:any, "http://twitter.com/account/rate_limit_status.json", :body => "{\"reset_time\":\"Thu May 27 03:27:00 +0000 2010\",\"remaining_hits\":9001,\"hourly_limit\":150,\"reset_time_in_seconds\":1274930820}")
11
+
9
12
  # SEARCH METHOD
10
13
  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":"<a href="http://twitter.com/">web</a>"},{"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":"<a href="http://help.twitter.com/index.php?pg=kb.page&id=75" rel="nofollow">txt</a>"}],"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
14
 
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pork_sandwich
3
3
  version: !ruby/object:Gem::Version
4
- hash: 39
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 4
9
- - 20
10
- version: 0.4.20
8
+ - 21
9
+ version: 0.4.21
11
10
  platform: ruby
12
11
  authors:
13
12
  - Sam Gilbert
@@ -16,18 +15,16 @@ autorequire:
16
15
  bindir: bin
17
16
  cert_chain: []
18
17
 
19
- date: 2010-05-23 00:00:00 -04:00
18
+ date: 2010-05-26 00:00:00 -04:00
20
19
  default_executable:
21
20
  dependencies:
22
21
  - !ruby/object:Gem::Dependency
23
22
  name: acts-as-taggable-on
24
23
  prerelease: false
25
24
  requirement: &id001 !ruby/object:Gem::Requirement
26
- none: false
27
25
  requirements:
28
26
  - - ">="
29
27
  - !ruby/object:Gem::Version
30
- hash: 15
31
28
  segments:
32
29
  - 1
33
30
  - 0
@@ -39,11 +36,9 @@ dependencies:
39
36
  name: twitter
40
37
  prerelease: false
41
38
  requirement: &id002 !ruby/object:Gem::Requirement
42
- none: false
43
39
  requirements:
44
40
  - - ">="
45
41
  - !ruby/object:Gem::Version
46
- hash: 17
47
42
  segments:
48
43
  - 0
49
44
  - 7
@@ -81,18 +76,6 @@ files:
81
76
  - lib/pork_sandwich/saver.rb
82
77
  - lib/pork_sandwich/search.rb
83
78
  - lib/pork_sandwich/twitter_user.rb
84
- - test/auth_test.rb
85
- - test/crawler_test.rb
86
- - test/factories.rb
87
- - test/fakewebs.rb
88
- - test/log_test.rb
89
- - test/puller_test.rb
90
- - test/reaction_processor_test.rb
91
- - test/saver_test.rb
92
- - test/schema.rb
93
- - test/search_test.rb
94
- - test/test_helper.rb
95
- - test/twitter_user_test.rb
96
79
  has_rdoc: true
97
80
  homepage: http://github.com/sam1vp/pork_sandwich
98
81
  licenses: []
@@ -103,27 +86,23 @@ rdoc_options:
103
86
  require_paths:
104
87
  - lib
105
88
  required_ruby_version: !ruby/object:Gem::Requirement
106
- none: false
107
89
  requirements:
108
90
  - - ">="
109
91
  - !ruby/object:Gem::Version
110
- hash: 3
111
92
  segments:
112
93
  - 0
113
94
  version: "0"
114
95
  required_rubygems_version: !ruby/object:Gem::Requirement
115
- none: false
116
96
  requirements:
117
97
  - - ">="
118
98
  - !ruby/object:Gem::Version
119
- hash: 3
120
99
  segments:
121
100
  - 0
122
101
  version: "0"
123
102
  requirements: []
124
103
 
125
104
  rubyforge_project:
126
- rubygems_version: 1.3.7
105
+ rubygems_version: 1.3.6
127
106
  signing_key:
128
107
  specification_version: 3
129
108
  summary: A tool for pulling and storing delicious, delicious Twitter data