raw_net_capture 0.1.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/raw_net_capture.rb +40 -7
  3. metadata +4 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0fe83e54f2599f248742323990ffd740b0b15fac
4
- data.tar.gz: 77344bd5dd7970d29db25547e5361981d7ce7efd
3
+ metadata.gz: 4f1efc8f70b2f5e320eddfd58cfb298318008694
4
+ data.tar.gz: 25825e1efeaaa5789d73c64b48416f65bb07c000
5
5
  SHA512:
6
- metadata.gz: b99e22ed15f73f934f0ec092fd4b8e5406902e91a8b86be0f9f73dc48a364c90466ace00c8fc61b6f0b46ba300746dba43ed50f97dfd66e83a6415952ae8b963
7
- data.tar.gz: d370eb22ef44f240ae6e65dcc9a0cbddb92ddbf52fd64dee1093f15f39b4678967e0efcba294733d8accef72363016a73a89bd59546356fd1bb02cd93f845a5e
6
+ metadata.gz: 60b7500326a8a3c3f49c7b64a67e25db4fc9733ac81131bd631244ef050eef1a39c5610282841a54ddb1e4eb598f65a1695ed3d0c9450335ea4c2ef73aff674f
7
+ data.tar.gz: f46e16ec6cebede513ce1c2138a962dd0aaa7721a241b989284d104651112b059ead20ff20474d01c92c251ec7e35f47f3169760d7ffac8d53e17aa7d5e57b5a
@@ -1,13 +1,46 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  class RawNetCapture < StringIO
4
- def raw_received
5
- @raw_received ||= StringIO.new
4
+ attr_reader :raw_traffic
5
+
6
+ def initialize
7
+ super
8
+ reset
9
+ end
10
+
11
+ def received(data)
12
+ @raw_traffic << [:received, data]
13
+ end
14
+
15
+ def sent(data)
16
+ @raw_traffic << [:sent, data]
17
+ end
18
+
19
+ def reset
20
+ @raw_traffic = []
21
+ end
22
+ end
23
+
24
+ class RawHTTPCapture < StringIO
25
+ attr_reader :raw_received, :raw_sent
26
+
27
+ def initialize
28
+ super
29
+ reset
30
+ end
31
+
32
+ def reset
33
+ @raw_received = StringIO.new
34
+ @raw_sent = StringIO.new
35
+ end
36
+
37
+ def received(data)
38
+ @raw_received << data
6
39
  end
7
40
 
8
- def raw_sent
9
- @raw_sent ||= StringIO.new
10
- end
41
+ def sent(data)
42
+ @raw_sent << data
43
+ end
11
44
  end
12
45
 
13
46
  module Net
@@ -18,7 +51,7 @@ module Net
18
51
  s = @rbuf.slice!(0, len)
19
52
  if @debug_output
20
53
  @debug_output << %Q[-> #{s.dump}\n]
21
- @debug_output.raw_received << s if @debug_output.is_a?(RawNetCapture)
54
+ @debug_output.received(s) if @debug_output.respond_to?(:received)
22
55
  end
23
56
  s
24
57
  end
@@ -26,7 +59,7 @@ module Net
26
59
  def write0(str)
27
60
  if @debug_output
28
61
  @debug_output << str.dump
29
- @debug_output.raw_sent << str if @debug_output.is_a?(RawNetCapture)
62
+ @debug_output.sent(str) if @debug_output.respond_to?(:sent)
30
63
  end
31
64
  len = @io.write(str)
32
65
  @written_bytes += len
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: raw_net_capture
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gary Grossman
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-12-18 00:00:00.000000000 Z
12
+ date: 2015-01-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: appraisal
@@ -56,12 +56,13 @@ dependencies:
56
56
  description: Adds raw capture capability to Ruby's net debug_output
57
57
  email:
58
58
  - ggrossman@zendesk.com
59
+ - vkmita@zendesk.com
59
60
  executables: []
60
61
  extensions: []
61
62
  extra_rdoc_files: []
62
63
  files:
63
64
  - lib/raw_net_capture.rb
64
- homepage: https://github.com/ggrossman/raw_net_capture
65
+ homepage: https://github.com/zendesk/raw_net_capture
65
66
  licenses:
66
67
  - Apache License Version 2.0
67
68
  metadata: {}