biran 0.1.9 → 0.1.10
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f486fa4aeeff2d2ec22b1a15a553fc044235c8f15b6c1f4e54e968ad5b1c648
|
4
|
+
data.tar.gz: df47f776ed09799f9e71d8b3ddb5ad1c8cb80178326a987fe5231e5f6c2b030c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca3af8fb137ff99fdbd6bab2682bf7c8d3231ad4914cb81eba76fa8533e04b35448dfdee22729888e4165e6039b8c36c68a603ddb72ad85b77ea48f7f840d30f
|
7
|
+
data.tar.gz: 2a466ac6a681c5b64878bcb3bf145584cdfa95dcab0670e57d414525d56650683bab7e6d2513e323bcbf189735fec63d0d6bd8419dbc60b9620cec3ca7a8e1bf
|
data/lib/biran/configurinator.rb
CHANGED
@@ -53,7 +53,7 @@ module Biran
|
|
53
53
|
}
|
54
54
|
|
55
55
|
app_config.deep_merge! app_config_defaults
|
56
|
-
app_config[:secrets]
|
56
|
+
app_config[:secrets].deep_merge! get_secret_contents(app_config)
|
57
57
|
app_config[:db_config] = build_db_config
|
58
58
|
|
59
59
|
app_config.deep_merge! local_config_file_contents
|
@@ -1,10 +1,13 @@
|
|
1
|
+
require 'biran/hash_refinement'
|
2
|
+
|
1
3
|
module Biran
|
2
4
|
class Configurinator
|
3
5
|
include ConfigDefaults
|
6
|
+
using HashRefinement
|
4
7
|
|
5
8
|
DEFAULT_ENV = 'development'
|
6
9
|
|
7
|
-
attr_reader :config, :db_config
|
10
|
+
attr_reader :config, :db_config, :env
|
8
11
|
|
9
12
|
class << self
|
10
13
|
attr_accessor :config
|
@@ -13,18 +16,10 @@ module Biran
|
|
13
16
|
self.config ||= Config.instance
|
14
17
|
yield config
|
15
18
|
end
|
16
|
-
|
17
|
-
def env= env
|
18
|
-
@env = env
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def env
|
23
|
-
return @env if @env
|
24
|
-
@env = app_env
|
25
19
|
end
|
26
20
|
|
27
|
-
def initialize
|
21
|
+
def initialize(env: nil)
|
22
|
+
@env = env || app_env
|
28
23
|
@config = build_app_config
|
29
24
|
end
|
30
25
|
|
@@ -32,23 +27,16 @@ module Biran
|
|
32
27
|
files_to_generate.keys
|
33
28
|
end
|
34
29
|
|
35
|
-
def debug_stuff
|
36
|
-
puts "app env2 is: #{app_env}"
|
37
|
-
puts "instance @env is #{@env}"
|
38
|
-
puts "env from method is #{env}"
|
39
|
-
puts "rack env is #{ENV['RACK_ENV']}"
|
40
|
-
end
|
41
|
-
|
42
30
|
def files_to_generate
|
43
31
|
@files_to_generate ||= config.fetch(:app, {})
|
44
32
|
.fetch(:files_to_generate, configuration.files_to_generate)
|
45
33
|
.tap { |files_list| files_list.each(&sanitize_config_files(files_list)) }
|
46
34
|
end
|
47
35
|
|
48
|
-
def create(name:, extension:, output_dir: nil)
|
36
|
+
def create(name:, extension:, output_dir: nil, output_name: nil)
|
49
37
|
output_dir ||= config_dir
|
50
|
-
|
51
|
-
generated_file = ERBConfig.new(filtered_config, name, extension, config_dir, output_dir)
|
38
|
+
output_name ||= name
|
39
|
+
generated_file = ERBConfig.new(filtered_config, name, extension, config_dir, output_dir, output_name)
|
52
40
|
generated_file.bindings = bindings
|
53
41
|
generated_file.save!
|
54
42
|
end
|
@@ -56,6 +44,7 @@ module Biran
|
|
56
44
|
private
|
57
45
|
|
58
46
|
def build_app_config
|
47
|
+
raise 'Environment not set to build the application config' unless @env
|
59
48
|
app_config = {
|
60
49
|
app_root_dir: app_root,
|
61
50
|
app_shared_dir: app_shared_dir,
|
@@ -67,10 +56,13 @@ module Biran
|
|
67
56
|
}
|
68
57
|
|
69
58
|
app_config.deep_merge! app_config_defaults
|
70
|
-
app_config[:secrets]
|
59
|
+
app_config[:secrets].deep_merge! get_secret_contents(app_config)
|
71
60
|
app_config[:db_config] = build_db_config
|
72
61
|
|
73
62
|
app_config.deep_merge! local_config_file_contents
|
63
|
+
|
64
|
+
puts "app config final is #{app_config.inspect}"
|
65
|
+
app_config
|
74
66
|
end
|
75
67
|
|
76
68
|
def build_db_config
|
@@ -97,7 +89,25 @@ module Biran
|
|
97
89
|
config_file_contents = File.read(config_file)
|
98
90
|
config_file_contents = ERB.new(config_file_contents).result
|
99
91
|
config_file_contents = YAML.safe_load(config_file_contents, [], [], true)
|
100
|
-
config_file_contents
|
92
|
+
#puts "Config file contents after yaml load before env grab #{config_file_contents.inspect}"
|
93
|
+
config_file_contents_for_test = config_file_contents['test']
|
94
|
+
config_file_contents_for_env = config_file_contents[env]
|
95
|
+
puts "Config file contents for test:"
|
96
|
+
puts config_file_contents_for_test.to_yaml
|
97
|
+
puts
|
98
|
+
puts "Config file contents for #{env}:"
|
99
|
+
puts config_file_contents_for_env.to_yaml
|
100
|
+
puts
|
101
|
+
config_file_diff = config_file_contents_for_test.deep_diff(config_file_contents_for_env)
|
102
|
+
puts "diff hash is:"
|
103
|
+
puts config_file_diff.to_yaml
|
104
|
+
puts
|
105
|
+
config_file_diff_r = config_file_contents_for_env.deep_diff(config_file_contents_for_test)
|
106
|
+
puts "diff hash reversed is:"
|
107
|
+
puts config_file_diff_r.to_yaml
|
108
|
+
puts
|
109
|
+
|
110
|
+
config_file_contents_for_env.deep_symbolize_keys!
|
101
111
|
rescue Errno::ENOENT
|
102
112
|
raise "Missing config file: #{config_file}"
|
103
113
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module HashRefinement
|
2
|
+
|
3
|
+
refine Hash do
|
4
|
+
def deep_diff(b)
|
5
|
+
a = self
|
6
|
+
(a.keys | b.keys).inject({}) do |diff, k|
|
7
|
+
if a[k] != b[k]
|
8
|
+
if a[k].respond_to?(:deep_diff) && b[k].respond_to?(:deep_diff)
|
9
|
+
diff[k] = a[k].deep_diff(b[k])
|
10
|
+
else
|
11
|
+
#diff[k] = b[k] || a[k]
|
12
|
+
diff[k] = b.keys.exclude?(k) ? a[k] : b[k]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
diff
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/biran/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: biran
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- javierg
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2019-
|
13
|
+
date: 2019-09-30 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: railties
|
@@ -125,8 +125,9 @@ files:
|
|
125
125
|
- lib/biran/config.rb
|
126
126
|
- lib/biran/config_defaults.rb
|
127
127
|
- lib/biran/configurinator.rb
|
128
|
-
- lib/biran/configurinator.rb.
|
128
|
+
- lib/biran/configurinator.rb.test_changes
|
129
129
|
- lib/biran/erb_config.rb
|
130
|
+
- lib/biran/hash_refinement.rb
|
130
131
|
- lib/biran/railtie.rb
|
131
132
|
- lib/biran/version.rb
|
132
133
|
- lib/tasks/biran_tasks.rake
|