tcfg 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/Gemfile.lock +8 -0
- data/VERSION +1 -1
- data/lib/tcfg/tcfg_helper.rb +32 -17
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bbfdbdd6c15939ee12601567c3a500533152d5ab
|
4
|
+
data.tar.gz: 7f6357741984ab34df388bef696b75e81d605628
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 310f1ef7283cd174f008a7d6b32eae4bbc9b7df4e85b1dca450a0398b625f42cb0c92c1c62224adcf14c56d0e547526487824f9e34e90e284fe594fcc2efc72d
|
7
|
+
data.tar.gz: 9b4420e6f2a72d4ea544e5dacca1fdb5d0ed71a0c76a1a1aba27a2871cf3489dcb6397aa548b457c10751761b5628cb68b907dd7871892912784af89e74564ab
|
data/Gemfile
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
source 'http://rubygems.org'
|
2
2
|
|
3
3
|
# activesupport used for HashWithIndifferentAccess
|
4
|
+
# and also some utility methods (deep_dup, deep_merge)
|
4
5
|
gem 'activesupport'
|
5
6
|
|
6
7
|
group :development do
|
7
8
|
gem 'jeweler'
|
8
9
|
gem 'rspec'
|
9
10
|
gem 'rubocop'
|
11
|
+
gem 'simplecov'
|
10
12
|
gem 'yard'
|
11
13
|
end
|
data/Gemfile.lock
CHANGED
@@ -14,6 +14,7 @@ GEM
|
|
14
14
|
descendants_tracker (0.0.4)
|
15
15
|
thread_safe (~> 0.3, >= 0.3.1)
|
16
16
|
diff-lcs (1.3)
|
17
|
+
docile (1.1.5)
|
17
18
|
faraday (0.9.2)
|
18
19
|
multipart-post (>= 1.2, < 3)
|
19
20
|
git (1.3.0)
|
@@ -39,6 +40,7 @@ GEM
|
|
39
40
|
rake
|
40
41
|
rdoc
|
41
42
|
semver2
|
43
|
+
json (2.1.0)
|
42
44
|
jwt (1.5.6)
|
43
45
|
mini_portile2 (2.1.0)
|
44
46
|
minitest (5.10.1)
|
@@ -84,6 +86,11 @@ GEM
|
|
84
86
|
unicode-display_width (~> 1.0, >= 1.0.1)
|
85
87
|
ruby-progressbar (1.8.1)
|
86
88
|
semver2 (3.4.2)
|
89
|
+
simplecov (0.14.1)
|
90
|
+
docile (~> 1.1.0)
|
91
|
+
json (>= 1.8, < 3)
|
92
|
+
simplecov-html (~> 0.10.0)
|
93
|
+
simplecov-html (0.10.0)
|
87
94
|
thread_safe (0.3.6)
|
88
95
|
tzinfo (1.2.3)
|
89
96
|
thread_safe (~> 0.1)
|
@@ -98,6 +105,7 @@ DEPENDENCIES
|
|
98
105
|
jeweler
|
99
106
|
rspec
|
100
107
|
rubocop
|
108
|
+
simplecov
|
101
109
|
yard
|
102
110
|
|
103
111
|
BUNDLED WITH
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
data/lib/tcfg/tcfg_helper.rb
CHANGED
@@ -5,7 +5,7 @@ require 'yaml'
|
|
5
5
|
require 'active_support/core_ext/hash/indifferent_access'
|
6
6
|
require 'active_support/core_ext/hash/deep_merge'
|
7
7
|
require 'active_support/core_ext/hash/slice'
|
8
|
-
# active_support 5 moved deep_dup,
|
8
|
+
# active_support 5 moved deep_dup,
|
9
9
|
# so this trick is in place to support all activesupport versions
|
10
10
|
begin
|
11
11
|
# deep_dup is here in active_support 5
|
@@ -16,7 +16,8 @@ rescue LoadError
|
|
16
16
|
end
|
17
17
|
|
18
18
|
module TCFG
|
19
|
-
# TCFG::Helper does all the "heavy lifting".
|
19
|
+
# TCFG::Helper does all the "heavy lifting".
|
20
|
+
# Essentially all the logic within TCFG is defined by this module.
|
20
21
|
# The intended ways to use this module are:
|
21
22
|
#
|
22
23
|
# - use the TCFG module methods whenever a single instance of configuration will do
|
@@ -60,8 +61,8 @@ module TCFG
|
|
60
61
|
# @return [ActiveSupport::HashWithIndifferentAccess] a copy of the resolved configuration
|
61
62
|
def tcfg
|
62
63
|
@tcfg_resolved_config ||= resolve_config
|
63
|
-
# return a deep copy of the configuration object to prevent mutations
|
64
|
-
@tcfg_resolved_config.deep_dup
|
64
|
+
# return a frozen deep copy of the configuration object to prevent mutations
|
65
|
+
@tcfg_resolved_config.deep_dup.freeze
|
65
66
|
end
|
66
67
|
|
67
68
|
# change the name of the public configuration file
|
@@ -174,22 +175,11 @@ module TCFG
|
|
174
175
|
end
|
175
176
|
|
176
177
|
def tier_config_file
|
177
|
-
|
178
|
-
tcfg_load_optional_config_file @tcfg_config_filename
|
178
|
+
tcfg_load_optional_config_file possible_config_file_name
|
179
179
|
end
|
180
180
|
|
181
181
|
def tier_secret_config_file
|
182
|
-
|
183
|
-
tcfg_load_optional_config_file @tcfg_secret_config_filename
|
184
|
-
elsif @tcfg_config_filename
|
185
|
-
ext = File.extname @tcfg_config_filename
|
186
|
-
base = File.basename @tcfg_config_filename, ext
|
187
|
-
dir = File.dirname @tcfg_config_filename
|
188
|
-
possible_secret_filename = dir + '/' + base + '.secret' + ext
|
189
|
-
tcfg_load_optional_config_file possible_secret_filename
|
190
|
-
else
|
191
|
-
{}
|
192
|
-
end
|
182
|
+
tcfg_load_optional_config_file possible_secret_config_file_name
|
193
183
|
end
|
194
184
|
|
195
185
|
def tier_environment_overrides
|
@@ -283,6 +273,31 @@ module TCFG
|
|
283
273
|
|
284
274
|
resolved_config
|
285
275
|
end
|
276
|
+
|
277
|
+
|
278
|
+
def possible_config_file_name
|
279
|
+
possible_file_name = if @tcfg_config_filename
|
280
|
+
@tcfg_config_filename
|
281
|
+
else
|
282
|
+
DEFAULT_CONFIG_FILE
|
283
|
+
end
|
284
|
+
possible_file_name
|
285
|
+
end
|
286
|
+
|
287
|
+
def possible_secret_config_file_name
|
288
|
+
possible_file_name = if @tcfg_secret_config_filename
|
289
|
+
@tcfg_secret_config_filename
|
290
|
+
else
|
291
|
+
# turn 'somedir/tcfg.yml' into 'somedir/tcfg.secret.yml'
|
292
|
+
non_secret_config_file = possible_config_file_name
|
293
|
+
ext = File.extname non_secret_config_file
|
294
|
+
base = File.basename non_secret_config_file, ext
|
295
|
+
dir = File.dirname non_secret_config_file
|
296
|
+
possible_secret_filename = dir + '/' + base + '.secret' + ext
|
297
|
+
possible_secret_filename
|
298
|
+
end
|
299
|
+
possible_file_name
|
300
|
+
end
|
286
301
|
end
|
287
302
|
|
288
303
|
# raised when the requested environment is not available
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tcfg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- robert schultheis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: yard
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|