http_logger 0.3.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.3
1
+ 0.4.0
data/http_logger.gemspec CHANGED
@@ -4,14 +4,14 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{http_logger}
8
- s.version = "0.3.3"
7
+ s.name = "http_logger"
8
+ s.version = "0.4.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Bogdan Gusiev"]
12
- s.date = %q{2013-02-15}
13
- s.description = %q{This gem keep an eye on every Net::HTTP library usage and dump all request and response data to the log file}
14
- s.email = %q{agresso@gmail.com}
12
+ s.date = "2013-04-04"
13
+ s.description = "This gem keep an eye on every Net::HTTP library usage and dump all request and response data to the log file"
14
+ s.email = "agresso@gmail.com"
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE.txt"
17
17
  ]
@@ -32,11 +32,11 @@ Gem::Specification.new do |s|
32
32
  "spec/http_logger_spec.rb",
33
33
  "spec/spec_helper.rb"
34
34
  ]
35
- s.homepage = %q{http://github.com/bogdan/http_logger}
35
+ s.homepage = "http://github.com/bogdan/http_logger"
36
36
  s.licenses = ["MIT"]
37
37
  s.require_paths = ["lib"]
38
- s.rubygems_version = %q{1.6.0}
39
- s.summary = %q{Log your http api calls just like SQL queries}
38
+ s.rubygems_version = "1.8.24"
39
+ s.summary = "Log your http api calls just like SQL queries"
40
40
 
41
41
  if s.respond_to? :specification_version then
42
42
  s.specification_version = 3
data/lib/http_logger.rb CHANGED
@@ -50,7 +50,7 @@ class HttpLogger
50
50
  ensure
51
51
  if require_logging?(http, request)
52
52
  log_request_url(http, request, start_time)
53
- log_post_put_params(request)
53
+ log_request_body(request)
54
54
  log_request_headers(request)
55
55
  if defined?(response) && response
56
56
  log_response_code(response)
@@ -74,10 +74,13 @@ class HttpLogger
74
74
  end
75
75
  end
76
76
 
77
- def log_post_put_params(request)
78
- body = request.body
79
- if body && !body.empty? && (request.is_a?(::Net::HTTP::Post) || request.is_a?(::Net::HTTP::Put))
80
- log("Request body", truncate_body(body))
77
+ HTTP_METHODS_WITH_BODY = %w(POST PUT)
78
+
79
+ def log_request_body(request)
80
+ if HTTP_METHODS_WITH_BODY.include?(request.method)
81
+ if (body = request.body) && !body.empty?
82
+ log("Request body", truncate_body(body))
83
+ end
81
84
  end
82
85
  end
83
86
 
@@ -81,6 +81,18 @@ describe HttpLogger do
81
81
  it {should include("Request body")}
82
82
  it {should include("a=hello&b=1")}
83
83
  end
84
+
85
+ describe "generic request" do
86
+ let(:request) do
87
+ http = Net::HTTP.new(uri.host, uri.port)
88
+ request = Net::HTTPGenericRequest.new('PUT', true, true, uri.path)
89
+ request.body = "a=hello&b=1"
90
+ http.request(request)
91
+ end
92
+
93
+ it {should include("Request body")}
94
+ it {should include("a=hello&b=1")}
95
+ end
84
96
 
85
97
  context "with long response body" do
86
98
 
metadata CHANGED
@@ -1,102 +1,104 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: http_logger
3
- version: !ruby/object:Gem::Version
4
- hash: 21
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.0
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 3
9
- - 3
10
- version: 0.3.3
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Bogdan Gusiev
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2013-02-15 00:00:00 +02:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- requirement: &id001 !ruby/object:Gem::Requirement
23
- none: false
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- hash: 3
28
- segments:
29
- - 0
30
- version: "0"
31
- version_requirements: *id001
32
- prerelease: false
12
+ date: 2013-04-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
33
15
  name: debugger
34
- type: :development
35
- - !ruby/object:Gem::Dependency
36
- requirement: &id002 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
37
17
  none: false
38
- requirements:
39
- - - ">="
40
- - !ruby/object:Gem::Version
41
- hash: 3
42
- segments:
43
- - 0
44
- version: "0"
45
- version_requirements: *id002
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
46
23
  prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
47
31
  name: rspec
48
- type: :development
49
- - !ruby/object:Gem::Dependency
50
- requirement: &id003 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
51
33
  none: false
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- hash: 3
56
- segments:
57
- - 0
58
- version: "0"
59
- version_requirements: *id003
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
60
39
  prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
61
47
  name: bundler
62
- type: :development
63
- - !ruby/object:Gem::Dependency
64
- requirement: &id004 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
65
49
  none: false
66
- requirements:
67
- - - ">="
68
- - !ruby/object:Gem::Version
69
- hash: 3
70
- segments:
71
- - 0
72
- version: "0"
73
- version_requirements: *id004
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
74
55
  prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
75
63
  name: jeweler
76
- type: :development
77
- - !ruby/object:Gem::Dependency
78
- requirement: &id005 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
79
65
  none: false
80
- requirements:
81
- - - ">="
82
- - !ruby/object:Gem::Version
83
- hash: 3
84
- segments:
85
- - 0
86
- version: "0"
87
- version_requirements: *id005
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
88
71
  prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
89
79
  name: fakeweb
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
90
86
  type: :development
91
- description: This gem keep an eye on every Net::HTTP library usage and dump all request and response data to the log file
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ description: This gem keep an eye on every Net::HTTP library usage and dump all request
95
+ and response data to the log file
92
96
  email: agresso@gmail.com
93
97
  executables: []
94
-
95
98
  extensions: []
96
-
97
- extra_rdoc_files:
99
+ extra_rdoc_files:
98
100
  - LICENSE.txt
99
- files:
101
+ files:
100
102
  - .document
101
103
  - .rspec
102
104
  - Gemfile
@@ -112,39 +114,32 @@ files:
112
114
  - screenshots/solr.png
113
115
  - spec/http_logger_spec.rb
114
116
  - spec/spec_helper.rb
115
- has_rdoc: true
116
117
  homepage: http://github.com/bogdan/http_logger
117
- licenses:
118
+ licenses:
118
119
  - MIT
119
120
  post_install_message:
120
121
  rdoc_options: []
121
-
122
- require_paths:
122
+ require_paths:
123
123
  - lib
124
- required_ruby_version: !ruby/object:Gem::Requirement
124
+ required_ruby_version: !ruby/object:Gem::Requirement
125
125
  none: false
126
- requirements:
127
- - - ">="
128
- - !ruby/object:Gem::Version
129
- hash: 3
130
- segments:
126
+ requirements:
127
+ - - ! '>='
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ segments:
131
131
  - 0
132
- version: "0"
133
- required_rubygems_version: !ruby/object:Gem::Requirement
132
+ hash: -703015497783521019
133
+ required_rubygems_version: !ruby/object:Gem::Requirement
134
134
  none: false
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- hash: 3
139
- segments:
140
- - 0
141
- version: "0"
135
+ requirements:
136
+ - - ! '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
142
139
  requirements: []
143
-
144
140
  rubyforge_project:
145
- rubygems_version: 1.6.0
141
+ rubygems_version: 1.8.24
146
142
  signing_key:
147
143
  specification_version: 3
148
144
  summary: Log your http api calls just like SQL queries
149
145
  test_files: []
150
-