error_response 0.3.0 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/error_response.rb +19 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1efeb1efcc18c781cdd4a93c43f58bf43b5e0c458858eef2e9f075743b458267
|
4
|
+
data.tar.gz: bfcedb8926e592af00c8d9d8de3c28e5812b6fe5998da8d7e011b588b2368dea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 642829817c96ccc1f356a87ed6b5c84354703d920e297b839df88eefb5ffa2f61136a3ea5748fb6d09d737dec7b33ea7961559b5724b94ec9022dd3bf0cd7156
|
7
|
+
data.tar.gz: d62b4657bd9d672954d61a20d8af78048d539ce89ae297ecbe0ed65deb06a55bcf831c1db07557f2cb735d444de7e51aaeb7d7617ed187b7a31cf7c4bd21ddf7
|
data/lib/error_response.rb
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
require 'yaml'
|
2
|
+
require 'open-uri'
|
3
|
+
|
2
4
|
class ErrorResponse
|
3
|
-
|
5
|
+
SETTING_PATH = 'config/error_response.yml'
|
4
6
|
|
5
7
|
def self.all
|
6
8
|
yaml_hash
|
7
9
|
end
|
8
10
|
|
9
11
|
def self.to_hash(key)
|
10
|
-
return unless yaml_hash.key?(key.to_s)
|
12
|
+
return {} unless yaml_hash.key?(key.to_s)
|
11
13
|
yaml_hash[key.to_s].merge({ 'error_key' => key.to_s })
|
12
14
|
end
|
13
15
|
|
@@ -29,6 +31,20 @@ class ErrorResponse
|
|
29
31
|
private
|
30
32
|
|
31
33
|
def self.yaml_hash
|
32
|
-
@hash
|
34
|
+
return @hash unless @hash.nil?
|
35
|
+
|
36
|
+
settings = YAML.load(File.read(SETTING_PATH))
|
37
|
+
local_array = settings['source']['local']
|
38
|
+
local_hash = local_array.nil? ? {} : local_array.map { |path| YAML.load_file(path) }.inject(&:merge)
|
39
|
+
|
40
|
+
remote_array = settings['source']['remote']
|
41
|
+
remote_hash = remote_array.nil? ? {} : remote_array.map { |url| build_yaml(url) }.inject(&:merge)
|
42
|
+
|
43
|
+
@hash = local_hash.merge(remote_hash)
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.build_yaml(url)
|
47
|
+
content = URI.open(url){|f| f.read}
|
48
|
+
YAML.load(content)
|
33
49
|
end
|
34
50
|
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: 0.3
|
4
|
+
version: 1.0.3
|
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
|
+
date: 2020-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: use for error_response
|
14
14
|
email: dev@kdanmobile.com
|