turd 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/turd/tcp.rb +20 -3
  2. data/lib/turd/version.rb +2 -2
  3. metadata +2 -2
data/lib/turd/tcp.rb CHANGED
@@ -4,19 +4,36 @@ module Turd
4
4
  def self.connect(request_definition)
5
5
 
6
6
  response = String.new
7
- before = Time.now.to_f
7
+ read_after = nil
8
+ read_before = nil
8
9
 
9
10
  begin
11
+ total_before = Time.now.to_f
12
+
10
13
  TCPSocket.open(request_definition[:options][:host], request_definition[:options][:port]) do |socket|
14
+ read_before = Time.now.to_f
11
15
  response = socket.gets
16
+ read_after = Time.now.to_f
12
17
  end
18
+
19
+ total_after = Time.now.to_f
13
20
  rescue Errno::ETIMEDOUT
14
21
  # timeout
22
+ ensure
23
+ total_after = Time.now.to_f
15
24
  end
16
25
 
17
- after = Time.now.to_f
26
+ if read_after && read_before
27
+ read_time = read_after - read_before
28
+ else
29
+ read_time = nil
30
+ end
18
31
 
19
- {:response => response, :total_time => after - before}
32
+ {
33
+ :response => response,
34
+ :total_time => total_after - total_before,
35
+ :read_time => read_time
36
+ }
20
37
 
21
38
  end
22
39
 
data/lib/turd/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Turd
2
- VERSION = "0.0.1"
3
- end
2
+ VERSION = "0.0.2"
3
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-01-15 00:00:00.000000000 Z
12
+ date: 2014-01-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: typhoeus