error_response 1.0.2 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/error_response.rb +9 -10
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1dfefe20bd6f5d04dd9c810e9c41162c8553b6f956d66ca8167b582802e3942c
4
- data.tar.gz: c62ac75a87b7e8c2792042524d885ecc67a0af91c07057dbf637f290350f2593
3
+ metadata.gz: 942aeb3cb71ffd7c3adff6fd0d30d200ec1179eac0252f9c3d73c19530ef3226
4
+ data.tar.gz: 077bcdd308abe7d3eaf1a849594b9f25d056e52447c83a7b93ce6014d440c19b
5
5
  SHA512:
6
- metadata.gz: c060b9b673d0d4de104fbd08aa55a482ab25c481b89f0a06e0afbdf8ab62b4840fba3753857c24744839f19d4b40503ce1e5bf982b1ef43055162aa3a25af0fc
7
- data.tar.gz: c5e2ba705cea8bbd13792683f98a67efdd9ac0706c8d9d5fdb227659df4ba35406b8d309624b13deb7cef92f16024bafc144ad424fb5bfa8a71d68b19cc11634
6
+ metadata.gz: 64c7a9948a528a8cb85c188538cb885802483e4752aa8ad98fcad13e5f4cd65245e78dc5f5c8967a26c3345d3668b46b06840a2bd77207396f4b2075ca97d62b
7
+ data.tar.gz: a27250609dee2141be6f848f95588ea150b8f6ff9d080886ba47175b6fea7476e56fa13487e5e335e4508e9de479c993a4c3a0b76a53e712d43a24f70a88703a
@@ -14,16 +14,11 @@ class ErrorResponse
14
14
  end
15
15
 
16
16
  def self.to_api(key, message=nil)
17
- default_result = {
18
- status: 500,
19
- json: { 'error_code' => 500_000, 'error_message' => message }
20
- }
21
- return default_result unless yaml_hash.key?(key.to_s)
22
-
23
- json = yaml_hash[key.to_s].merge({ 'error_key' => key.to_s })
17
+ json = yaml_hash[key.to_s] || { 'error_code' => 500_000, 'error_message' => key.to_s }
18
+ json['error_key'] = key.to_s
24
19
  json['error_message'] += ": #{message}" unless message.nil?
25
20
  {
26
- status: json['error_code'] / 1_000,
21
+ status: parse_status(json['error_code']),
27
22
  json: json
28
23
  }
29
24
  end
@@ -39,12 +34,16 @@ class ErrorResponse
39
34
 
40
35
  remote_array = settings['source']['remote']
41
36
  remote_hash = remote_array.nil? ? {} : remote_array.map { |url| build_yaml(url) }.inject(&:merge)
42
-
37
+
43
38
  @hash = local_hash.merge(remote_hash)
44
39
  end
45
40
 
46
41
  def self.build_yaml(url)
47
- content = open(url){|f| f.read}
42
+ content = URI.open(url){|f| f.read}
48
43
  YAML.load(content)
49
44
  end
45
+
46
+ def self.parse_status(error_code)
47
+ error_code.to_s[0..2].to_i
48
+ end
50
49
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: error_response
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kdan Mobile Software Developer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-04 00:00:00.000000000 Z
11
+ date: 2022-03-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: use for error_response
14
14
  email: dev@kdanmobile.com