usps-imis-api 0.13.1 → 0.13.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/usps/imis/command_line/interface.rb +6 -0
- data/lib/usps/imis/command_line/options.yml.erb +6 -0
- data/lib/usps/imis/command_line/performers.rb +3 -2
- data/lib/usps/imis/error.rb +6 -1
- data/lib/usps/imis/errors/pattern_matching_error.rb +25 -0
- data/lib/usps/imis/logger_helpers.rb +3 -3
- data/lib/usps/imis/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '09a1b56a1ebf594cbb7ee3ebad5ce72263cf004b991291e0b1540672f55cac41'
|
|
4
|
+
data.tar.gz: ac66d1c3bc9887a061ed8800e93624b99a9e8813d4bd14e98c566fbf00e36245
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 98c418427848de89251fe111854af67e81a0160766ed8ab6073b4d575044687bbad0b72d04faae5f0128f6bc8a47c2183cd3b5be07b7da32eb2d76565222b6f9
|
|
7
|
+
data.tar.gz: bcfd41aa7c1e38cbe5331853acbad46beb5ffe0389e592d7564bc5880973e6cf3c0f425187f002a9c7b3796e37be19e8b1c674e85beb2a9485ba7a01fbc0821e
|
|
@@ -64,6 +64,8 @@ module Usps
|
|
|
64
64
|
output { result }
|
|
65
65
|
|
|
66
66
|
result
|
|
67
|
+
rescue StandardError => e
|
|
68
|
+
handle_exception!(e)
|
|
67
69
|
end
|
|
68
70
|
|
|
69
71
|
private
|
|
@@ -165,6 +167,10 @@ module Usps
|
|
|
165
167
|
end
|
|
166
168
|
|
|
167
169
|
def default_options? = options[:log_level] == 'info' && options.except(:log_level).values.none?
|
|
170
|
+
|
|
171
|
+
# :nocov:
|
|
172
|
+
def handle_exception!(exception) = options[:trace] ? raise(exception) : exit(2)
|
|
173
|
+
# :nocov:
|
|
168
174
|
end
|
|
169
175
|
end
|
|
170
176
|
end
|
|
@@ -159,11 +159,17 @@ Options:
|
|
|
159
159
|
- type: string
|
|
160
160
|
default: info
|
|
161
161
|
short: L
|
|
162
|
+
trace:
|
|
163
|
+
- Show exception stack trace on error
|
|
164
|
+
- short: x
|
|
162
165
|
|
|
163
166
|
Misc:
|
|
164
167
|
version:
|
|
165
168
|
- Print version and exit
|
|
166
169
|
- short: v
|
|
170
|
+
environment:
|
|
171
|
+
- Print configured environment and exit
|
|
172
|
+
- short: E
|
|
167
173
|
help:
|
|
168
174
|
- Show this message
|
|
169
175
|
- short: h
|
|
@@ -21,9 +21,10 @@ module Usps
|
|
|
21
21
|
in certificate: _ then api.imis_id
|
|
22
22
|
in show_config: true then config_path
|
|
23
23
|
in version: true then api.class.version
|
|
24
|
+
in environment: true then Imis.config.environment
|
|
24
25
|
end
|
|
25
|
-
rescue NoMatchingPatternError
|
|
26
|
-
raise Errors::
|
|
26
|
+
rescue NoMatchingPatternError
|
|
27
|
+
raise Errors::PatternMatchingError.new(options:)
|
|
27
28
|
end
|
|
28
29
|
|
|
29
30
|
def convert(options)
|
data/lib/usps/imis/error.rb
CHANGED
|
@@ -18,7 +18,7 @@ module Usps
|
|
|
18
18
|
super(message)
|
|
19
19
|
@metadata = metadata
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
log_error
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
# Additional metadata to include in Bugsnag reports
|
|
@@ -39,6 +39,10 @@ module Usps
|
|
|
39
39
|
def base_metadata
|
|
40
40
|
{ api: metadata }
|
|
41
41
|
end
|
|
42
|
+
|
|
43
|
+
def log_error
|
|
44
|
+
Imis.logger(self.class.name).multiline(message, level: :error)
|
|
45
|
+
end
|
|
42
46
|
end
|
|
43
47
|
end
|
|
44
48
|
end
|
|
@@ -52,4 +56,5 @@ require_relative 'errors/not_found_error'
|
|
|
52
56
|
require_relative 'errors/response_error'
|
|
53
57
|
require_relative 'errors/panel_unimplemented_error'
|
|
54
58
|
require_relative 'errors/unexpected_property_type_error'
|
|
59
|
+
require_relative 'errors/pattern_matching_error'
|
|
55
60
|
require_relative 'errors/command_line_error'
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Usps
|
|
4
|
+
module Imis
|
|
5
|
+
module Errors
|
|
6
|
+
# Exception raised by failure to match pattern
|
|
7
|
+
#
|
|
8
|
+
class PatternMatchingError < Error
|
|
9
|
+
attr_reader :options
|
|
10
|
+
|
|
11
|
+
def initialize(_message = nil, options: {})
|
|
12
|
+
@options = options
|
|
13
|
+
super('Unable to match pattern from options', { options: })
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
private
|
|
17
|
+
|
|
18
|
+
def log_error
|
|
19
|
+
Imis.logger(self.class.name).error('Unable to match pattern from options:')
|
|
20
|
+
Imis.logger(self.class.name).json(options, level: :error)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -9,11 +9,11 @@ module Usps
|
|
|
9
9
|
string.split("\n").each { public_send(level, it) }
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
-
def json(data)
|
|
12
|
+
def json(data, level: :debug)
|
|
13
13
|
hash = data.is_a?(String) ? JSON.parse(data) : data
|
|
14
|
-
tagged('JSON') { multiline(JSON.pretty_generate(hash)) }
|
|
14
|
+
tagged('JSON') { multiline(JSON.pretty_generate(hash), level:) }
|
|
15
15
|
rescue StandardError
|
|
16
|
-
multiline(data)
|
|
16
|
+
multiline(data, level:)
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
def time
|
data/lib/usps/imis/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: usps-imis-api
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.13.
|
|
4
|
+
version: 0.13.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Julian Fiander
|
|
@@ -112,6 +112,7 @@ files:
|
|
|
112
112
|
- lib/usps/imis/errors/missing_id_error.rb
|
|
113
113
|
- lib/usps/imis/errors/not_found_error.rb
|
|
114
114
|
- lib/usps/imis/errors/panel_unimplemented_error.rb
|
|
115
|
+
- lib/usps/imis/errors/pattern_matching_error.rb
|
|
115
116
|
- lib/usps/imis/errors/response_error.rb
|
|
116
117
|
- lib/usps/imis/errors/unexpected_property_type_error.rb
|
|
117
118
|
- lib/usps/imis/logger.rb
|