error_response 0.1.3 → 0.2.0

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 +10 -1
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fb1fff56885d056e0ff23ba2da10daa85875a60c3c6afb97a840ac601f23f138
4
- data.tar.gz: 28342938f10616bfba217b042b58156f83c82831f524717a446edeb17ce8d032
3
+ metadata.gz: bfd7efb20d85b835e242e64e7fee3d633522eefbe1834aedf30295b84b2cfea8
4
+ data.tar.gz: 9e9013875242b545811ce64585d3cf8f58a33775d773b507125e7cd8934bbaca
5
5
  SHA512:
6
- metadata.gz: 5d32e77ff063489bce54f894b158b18a53b7d211ee7cf92a8f3aa47b9425f6baafc30b9cfc6238f5d25109bc49f8fe392b3363d6bde1be34607eee9b08bf85db
7
- data.tar.gz: 0ca3cfd25e3073fadd087587007c00a548b8ea9ad225ba6eace37ecaf326f57048a788c5e869a8013ba86125d3b775cfe1ce2046ad3a6651f0d4fe65af60898c
6
+ metadata.gz: ba3d15d0cd86e5fea18fba693fef5b75fae6b8ba409a73b4d377cfa85e45e70d4cf87b116c6c3e78238cb16c047b8da10943b09abe33ece451a24aa83b462deb
7
+ data.tar.gz: 0aafe71739e97cd17b3fadb3614cf7c3e9fc6a221d77bab5a6bc4960d6e2374c3f9f881756153d333e59078049560268df4e290891d1ba1e4a9276bc263f1df1
@@ -2,6 +2,7 @@ require 'yaml'
2
2
  class ErrorResponse
3
3
  GEM_ROOT = File.expand_path("../..", __FILE__)
4
4
  YAML_PATH = 'lib/error_response.yml'
5
+ EXTEND_DIR = 'lib/error_response/*.yml'
5
6
 
6
7
  def self.to_api(key, message=nil)
7
8
  err_json = yaml_hash[key.to_s] || {'error_code' => 500000, 'error_message' => message}
@@ -23,6 +24,14 @@ class ErrorResponse
23
24
 
24
25
  private
25
26
  def self.yaml_hash
26
- yaml ||= YAML.load_file(File.join(GEM_ROOT,YAML_PATH))
27
+ return @hash unless @hash.nil?
28
+
29
+ @hash = YAML.load_file(File.join(GEM_ROOT,YAML_PATH))
30
+ Dir.glob(EXTEND_DIR).each do |file|
31
+ extend_yml = YAML.load_file(file)
32
+ @hash.merge!(extend_yml)
33
+ end
34
+
35
+ @hash
27
36
  end
28
37
  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.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - jameslee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-12 00:00:00.000000000 Z
11
+ date: 2019-08-19 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: use for error_response
14
14
  email: jameslee@kdanmobile.com