onlyoffice_bugzilla_helper 0.3.0 → 0.6.1

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: 5d94c6dba6d91fc40138e56a201ff3c202d9ba50081e3dc30966573815b372da
4
- data.tar.gz: 359ec64f4c49c1540a5f54f241cb90ff0878f4a97ad6a508df536fec8643bbcc
3
+ metadata.gz: aa8f152f01993c75b41a62070b59aaccc39c56d35487cf29aad32834e2aed432
4
+ data.tar.gz: eef1941b64d912297a1f7c81c1eb4a84d43b93055e347bb221d911f10994a513
5
5
  SHA512:
6
- metadata.gz: 5305b3d016dad39108d2120b474c87680dc67c314cff7f76f388d22cdb4dbd4d13468f3f866c47b08b44d9818014c50f36a0589813c56276eeb2adbed2edfd38
7
- data.tar.gz: 2111a27a55028dcc5290671b3ac24cb229c9dcd7919d49842f2d7c4702ff9d2991e997e0ca2d89af0fbee773cb6a6b6f3134043ddcd4f39bf22d1a54f9b03825
6
+ metadata.gz: e99a3055e61faa6f0892cd8d370becc72472bdb5a54acc0af29e577a7ad4b2f9185eed2c82ffd874e6d2121f340e174d2e509a39417e35a34b085388735a8560
7
+ data.tar.gz: 2d85b5860ad6b30d360b9325a5ac0de9b22fbd2abce74b995b579c0616e04e58a8adc868708e6de5d25b45170dc2f8ed991aae5c9afceaf5d1ef07e6106dfa1b
@@ -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
@@ -32,8 +34,6 @@ module OnlyofficeBugzillaHelper
32
34
  # @param string [String] string for error
33
35
  # @return [Integer, Nil] result of bug id from url
34
36
  def bug_id_from_string(string)
35
- return nil unless string&.match?(URI::DEFAULT_PARSER.make_regexp)
36
-
37
37
  uri = URI.parse(string)
38
38
  return nil unless uri.host == url.host
39
39
  return nil unless uri.path == @show_bug_path
@@ -42,14 +42,19 @@ module OnlyofficeBugzillaHelper
42
42
  return nil if id.zero?
43
43
 
44
44
  id
45
+ rescue URI::InvalidURIError
46
+ nil
45
47
  end
46
48
 
47
49
  # Read access token from file system
50
+ # @param force_file_read [True, False] force read api key from file
51
+ # @param token_path [String] path to file with API Token
48
52
  # @return [String] token
49
- def self.read_token
50
- return ENV['BUGZILLA_API_KEY'] if ENV['BUGZILLA_API_KEY']
53
+ def self.read_token(force_file_read: false,
54
+ token_path: "#{Dir.home}/.bugzilla/api_key")
55
+ return ENV['BUGZILLA_API_KEY'] if ENV['BUGZILLA_API_KEY'] && !force_file_read
51
56
 
52
- File.read(Dir.home + '/.bugzilla/api_key').delete("\n")
57
+ File.read(token_path).delete("\n")
53
58
  rescue Errno::ENOENT
54
59
  raise Errno::ENOENT,
55
60
  "No access token found in #{Dir.home}/.bugzilla/api_key" \
@@ -67,9 +72,8 @@ module OnlyofficeBugzillaHelper
67
72
  # @param bug_id [Integer] id of bug
68
73
  # @return [Net::HTTPResponse] result of request
69
74
  def get_bug_result(bug_id)
70
- Net::HTTP.start(@url.host, @url.port, use_ssl: use_ssl?) do |http|
71
- http.get(bug_url(bug_id))
72
- end
75
+ req = Net::HTTP::Get.new(bug_url(bug_id))
76
+ perform_request(req)
73
77
  end
74
78
  end
75
79
  end
@@ -24,7 +24,7 @@ module OnlyofficeBugzillaHelper
24
24
  def bug_exists?(bug_id)
25
25
  bug_status(bug_id)
26
26
  true
27
- rescue JSON::ParserError
27
+ rescue JSON::ParserError, NoMethodError
28
28
  false
29
29
  end
30
30
  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
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OnlyofficeBugzillaHelper
4
+ # [String] name of gem
4
5
  NAME = 'onlyoffice_bugzilla_helper'
5
6
  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
@@ -3,13 +3,15 @@
3
3
  module OnlyofficeBugzillaHelper
4
4
  # Method to updating bug data
5
5
  module UpdateBug
6
+ # Update bug info
7
+ # @param bug_id [Integer] id of bug
8
+ # @param params [Hash] params to update
9
+ # @return [Net::HTTPResponse] result of update
6
10
  def update_bug(bug_id, params = {})
7
11
  req = Net::HTTP::Put.new(bug_url(bug_id))
8
12
  req.body = params.to_json
9
13
  req.add_field('Content-Type', 'text/plain')
10
- connection = Net::HTTP.new(@url.host, @url.port)
11
- connection.use_ssl = use_ssl?
12
- connection.start { |http| http.request(req) }
14
+ perform_request(req)
13
15
  end
14
16
  end
15
17
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OnlyofficeBugzillaHelper
4
- VERSION = '0.3.0'
4
+ # [String] version of Gem
5
+ VERSION = '0.6.1'
5
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.3.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ONLYOFFICE
@@ -9,22 +9,148 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-04-29 00:00:00.000000000 Z
12
+ date: 2021-04-08 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: faker
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '2'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '2'
28
+ - !ruby/object:Gem::Dependency
29
+ name: overcommit
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
14
42
  - !ruby/object:Gem::Dependency
15
43
  name: rake
16
44
  requirement: !ruby/object:Gem::Requirement
17
45
  requirements:
18
46
  - - "~>"
19
47
  - !ruby/object:Gem::Version
20
- version: '13.0'
48
+ version: '13'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '13'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rspec
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '3'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '3'
70
+ - !ruby/object:Gem::Dependency
71
+ name: rubocop
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '1'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '1'
84
+ - !ruby/object:Gem::Dependency
85
+ name: rubocop-performance
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: '1'
21
91
  type: :development
22
92
  prerelease: false
23
93
  version_requirements: !ruby/object:Gem::Requirement
24
94
  requirements:
25
95
  - - "~>"
26
96
  - !ruby/object:Gem::Version
27
- version: '13.0'
97
+ version: '1'
98
+ - !ruby/object:Gem::Dependency
99
+ name: rubocop-rake
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - "~>"
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - "~>"
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ - !ruby/object:Gem::Dependency
113
+ name: rubocop-rspec
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - "~>"
117
+ - !ruby/object:Gem::Version
118
+ version: '2'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - "~>"
124
+ - !ruby/object:Gem::Version
125
+ version: '2'
126
+ - !ruby/object:Gem::Dependency
127
+ name: simplecov
128
+ requirement: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - "~>"
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ type: :development
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - "~>"
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ - !ruby/object:Gem::Dependency
141
+ name: yard
142
+ requirement: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ version: 0.9.20
147
+ type: :development
148
+ prerelease: false
149
+ version_requirements: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: 0.9.20
28
154
  description: Helper for bugzilla, used in QA
29
155
  email:
30
156
  - shockwavenn@gmail.com
@@ -35,19 +161,20 @@ files:
35
161
  - lib/onlyoffice_bugzilla_helper.rb
36
162
  - lib/onlyoffice_bugzilla_helper/bug_data.rb
37
163
  - lib/onlyoffice_bugzilla_helper/comments.rb
164
+ - lib/onlyoffice_bugzilla_helper/logger_wrapper.rb
38
165
  - lib/onlyoffice_bugzilla_helper/name.rb
39
166
  - lib/onlyoffice_bugzilla_helper/networking.rb
40
167
  - lib/onlyoffice_bugzilla_helper/update_bug.rb
41
168
  - lib/onlyoffice_bugzilla_helper/version.rb
42
- homepage: https://github.com/onlyoffice-testing-robot/onlyoffice_bugzilla_helper
169
+ homepage: https://github.com/ONLYOFFICE-QA/onlyoffice_bugzilla_helper
43
170
  licenses:
44
171
  - AGPL-3.0
45
172
  metadata:
46
- bug_tracker_uri: https://github.com/onlyoffice-testing-robot/onlyoffice_bugzilla_helper/issues
47
- changelog_uri: https://github.com/onlyoffice-testing-robot/onlyoffice_bugzilla_helper/blob/master/CHANGELOG.md
173
+ bug_tracker_uri: https://github.com/ONLYOFFICE-QA/onlyoffice_bugzilla_helper/issues
174
+ changelog_uri: https://github.com/ONLYOFFICE-QA/onlyoffice_bugzilla_helper/blob/master/CHANGELOG.md
48
175
  documentation_uri: https://www.rubydoc.info/gems/onlyoffice_bugzilla_helper
49
- homepage_uri: https://github.com/onlyoffice-testing-robot/onlyoffice_bugzilla_helper
50
- source_code_uri: https://github.com/onlyoffice-testing-robot/onlyoffice_bugzilla_helper
176
+ homepage_uri: https://github.com/ONLYOFFICE-QA/onlyoffice_bugzilla_helper
177
+ source_code_uri: https://github.com/ONLYOFFICE-QA/onlyoffice_bugzilla_helper
51
178
  post_install_message:
52
179
  rdoc_options: []
53
180
  require_paths:
@@ -56,14 +183,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
56
183
  requirements:
57
184
  - - ">="
58
185
  - !ruby/object:Gem::Version
59
- version: '0'
186
+ version: '2.4'
60
187
  required_rubygems_version: !ruby/object:Gem::Requirement
61
188
  requirements:
62
189
  - - ">="
63
190
  - !ruby/object:Gem::Version
64
191
  version: '0'
65
192
  requirements: []
66
- rubygems_version: 3.1.2
193
+ rubygems_version: 3.2.14
67
194
  signing_key:
68
195
  specification_version: 4
69
196
  summary: Helper for bugzilla