typhoeus 0.2.4 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,40 +0,0 @@
1
- require File.dirname(__FILE__) + '/../lib/typhoeus.rb'
2
-
3
- hydra = Typhoeus::Hydra.new
4
- hydra.disable_memoization
5
-
6
- urls = [
7
- 'http://google.com',
8
- 'http://testphp.vulnweb.com',
9
- 'http://demo.testfire.net',
10
- 'http://example.net',
11
- ]
12
-
13
- 10.times {
14
- |i|
15
-
16
- req = Typhoeus::Request.new( urls[ i % urls.size] )
17
- req.on_complete {
18
- |res|
19
- puts 'URL: ' + res.effective_url
20
- puts 'Time: ' + res.time.to_s
21
- puts 'Connect time: ' + res.connect_time.to_s
22
- puts 'App connect time: ' + res.app_connect_time.to_s
23
- puts 'Start transfer time: ' + res.start_transfer_time.to_s
24
- puts 'Pre transfer time: ' + res.pretransfer_time.to_s
25
- puts '-------------'
26
- }
27
-
28
- hydra.queue( req )
29
- puts 'Queued: ' + req.url
30
- }
31
-
32
- puts
33
- puts 'Harvesting responses...'
34
- puts
35
-
36
- hydra.run
37
-
38
- puts
39
- puts 'Done.'
40
- puts
@@ -1,21 +0,0 @@
1
- require 'rubygems'
2
- require File.dirname(__FILE__) + '/../lib/typhoeus.rb'
3
- require 'json'
4
-
5
- class Twitter
6
- include Typhoeus
7
- remote_defaults :on_success => lambda {|response| JSON.parse(response.body)},
8
- :on_failure => lambda {|response| puts "error code: #{response.code}"},
9
- :base_uri => "http://search.twitter.com"
10
-
11
- define_remote_method :search, :path => '/search.json'
12
- define_remote_method :trends, :path => '/trends/:time_frame.json'
13
- end
14
-
15
- tweets = Twitter.search(:params => {:q => "railsconf"})
16
- trends = Twitter.trends(:time_frame => :current)
17
-
18
- # and then the calls don't actually happen until the first time you
19
- # call a method on one of the objects returned from the remote_method
20
-
21
- puts tweets.keys # it's a hash from parsed JSON
@@ -1,24 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # go to ext/typhoeus and run ruby extconf.rb && make before running
3
- # this.
4
-
5
- $LOAD_PATH.unshift(File.dirname(__FILE__) + "/../ext")
6
- require File.dirname(__FILE__) + "/../lib/typhoeus"
7
-
8
- klass = Class.new { include Typhoeus }
9
-
10
- loops = ENV['LOOPS'].to_i
11
- url = ARGV.first || (raise "requires URL!")
12
-
13
- loops.times do |i|
14
- puts "On loop #{i}" if i % 10 == 0
15
- results = []
16
- 5.times do
17
- results << klass.get(url)
18
- end
19
-
20
- # fire requests
21
- results[0].code
22
- end
23
-
24
- puts "Ran #{loops} loops on #{url}!"
@@ -1,3 +0,0 @@
1
- --diff
2
- --color
3
- --backtrace