error_response 0.4.0 → 1.0.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 +13 -7
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 89dfae134289bf7bbcc43d119e0e94bffca2022dcaa82aa32ae62dabf6d016b7
4
- data.tar.gz: 8f3b6b890ba7191734fe1d2ae21102149ebb84ca4ee6102b1d608b21357b44ba
3
+ metadata.gz: ebe8d02da14d5ee8e61570632107f19771e72abecde069d7135bb34c605ab690
4
+ data.tar.gz: e474c47b4ea2a7451706d07323cd1b0cd62c29a04abba20b5cdfb184c8d616fe
5
5
  SHA512:
6
- metadata.gz: 06e1f7500a4f97c6448611eb6dea6ea52decf9703aa560805c79ce7d473a025cce114edd1110623d6c6e26669129ccd50513a23be2f638a4d179644838beeada
7
- data.tar.gz: 0c9e59ed9a5421fb3fab7ac591df3cc1163ed9eca82dcdcbb395ebf2f101cf47834b5ab3b54b3841a8c27f4b76ee061c9a3c35252197068afea868c11ff56615
6
+ metadata.gz: 51fa6d71acb509c7713c19089a5cfa431a25adc6866fbb4db52c775fa08cd3117b40b9e8be0ad91059b3c8a099bbb3df3f2b95ef4ce310ca1797b2761ec4be32
7
+ data.tar.gz: 68e1fb3cafb7f2d42e7e1595dab4404d71e1e1c10ccbeabe4ce20acd23148a5a0e9980fe842cb91ac2480d295e2e148126fbae2ef9215d91a7856f9fe827b192
@@ -2,7 +2,7 @@ require 'yaml'
2
2
  require 'open-uri'
3
3
 
4
4
  class ErrorResponse
5
- YAML_PATH = 'config/error_response.yml'
5
+ SETTING_PATH = 'config/error_response.yml'
6
6
 
7
7
  def self.all
8
8
  yaml_hash
@@ -28,14 +28,20 @@ class ErrorResponse
28
28
  }
29
29
  end
30
30
 
31
- def self.load_remote(remote_file)
32
- content = open(remote_file){|f| f.read}
33
- @hash = YAML.load(content)
34
- end
35
-
36
31
  private
37
32
 
38
33
  def self.yaml_hash
39
- @hash ||= YAML.load_file(YAML_PATH)
34
+ return @hash unless @hash.nil?
35
+
36
+ settings = YAML.load(File.read(SETTING_PATH))
37
+ local_hash = settings['source']['local'].map { |path| YAML.load_file(path) }.inject(&:merge)
38
+ remote_hash = settings['source']['remote'].map { |url| build_yaml(url) }.inject(&:merge)
39
+
40
+ @hash = local_hash.merge(remote_hash)
41
+ end
42
+
43
+ def self.build_yaml(url)
44
+ content = open(url){|f| f.read}
45
+ YAML.load(content)
40
46
  end
41
47
  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.4.0
4
+ version: 1.0.0
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-08-20 00:00:00.000000000 Z
11
+ date: 2020-08-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: use for error_response
14
14
  email: dev@kdanmobile.com