minato-utils 0.3.0 → 0.5.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: a05b7abec99a94707b89712be193674bcca9a435659048c056bc35b1a2181388
4
- data.tar.gz: 2c62d3651df6545e0246d6b0a3707a43c18e8754b3b870c49251783eef2929de
3
+ metadata.gz: 6626367c8440fded71994676c199806bc01f7358a6ba42e85d8b494fef182c7f
4
+ data.tar.gz: c1a8a0a05a370826951e10a8216b0419cd4c0732a72a6ce809f2a22212738547
5
5
  SHA512:
6
- metadata.gz: b189685deee6144188542ca6a54aa3b5b30539c431b71c3a6ea39be4570df35f8a35a9f1441b0187ffeb22b5fa0a09b664f8bdbf0be25c058e9fb4a33f907395
7
- data.tar.gz: 8be054f544d3820864763af19471edc40acf4077e795a97aa5dbcc7db41d6eb12a79779c309e1f586152de30638aa608b59194680a06a8019aacc49adb9bfcfc
6
+ metadata.gz: 9f605fef797c9f3b1ec7c5b335fbded2373ca15dfe0eac2c3a172b0d5f6b1de3215e7aa1a6a01c108f335ad361461681eeb34646be5345413835ecec7a6a9864
7
+ data.tar.gz: e334237e871b048ad46a657f1bcd2019eb8c2c0517bd9b7b980d4ae55fdb62533b9d0a055a28ca1037802022b50b73231d2bab4448e981e41782a9c5903a51c2
data/.rubocop.yml CHANGED
@@ -22,6 +22,9 @@ RSpec/ExampleLength:
22
22
  RSpec/ImplicitExpect:
23
23
  Enabled: false
24
24
 
25
+ RSpec/MultipleExpectations:
26
+ Enabled: false
27
+
25
28
  Style/Documentation:
26
29
  Enabled: false
27
30
 
data/Gemfile.lock CHANGED
@@ -1,30 +1,29 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- minato-utils (0.3.0)
5
- activesupport (~> 6.0)
4
+ minato-utils (0.4.0)
5
+ activesupport (~> 7.0.4)
6
6
  httparty (~> 0.18)
7
7
  simple_command (~> 0.1.0)
8
8
 
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- activemodel (6.1.4.4)
13
- activesupport (= 6.1.4.4)
14
- activerecord (6.1.4.4)
15
- activemodel (= 6.1.4.4)
16
- activesupport (= 6.1.4.4)
17
- activesupport (6.1.4.4)
12
+ activemodel (7.0.4)
13
+ activesupport (= 7.0.4)
14
+ activerecord (7.0.4)
15
+ activemodel (= 7.0.4)
16
+ activesupport (= 7.0.4)
17
+ activesupport (7.0.4)
18
18
  concurrent-ruby (~> 1.0, >= 1.0.2)
19
19
  i18n (>= 1.6, < 2)
20
20
  minitest (>= 5.1)
21
21
  tzinfo (~> 2.0)
22
- zeitwerk (~> 2.3)
23
22
  addressable (2.8.0)
24
23
  public_suffix (>= 2.0.2, < 5.0)
25
24
  ast (2.4.2)
26
25
  coderay (1.1.3)
27
- concurrent-ruby (1.1.9)
26
+ concurrent-ruby (1.1.10)
28
27
  crack (0.4.5)
29
28
  rexml
30
29
  database_cleaner-active_record (2.0.1)
@@ -36,14 +35,14 @@ GEM
36
35
  httparty (0.20.0)
37
36
  mime-types (~> 3.0)
38
37
  multi_xml (>= 0.5.2)
39
- i18n (1.8.11)
38
+ i18n (1.12.0)
40
39
  concurrent-ruby (~> 1.0)
41
40
  json (2.6.1)
42
41
  method_source (1.0.0)
43
42
  mime-types (3.4.1)
44
43
  mime-types-data (~> 3.2015)
45
44
  mime-types-data (3.2022.0105)
46
- minitest (5.15.0)
45
+ minitest (5.16.3)
47
46
  multi_xml (0.6.0)
48
47
  parallel (1.21.0)
49
48
  parser (3.0.3.2)
@@ -92,21 +91,21 @@ GEM
92
91
  ruby-progressbar (1.11.0)
93
92
  simple_command (0.1.0)
94
93
  sqlite3 (1.4.2)
95
- tzinfo (2.0.4)
94
+ tzinfo (2.0.5)
96
95
  concurrent-ruby (~> 1.0)
97
96
  unicode-display_width (2.1.0)
98
97
  webmock (3.14.0)
99
98
  addressable (>= 2.8.0)
100
99
  crack (>= 0.3.2)
101
100
  hashdiff (>= 0.4.0, < 2.0.0)
102
- zeitwerk (2.5.1)
103
101
 
104
102
  PLATFORMS
103
+ x64-mingw32
105
104
  x86_64-darwin-21
106
105
  x86_64-linux
107
106
 
108
107
  DEPENDENCIES
109
- activerecord (~> 6.1.4)
108
+ activerecord (~> 7.0.4)
110
109
  bundler (~> 2.2)
111
110
  database_cleaner-active_record (~> 2.0.1)
112
111
  json (~> 2.6)
@@ -122,4 +121,4 @@ DEPENDENCIES
122
121
  webmock (~> 3.14)
123
122
 
124
123
  BUNDLED WITH
125
- 2.3.13
124
+ 2.3.25
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'google/cloud/error_reporting'
4
+
3
5
  module Minato
4
6
  module Utils
5
7
  class SerializableError < StandardError
@@ -43,5 +45,17 @@ module Minato
43
45
  class UnprocessableEntity < NetworkException; end
44
46
 
45
47
  class UnknownException < SerializableException; end
48
+
49
+ module_function
50
+
51
+ def report_error(error:, status: nil)
52
+ return unless Rails.env.production?
53
+
54
+ Google::Cloud::ErrorReporting.report error do |error_event|
55
+ error_event.http_status = status.nil? ? error.code : status
56
+ error_event.service_version = ENV.fetch('RUNTIME_ENV', '?')
57
+ error_event.service_name = ENV.fetch('SERVICE_NAME', '?')
58
+ end
59
+ end
46
60
  end
47
61
  end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Minato
4
+ module Utils
5
+ class Response
6
+ attr_reader :code, :header, :body
7
+
8
+ def initialize(response)
9
+ @code = response.code
10
+ @header = response.header.to_hash || {}
11
+ @body = Helpers.parse_json(response.body)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -9,10 +9,7 @@ module Minato
9
9
  class << self
10
10
  def handle(response)
11
11
  raise_exception(response) if response_error?(response)
12
-
13
- body = Minato::Utils::Helpers.parse_json(response.body)
14
- header = response.header.to_hash || {}
15
- { body: body, header: header }
12
+ Response.new(response)
16
13
  end
17
14
 
18
15
  private
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Minato
4
4
  module Utils
5
- VERSION = '0.3.0'
5
+ VERSION = '0.5.0'
6
6
  end
7
7
  end
data/lib/minato/utils.rb CHANGED
@@ -5,6 +5,7 @@ require_relative 'utils/exception'
5
5
  require_relative 'utils/helpers'
6
6
  require_relative 'utils/logger'
7
7
  require_relative 'utils/version'
8
+ require_relative 'utils/response'
8
9
  require_relative 'utils/base_command/base'
9
10
 
10
11
  module Minato
@@ -24,11 +24,11 @@ Gem::Specification.new do |spec|
24
24
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
25
  spec.require_paths = ['lib']
26
26
 
27
- spec.add_dependency 'activesupport', '~> 6.0'
27
+ spec.add_dependency 'activesupport', '~> 7.0.4'
28
28
  spec.add_dependency 'httparty', '~> 0.18'
29
29
  spec.add_dependency 'simple_command', '~> 0.1.0'
30
30
 
31
- spec.add_development_dependency 'activerecord', '~> 6.1.4'
31
+ spec.add_development_dependency 'activerecord', '~> 7.0.4'
32
32
  spec.add_development_dependency 'bundler', '~> 2.2'
33
33
  spec.add_development_dependency 'database_cleaner-active_record', '~> 2.0.1'
34
34
  spec.add_development_dependency 'json', '~> 2.6'
@@ -42,6 +42,8 @@ Gem::Specification.new do |spec|
42
42
  spec.add_development_dependency 'sqlite3', '~> 1.4.2'
43
43
  spec.add_development_dependency 'webmock', '~> 3.14'
44
44
 
45
+ spec.add_runtime_dependency 'stackdriver', '~> 0.21.1'
46
+
45
47
  spec.metadata = {
46
48
  'rubygems_mfa_required' => 'true'
47
49
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minato-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ferreri
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-05-05 00:00:00.000000000 Z
11
+ date: 2022-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '6.0'
19
+ version: 7.0.4
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '6.0'
26
+ version: 7.0.4
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: httparty
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 6.1.4
61
+ version: 7.0.4
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: 6.1.4
68
+ version: 7.0.4
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bundler
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -234,6 +234,20 @@ dependencies:
234
234
  - - "~>"
235
235
  - !ruby/object:Gem::Version
236
236
  version: '3.14'
237
+ - !ruby/object:Gem::Dependency
238
+ name: stackdriver
239
+ requirement: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - "~>"
242
+ - !ruby/object:Gem::Version
243
+ version: 0.21.1
244
+ type: :runtime
245
+ prerelease: false
246
+ version_requirements: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - "~>"
249
+ - !ruby/object:Gem::Version
250
+ version: 0.21.1
237
251
  description: Library to share common functionality across services
238
252
  email:
239
253
  - contato@ferreri.co
@@ -266,6 +280,7 @@ files:
266
280
  - lib/minato/utils/exception.rb
267
281
  - lib/minato/utils/helpers.rb
268
282
  - lib/minato/utils/logger.rb
283
+ - lib/minato/utils/response.rb
269
284
  - lib/minato/utils/response_handler.rb
270
285
  - lib/minato/utils/version.rb
271
286
  - minato-ruby-utils.gemspec