config_service 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config_service.gemspec +2 -2
- data/lib/config_service.rb +2 -1
- data/lib/services/config_service.rb +1 -1
- data/lib/utils/hash_utils.rb +14 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d78e78d2fb9f00610ebee9b2979b097cf136589
|
4
|
+
data.tar.gz: 71c1977080f8823b52637d682b928107e46b22a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ec7987d2b349cdd3d3345d734ea41cdc8fc0503836510cb89b569a5482fc15478c80fd985779ca80ca22623b9309e9fcc6e0dbcc906dac693a6c12dde5151ca
|
7
|
+
data.tar.gz: 320aad7b8617393b46597cefdec1f215552f978bae59bef31e6708a9a677cc7b0b1d2be2e47350eb207841d834d31729c6151d40ab5a0a617b299f86df5273a0
|
data/config_service.gemspec
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'config_service'
|
3
|
-
s.version = '1.0.
|
3
|
+
s.version = '1.0.1'
|
4
4
|
s.summary = "A gem to load config yml files"
|
5
5
|
s.description = "A gem to load config yml files"
|
6
6
|
s.authors = ['Linh Chau']
|
7
7
|
s.email = 'chauhonglinh@gmail.com'
|
8
8
|
s.files = [
|
9
9
|
'./config_service.gemspec', 'lib/config_service.rb',
|
10
|
-
'lib/services/config_service.rb'
|
10
|
+
'lib/services/config_service.rb', 'lib/utils/hash_utils.rb'
|
11
11
|
]
|
12
12
|
s.homepage = 'https://github.com/linhchauatl/config_service'
|
13
13
|
s.license = 'MIT'
|
data/lib/config_service.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'yaml'
|
2
|
+
require 'ostruct'
|
2
3
|
require_relative 'services/config_service'
|
3
4
|
|
4
5
|
def load_gem_lib(sub_path)
|
@@ -9,7 +10,7 @@ rescue Exception => error
|
|
9
10
|
# Who cares?
|
10
11
|
end
|
11
12
|
|
12
|
-
['services'].each do |sub_path|
|
13
|
+
['utils', 'services'].each do |sub_path|
|
13
14
|
load_gem_lib(sub_path)
|
14
15
|
rb_files = Dir.glob("#{File.expand_path('.')}/lib/#{sub_path}/*.rb")
|
15
16
|
rb_files.each { |rb_file| require rb_file }
|
@@ -16,7 +16,7 @@ class ConfigService
|
|
16
16
|
|
17
17
|
raise("#{Time.now.strftime("%m/%d/%Y %H:%M:%S.%3N %z")} ERROR: ConfigService#load_config #{config_file_name} file not found.") unless config_file
|
18
18
|
|
19
|
-
YAML.load_file(config_file)
|
19
|
+
HashUtils.hash_to_open_struct(YAML.load_file(config_file))
|
20
20
|
end
|
21
21
|
|
22
22
|
def environment
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class HashUtils
|
2
|
+
class << self
|
3
|
+
def hash_to_open_struct(data_hash)
|
4
|
+
elements_with_hash_values = data_hash.select { |key, value| value.is_a? Hash }
|
5
|
+
return OpenStruct.new(data_hash) if elements_with_hash_values.empty?
|
6
|
+
|
7
|
+
result = OpenStruct.new(data_hash.select { |key, value| !value.is_a?(Hash) })
|
8
|
+
elements_with_hash_values.each do |key, value|
|
9
|
+
result.send("#{key}=", hash_to_open_struct(value))
|
10
|
+
end
|
11
|
+
result
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: config_service
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Linh Chau
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logging
|
@@ -61,6 +61,7 @@ files:
|
|
61
61
|
- "./config_service.gemspec"
|
62
62
|
- lib/config_service.rb
|
63
63
|
- lib/services/config_service.rb
|
64
|
+
- lib/utils/hash_utils.rb
|
64
65
|
homepage: https://github.com/linhchauatl/config_service
|
65
66
|
licenses:
|
66
67
|
- MIT
|
@@ -81,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
82
|
version: '0'
|
82
83
|
requirements: []
|
83
84
|
rubyforge_project:
|
84
|
-
rubygems_version: 2.4.
|
85
|
+
rubygems_version: 2.4.6
|
85
86
|
signing_key:
|
86
87
|
specification_version: 4
|
87
88
|
summary: A gem to load config yml files
|