config_service 1.0.6 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2aa49cd3e3bbde559c6803631a762bdfb7eac969
4
- data.tar.gz: 3503168f3ae75b8526db4e71014589be53365371
3
+ metadata.gz: c4ed5db710f18700fcc8bc1dcdb49e1676b08bb5
4
+ data.tar.gz: 65ff95704a41b6af69b2548fcf569c12395a8f92
5
5
  SHA512:
6
- metadata.gz: 124db259e5cc24ed98c199c6c856c95f5ddaa317dba83bcb61c3ed4a9daa01610616645e9e5c4e7d93bf4cdabccd51508811435a531073aab7eef84d3d371724
7
- data.tar.gz: 384721eb12b13066592b1b7c56276ac4cff72c1db4d475c486bad87c4c08aa267bf19248af009093b989ba40b8e7fbcf8baee7ecac86485df605b86fdb388fe3
6
+ metadata.gz: a1fece3618f6294c2283b6811c39bc4b0121e2f98553ce1c11e4faec4d85a88505d9000d42009b4ff69c5d4967c3afa0c5619f77955e4f86c6c6c58e533ad05a
7
+ data.tar.gz: 05ac92d32456d277cadbe1a758f44057c4e878a6d9d2aed0621f81a99757410cb5a0be5d76fd124c385dc773eb5dbf0dab733eb542e272eb44d8a965990081c9
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'config_service'
3
- s.version = '1.0.6'
3
+ s.version = '1.0.7'
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']
@@ -13,4 +13,4 @@ Gem::Specification.new do |s|
13
13
  s.license = 'MIT'
14
14
  s.add_runtime_dependency 'activesupport'
15
15
  s.add_development_dependency 'rspec', '~> 3.1'
16
- end
16
+ end
@@ -5,15 +5,19 @@ class ConfigService
5
5
  class << self
6
6
  def load_config(config_file_name)
7
7
  app_root = (defined? APP_ROOT)? APP_ROOT : File.expand_path('.')
8
-
8
+
9
9
  config_file = nil
10
- ['conf', 'config'].each do |sub_path|
11
- if File.exist?("#{app_root}/#{sub_path}/#{config_file_name}")
12
- config_file = "#{app_root}/#{sub_path}/#{config_file_name}"
13
- break
10
+ if config_file_name.starts_with?('/')
11
+ config_file = config_file_name if File.exist?(config_file_name)
12
+ else
13
+ ['conf', 'config'].each do |sub_path|
14
+ if File.exist?("#{app_root}/#{sub_path}/#{config_file_name}")
15
+ config_file = "#{app_root}/#{sub_path}/#{config_file_name}"
16
+ break
17
+ end
14
18
  end
15
19
  end
16
-
20
+
17
21
  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
22
 
19
23
  HashUtils.hash_to_open_struct(YAML.load(ERB.new(File.new(config_file).read).result))
@@ -22,9 +26,10 @@ class ConfigService
22
26
  def environment
23
27
  return Rails.env if defined? Rails
24
28
  return ENV['RACK_ENV'] if ENV['RACK_ENV'].present?
29
+ return ENV['ENV'] if ENV['ENV'].present?
25
30
  'development'
26
31
  rescue => error
27
32
  'development'
28
33
  end
29
34
  end # class methods
30
- end
35
+ 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.6
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Linh Chau
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-08 00:00:00.000000000 Z
11
+ date: 2016-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -68,7 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
68
68
  version: '0'
69
69
  requirements: []
70
70
  rubyforge_project:
71
- rubygems_version: 2.5.1
71
+ rubygems_version: 2.6.4
72
72
  signing_key:
73
73
  specification_version: 4
74
74
  summary: A gem to load config yml files