onlyoffice_bugzilla_helper 0.5.0 → 0.6.0

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: 7ff70cf1f92d58b5ee3fde49f516e53be60ad0f1589cae8624c5c8dc80efeb7c
4
- data.tar.gz: ae5a6db51a4e414a0c23e997084763c47052b2494ad4ba6fb8848a6494133bd4
3
+ metadata.gz: c2c0df09ea18bbe7bd0b3e564c373bd2d489bc46aa782905b8bacf6664126add
4
+ data.tar.gz: e178efeb2a1fd38b49db763eeb41292dfccbf8836b206779c48bac485f0c5c4d
5
5
  SHA512:
6
- metadata.gz: a959f75ef11abab71e6f82bc15e9307ceb46c7bbdc6befd18ef12b2869d4000adcb100577bf9b36c514fb683d6e06533d2cb5addad015955063cef16fa56a8c5
7
- data.tar.gz: '018bd6c8e66fc1b4930f001a32d024adad5dc4e16c38bef9197bd27098caba20b2707dbcbc7d549f82f466338b099a58ce124e9dba9090bcbdc5784b8ea499b0'
6
+ metadata.gz: 700fc2d2050f00db7f1bacc9524067bcaf9225eef0de1ca81345fc4c4d11cbd8ff63ef5cad5cb9efba1faf2ea56e599ac50f08f29f65ba31dbf71459841c6af4
7
+ data.tar.gz: 333a43b5c73e213162e21460b9acedbc1e8d38b72a1c904701bd28de578394bfc0d5c9a731451df4dfd68dd2eaa891c2d9818886b9f976752a4bead969dc614e
@@ -6,6 +6,7 @@ require 'net/http'
6
6
  require 'uri'
7
7
  require 'onlyoffice_bugzilla_helper/bug_data'
8
8
  require 'onlyoffice_bugzilla_helper/comments'
9
+ require 'onlyoffice_bugzilla_helper/logger_wrapper'
9
10
  require 'onlyoffice_bugzilla_helper/networking'
10
11
  require 'onlyoffice_bugzilla_helper/update_bug'
11
12
  require 'onlyoffice_bugzilla_helper/version'
@@ -16,6 +17,7 @@ module OnlyofficeBugzillaHelper
16
17
  class BugzillaHelper
17
18
  include BugData
18
19
  include Comments
20
+ include LoggerWrapper
19
21
  include Networking
20
22
  include UpdateBug
21
23
  attr_reader :url
@@ -70,9 +72,8 @@ module OnlyofficeBugzillaHelper
70
72
  # @param bug_id [Integer] id of bug
71
73
  # @return [Net::HTTPResponse] result of request
72
74
  def get_bug_result(bug_id)
73
- Net::HTTP.start(@url.host, @url.port, use_ssl: use_ssl?) do |http|
74
- http.get(bug_url(bug_id))
75
- end
75
+ req = Net::HTTP::Get.new(bug_url(bug_id))
76
+ perform_request(req)
76
77
  end
77
78
  end
78
79
  end
@@ -18,9 +18,7 @@ module OnlyofficeBugzillaHelper
18
18
  req = Net::HTTP::Post.new(bug_url(bug_id, '/comment'))
19
19
  req.body = { comment: comment }.to_json
20
20
  req.add_field('Content-Type', 'text/plain')
21
- connection = Net::HTTP.new(@url.host, @url.port)
22
- connection.use_ssl = use_ssl?
23
- connection.start { |http| http.request(req) }
21
+ perform_request(req)
24
22
  end
25
23
  end
26
24
  end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'logger'
4
+
5
+ module OnlyofficeBugzillaHelper
6
+ # Logger module for logging stuff
7
+ module LoggerWrapper
8
+ # @return [Logger] default logger
9
+ def logger
10
+ @logger ||= Logger.new($stdout)
11
+ end
12
+
13
+ # Log info about request
14
+ # @param [Net:HTTP] request to make
15
+ # @param [Net:HTTP] response in result
16
+ # @return [nil]
17
+ def log_request(request, response)
18
+ logger.info('Made request. '\
19
+ "Type: #{request.method}. "\
20
+ "Path: #{hide_keys(request.path)}. "\
21
+ "Body: #{hide_keys(request.body)}. "\
22
+ "Response: #{hide_keys(response.body)}")
23
+ end
24
+
25
+ # Hide sensitive info
26
+ # @param [String] string to hide
27
+ # @return [String] result
28
+ def hide_keys(string)
29
+ string&.gsub(@key, '[REMOVED]')
30
+ end
31
+ end
32
+ end
@@ -9,5 +9,16 @@ module OnlyofficeBugzillaHelper
9
9
  def use_ssl?
10
10
  @url.scheme == 'https'
11
11
  end
12
+
13
+ # Perform request for current bugzilla
14
+ # @param [Net:HTTP] request to make
15
+ # @return [Net:HTTPResponse] result of request
16
+ def perform_request(request)
17
+ connection = Net::HTTP.new(@url.host, @url.port)
18
+ connection.use_ssl = use_ssl?
19
+ result = connection.start { |http| http.request(request) }
20
+ log_request(request, result)
21
+ result
22
+ end
12
23
  end
13
24
  end
@@ -11,9 +11,7 @@ module OnlyofficeBugzillaHelper
11
11
  req = Net::HTTP::Put.new(bug_url(bug_id))
12
12
  req.body = params.to_json
13
13
  req.add_field('Content-Type', 'text/plain')
14
- connection = Net::HTTP.new(@url.host, @url.port)
15
- connection.use_ssl = use_ssl?
16
- connection.start { |http| http.request(req) }
14
+ perform_request(req)
17
15
  end
18
16
  end
19
17
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module OnlyofficeBugzillaHelper
4
4
  # [String] version of Gem
5
- VERSION = '0.5.0'
5
+ VERSION = '0.6.0'
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onlyoffice_bugzilla_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ONLYOFFICE
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-12-18 00:00:00.000000000 Z
12
+ date: 2021-03-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faker
@@ -161,6 +161,7 @@ files:
161
161
  - lib/onlyoffice_bugzilla_helper.rb
162
162
  - lib/onlyoffice_bugzilla_helper/bug_data.rb
163
163
  - lib/onlyoffice_bugzilla_helper/comments.rb
164
+ - lib/onlyoffice_bugzilla_helper/logger_wrapper.rb
164
165
  - lib/onlyoffice_bugzilla_helper/name.rb
165
166
  - lib/onlyoffice_bugzilla_helper/networking.rb
166
167
  - lib/onlyoffice_bugzilla_helper/update_bug.rb
@@ -189,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
190
  - !ruby/object:Gem::Version
190
191
  version: '0'
191
192
  requirements: []
192
- rubygems_version: 3.1.4
193
+ rubygems_version: 3.2.14
193
194
  signing_key:
194
195
  specification_version: 4
195
196
  summary: Helper for bugzilla