rdm 0.4.0 → 0.4.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.lock +1 -1
- data/example/Rdm.packages +4 -2
- data/example/env_files/development.env +3 -1
- data/example/env_files/production.env +2 -0
- data/example/env_files/test.env +3 -1
- data/lib/rdm.rb +9 -1
- data/lib/rdm/settings.rb +2 -1
- data/lib/rdm/source_parser.rb +10 -8
- data/lib/rdm/templates/init/Rdm.packages +4 -0
- data/lib/rdm/version.rb +1 -1
- data/spec/rdm/source_parser_spec.rb +4 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec7392add4bff744020f08554065f66d2b1c2155
|
4
|
+
data.tar.gz: 39ac10317b4c8ae71816e6844ec922b06025a74c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 705e6d22a68e2c9e5c2499bc197885bcb624f02777ba0601647cee6e93a034afb6c3c91dbef73da21ff5381d5e4f4d103f423193eaf6490c0fc0113badca3c21
|
7
|
+
data.tar.gz: 1a00c19c72dcdc189d84f9e1ac11412963bc04b7e4df69d3a6f1393bce683d9ae269180f35db35917bab16e1f6708f3778fe8f3bccff80dcaae91970fd1da638
|
data/Gemfile.lock
CHANGED
data/example/Rdm.packages
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
setup do
|
2
2
|
role "production"
|
3
|
+
|
4
|
+
env_file_name "production"
|
5
|
+
env_files_dir "env_files"
|
3
6
|
|
4
7
|
configs_dir "configs"
|
5
8
|
config_path ":configs_dir/:config_name/default.yml"
|
6
9
|
role_config_path ":configs_dir/:config_name/:role.yml"
|
7
10
|
|
8
|
-
env_files_dir "env_files"
|
9
|
-
|
10
11
|
package_subdir_name "package"
|
11
12
|
|
13
|
+
|
12
14
|
compile_path "/tmp/rdm/:package_name"
|
13
15
|
end
|
14
16
|
|
data/example/env_files/test.env
CHANGED
data/lib/rdm.rb
CHANGED
data/lib/rdm/settings.rb
CHANGED
@@ -2,7 +2,7 @@ class Rdm::Settings
|
|
2
2
|
SETTING_KEYS = [
|
3
3
|
:role, :package_subdir_name, :configs_dir, :config_path, :role_config_path,
|
4
4
|
:silence_missing_package_file, :silence_missing_package, :compile_path,
|
5
|
-
:compile_ignore_files, :compile_add_files, :env_files_dir
|
5
|
+
:compile_ignore_files, :compile_add_files, :env_files_dir, :env_file_name
|
6
6
|
].freeze
|
7
7
|
|
8
8
|
SETTING_VARIABLES = [:role, :configs_dir, :config_path, :role_config_path].freeze
|
@@ -26,6 +26,7 @@ class Rdm::Settings
|
|
26
26
|
'Gemfile',
|
27
27
|
'Gemfile.lock',
|
28
28
|
])
|
29
|
+
compile_path('/tmp/rdm/:package_name')
|
29
30
|
end
|
30
31
|
|
31
32
|
SETTING_KEYS.each do |key|
|
data/lib/rdm/source_parser.rb
CHANGED
@@ -70,18 +70,18 @@ class Rdm::SourceParser
|
|
70
70
|
end
|
71
71
|
|
72
72
|
def init_and_set_env_variables(source)
|
73
|
-
|
74
|
-
|
75
|
-
unless File.exists?(env_file_path
|
76
|
-
@stdout.puts "WARNING! Environment file
|
73
|
+
return unless settings.read_setting(:env_file_name)
|
74
|
+
|
75
|
+
unless File.exists?(env_file_path)
|
76
|
+
@stdout.puts "WARNING! Environment file '#{settings.read_setting(:env_file_name)}' was not found. Please, add #{env_file_path} file..."
|
77
77
|
return
|
78
78
|
end
|
79
79
|
|
80
|
-
File.foreach(env_file_path
|
80
|
+
File.foreach(env_file_path) do |line|
|
81
81
|
key, value = line.split('=').map(&:strip)
|
82
82
|
|
83
83
|
if ENV.has_key?(key) && ENV[key] != value
|
84
|
-
@stdout.puts "WARNING! Environment file '#{
|
84
|
+
@stdout.puts "WARNING! Environment file '#{settings.read_setting(:env_file_name)}' overwrites ENV['#{key}'] variable from '#{ENV.fetch(key, nil)}' to '#{value}' ..."
|
85
85
|
end
|
86
86
|
|
87
87
|
ENV[key] = value
|
@@ -102,8 +102,10 @@ class Rdm::SourceParser
|
|
102
102
|
File.dirname(source_path)
|
103
103
|
end
|
104
104
|
|
105
|
-
def env_file_path
|
106
|
-
File.join(root_path, settings.read_setting(:env_files_dir), "#{
|
105
|
+
def env_file_path
|
106
|
+
file_path = File.join(root_path, settings.read_setting(:env_files_dir), "#{settings.read_setting(:env_file_name)}")
|
107
|
+
|
108
|
+
file_path.gsub(/\.env$/, '').concat('.env')
|
107
109
|
end
|
108
110
|
|
109
111
|
# [String] Source file content
|
@@ -3,6 +3,10 @@ setup do
|
|
3
3
|
ENV['RUBY_ENV'] || raise('please set RUBY_ENV environment variable')
|
4
4
|
end
|
5
5
|
|
6
|
+
env_file_name do
|
7
|
+
ENV['ENV_FILE']
|
8
|
+
end
|
9
|
+
|
6
10
|
configs_dir 'configs'
|
7
11
|
config_path ':configs_dir/:config_name/default.yml'
|
8
12
|
role_config_path ':configs_dir/:config_name/:role.yml'
|
data/lib/rdm/version.rb
CHANGED
@@ -91,18 +91,19 @@ describe Rdm::SourceParser do
|
|
91
91
|
subject.read_and_init_source(@rdm_source_file)
|
92
92
|
|
93
93
|
expect(ENV['EXAMPLE_API_KEY']).to eq('example_key_value')
|
94
|
+
expect(ENV['APP_NAME']).to eq('Application')
|
94
95
|
end
|
95
96
|
end
|
96
97
|
|
97
98
|
context "with undefined role" do
|
98
99
|
it "puts warning message" do
|
99
100
|
Rdm::Utils::FileUtils.change_file @rdm_source_file do |line|
|
100
|
-
line.include?('
|
101
|
+
line.include?('env_file_name "production"') ? 'env_file_name "stading"' : line
|
101
102
|
end
|
102
103
|
|
103
104
|
subject.read_and_init_source(@rdm_source_file, stdout: stdout)
|
104
105
|
|
105
|
-
expect(stdout.output).to include("WARNING! Environment file
|
106
|
+
expect(stdout.output).to include("WARNING! Environment file 'stading' was not found. Please, add /tmp/example/env_files/stading.env file...")
|
106
107
|
end
|
107
108
|
end
|
108
109
|
|
@@ -119,6 +120,7 @@ describe Rdm::SourceParser do
|
|
119
120
|
|
120
121
|
it 'overwrites ENV variable' do
|
121
122
|
expect(ENV['RUBY_ENV']).to eq('production')
|
123
|
+
expect(ENV['APP_NAME']).to eq('Application')
|
122
124
|
end
|
123
125
|
end
|
124
126
|
end
|