net_http_wrapper 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1ba9d676fb9ac9e647a7dfe07c7af79e9259d20db79a3de283cedcb71b773786
4
- data.tar.gz: 5c20e8bb7508fa43fa5fcd86cc052e08aab666da25a3f74d07965ef14c481571
3
+ metadata.gz: ec50d6555247ccad87dfb3ccea2571b4c6a0ede0baa2e11cf36c918b531ecae9
4
+ data.tar.gz: 12413b51b0e4d0dfb2753ca2d0a60d24be76395201f90794ed2db4d29f8bc6fe
5
5
  SHA512:
6
- metadata.gz: aa524bd45bb786f56c581423e82d30a9553242bbe71a5e1e0a7536ca0b20a2fbf1ecac7322e86905f0cb7d6378b9728fa6c71694b3b5cee0b5c9009aecb92353
7
- data.tar.gz: 7ffcfe898f9e9c29b7077e560eef0e3b08425e3d5ddda261916eb9993e8c27a7bea9f8519caeb6f0c418aba8d07cebd4a5146b598cbfa28bbbd2ee5e9279ad24
6
+ metadata.gz: bf5f90bd01cf9a04ce0c9c705318a6adfaf0cb7d40f1ba4654c249bf4ffa4b25ecf84c6ca84c0f6ad0d0cc023c1ac199376bf45771c42970eb34a2bf550fdb34
7
+ data.tar.gz: 11fb7277b1657dae14c8a77fe7123cef74db7a042bd4e10892a78b886b4e5b06590ceab34fe486c0ae0284bb788a08750f860cd88d79df8a1e32c0276f0e650d
@@ -1,4 +1,9 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.3
3
+
1
4
  Metrics/LineLength:
2
5
  Max: 100
3
6
  Metrics/BlockLength:
4
7
  Enabled: false
8
+ Style/FrozenStringLiteralComment:
9
+ Enabled: false
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- net_http_wrapper (0.0.2)
4
+ net_http_wrapper (0.0.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -42,6 +42,8 @@ GEM
42
42
  rainbow (>= 2.2.2, < 4.0)
43
43
  ruby-progressbar (~> 1.7)
44
44
  unicode-display_width (~> 1.4.0)
45
+ rubocop-rspec (1.32.0)
46
+ rubocop (>= 0.60.0)
45
47
  ruby-progressbar (1.10.0)
46
48
  safe_yaml (1.0.4)
47
49
  unicode-display_width (1.4.1)
@@ -59,6 +61,7 @@ DEPENDENCIES
59
61
  rake (~> 10.0)
60
62
  rspec (~> 3.0)
61
63
  rubocop
64
+ rubocop-rspec
62
65
  webmock (~> 3.5.1)
63
66
 
64
67
  BUNDLED WITH
@@ -0,0 +1,15 @@
1
+ # Version 0.0.3
2
+ Release date: 2019-02-13
3
+
4
+ ### Fixed
5
+
6
+ * Added license and changelog files.
7
+ * Specified supported ruby version in gemspec.
8
+ * Run rubocop with rake by default.
9
+
10
+ # Version 0.0.1
11
+ Release date: 2019-02-13
12
+
13
+ ### Added
14
+
15
+ * First release.
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2019 Dima Samodurov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ 'Software'), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -48,7 +48,7 @@ NetHttpWrapper.enable
48
48
  NetHttpWrapper.after_request do |http:, request:, response:, start_time:|
49
49
  request_duration = (Time.now - start_time).round(3)
50
50
  request_url =
51
- URI.decode("http#{"s" if http.use_ssl?}://#{http.address}:#{http.port}#{request.path}")
51
+ "http#{"s" if http.use_ssl?}://#{http.address}:#{http.port}#{request.path}"
52
52
 
53
53
  Rails.logger.info(name: 'http_request',
54
54
  method: request.method,
@@ -61,8 +61,12 @@ end
61
61
  ## Development
62
62
 
63
63
  After checking out the repo, run `bin/setup` to install dependencies.
64
- Then, run `rake spec` to run the tests, and run `rubocop` to check code style.
65
- You can also run `bin/console` for an interactive prompt that will allow you to experiment.
64
+ Then, run `rake` to run the code style check and the tests.
65
+ You can also run `bundle exec bin/console` for an interactive prompt that will allow you to experiment.
66
+
67
+ You can also see example in action running
68
+ `bundle exec ruby examples/log_to_stdout.rb`
69
+
66
70
 
67
71
  To install this gem onto your local machine, run `bundle exec rake install`.
68
72
  To release a new version, update the version number in `version.rb`,
data/Rakefile CHANGED
@@ -1,6 +1,12 @@
1
1
  require 'bundler/gem_tasks'
2
2
  require 'rspec/core/rake_task'
3
+ require 'rubocop/rake_task'
3
4
 
4
5
  RSpec::Core::RakeTask.new(:spec)
5
6
 
6
- task default: :spec
7
+ desc 'Run rubocop'
8
+ task :rubocop do
9
+ RuboCop::RakeTask.new
10
+ end
11
+
12
+ task default: %i[rubocop spec]
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
-
3
2
  require 'bundler/setup'
4
3
  require 'net_http_wrapper'
5
4
 
@@ -0,0 +1,16 @@
1
+ require 'net/http'
2
+ require 'net_http_wrapper'
3
+
4
+ NetHttpWrapper.after_request do |http:, request:, response:, start_time:|
5
+ request_duration = (Time.now - start_time).round(3)
6
+ request_url =
7
+ "http#{'s' if http.use_ssl?}://#{http.address}:#{http.port}#{request.path}"
8
+
9
+ puts(url: request_url, status: response.code, duration: request_duration)
10
+ end
11
+ NetHttpWrapper.enable
12
+
13
+ Net::HTTP.get('example.com', '/')
14
+
15
+ # Expected output looks like below:
16
+ # {:url=>"http://example.com:80/", :status=>"200", :duration=>0.129}
@@ -31,7 +31,14 @@ module NetHttpWrapper
31
31
  #
32
32
  # Example:
33
33
  # NetHttpWrapper.after_request do |http:, request:, response:, start_time:|
34
- # # e.g. log request duration
34
+ # request_duration = (Time.now - start_time).round(3)
35
+ # request_url =
36
+ # URI.decode("http#{"s" if http.use_ssl?}://#{http.address}:#{http.port}#{request.path}")
37
+ #
38
+ # Rails.logger.info(method: request.method,
39
+ # url: request_url,
40
+ # status: response.code,
41
+ # duration: request_duration)
35
42
  # end
36
43
  def after_request(&block)
37
44
  after_request_callbacks << block
@@ -1,3 +1,3 @@
1
1
  module NetHttpWrapper
2
- VERSION = '0.0.2'.freeze
2
+ VERSION = '0.0.3'.freeze
3
3
  end
@@ -12,6 +12,9 @@ Gem::Specification.new do |spec|
12
12
  spec.description = 'Wraps Net::HTTP requests e.g. for logging purposes.'
13
13
  spec.homepage = 'https://github.com/dimasamodurov/net_http_wrapper'
14
14
 
15
+ spec.required_ruby_version = '>= 2.3.0'
16
+ spec.license = 'MIT'
17
+
15
18
  # Specify which files should be added to the gem when it is released.
16
19
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
17
20
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
@@ -24,6 +27,7 @@ Gem::Specification.new do |spec|
24
27
  spec.add_development_dependency 'bundler', '~> 2.0'
25
28
  spec.add_development_dependency 'rake', '~> 10.0'
26
29
  spec.add_development_dependency 'rspec', '~> 3.0'
27
- spec.add_development_dependency 'webmock', '~> 3.5.1'
28
30
  spec.add_development_dependency 'rubocop'
31
+ spec.add_development_dependency 'rubocop-rspec'
32
+ spec.add_development_dependency 'webmock', '~> 3.5.1'
29
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: net_http_wrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmytro Samodurov
@@ -53,21 +53,21 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: webmock
56
+ name: rubocop
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: 3.5.1
61
+ version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: 3.5.1
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: rubocop
70
+ name: rubocop-rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: webmock
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 3.5.1
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 3.5.1
83
97
  description: Wraps Net::HTTP requests e.g. for logging purposes.
84
98
  email:
85
99
  - dimasamodurov@gmail.com
@@ -95,15 +109,19 @@ files:
95
109
  - ".travis.yml"
96
110
  - Gemfile
97
111
  - Gemfile.lock
112
+ - History.md
113
+ - License.txt
98
114
  - README.md
99
115
  - Rakefile
100
116
  - bin/console
101
117
  - bin/setup
118
+ - examples/log_to_stdout.rb
102
119
  - lib/net_http_wrapper.rb
103
120
  - lib/net_http_wrapper/version.rb
104
121
  - net_http_wrapper.gemspec
105
122
  homepage: https://github.com/dimasamodurov/net_http_wrapper
106
- licenses: []
123
+ licenses:
124
+ - MIT
107
125
  metadata: {}
108
126
  post_install_message:
109
127
  rdoc_options: []
@@ -113,7 +131,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
113
131
  requirements:
114
132
  - - ">="
115
133
  - !ruby/object:Gem::Version
116
- version: '0'
134
+ version: 2.3.0
117
135
  required_rubygems_version: !ruby/object:Gem::Requirement
118
136
  requirements:
119
137
  - - ">="