rdm 0.4.0 → 0.4.1

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: ccd255c90b9282d7099a6d56209702df3a6ae2ea
4
- data.tar.gz: 45f8f4f7c203d6c9f24145df9f78ec150bad091f
3
+ metadata.gz: ec7392add4bff744020f08554065f66d2b1c2155
4
+ data.tar.gz: 39ac10317b4c8ae71816e6844ec922b06025a74c
5
5
  SHA512:
6
- metadata.gz: 43e2df557a1921a6ee3edc8d998113fd97efa8632ddcd3d7bb60596fdb63ca9f75f261666d305a149bcb75f6d91a3f01b60980db609f8e4422d681f552358a77
7
- data.tar.gz: 037effcac344e15c413e24cc4b676ef5840eecadd0c70b2ce2752243541d9967c9e75f07fd6955a43177d6198b2b6bb83bfd102081b11f1b8d5a89b117d09969
6
+ metadata.gz: 705e6d22a68e2c9e5c2499bc197885bcb624f02777ba0601647cee6e93a034afb6c3c91dbef73da21ff5381d5e4f4d103f423193eaf6490c0fc0113badca3c21
7
+ data.tar.gz: 1a00c19c72dcdc189d84f9e1ac11412963bc04b7e4df69d3a6f1393bce683d9ae269180f35db35917bab16e1f6708f3778fe8f3bccff80dcaae91970fd1da638
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rdm (0.4.0)
4
+ rdm (0.4.1)
5
5
  activesupport
6
6
  commander (~> 4.4)
7
7
 
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
 
@@ -1 +1,3 @@
1
- RUBY_ENV=development
1
+ RUBY_ENV=development
2
+
3
+ APP_NAME=Application
@@ -1,3 +1,5 @@
1
1
  RUBY_ENV=production
2
2
 
3
3
  EXAMPLE_API_KEY=example_key_value
4
+
5
+ APP_NAME=Application
@@ -1 +1,3 @@
1
- RUBY_ENV=test
1
+ RUBY_ENV=test
2
+
3
+ APP_NAME=Application
data/lib/rdm.rb CHANGED
@@ -88,6 +88,14 @@ module Rdm
88
88
  @root = value
89
89
  end
90
90
 
91
- attr_reader :root
91
+ def root(path = nil)
92
+ return @root if @root
93
+
94
+ if path
95
+ @root = Rdm::SourceLocator.locate(path)
96
+ end
97
+
98
+ @root
99
+ end
92
100
  end
93
101
  end
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|
@@ -70,18 +70,18 @@ class Rdm::SourceParser
70
70
  end
71
71
 
72
72
  def init_and_set_env_variables(source)
73
- role = settings.read_setting(:role)
74
-
75
- unless File.exists?(env_file_path(role))
76
- @stdout.puts "WARNING! Environment file for role '#{role}' was not found. Please, add #{env_file_path(role)} 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(role)) do |line|
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 '#{role}' overwrites ENV['#{key}'] variable from '#{ENV.fetch(key, nil)}' to '#{value}' ..."
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(role)
106
- File.join(root_path, settings.read_setting(:env_files_dir), "#{role}.env")
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
@@ -1,3 +1,3 @@
1
1
  module Rdm
2
- VERSION = '0.4.0'.freeze
2
+ VERSION = '0.4.1'.freeze
3
3
  end
@@ -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?('role "production"') ? 'role "stading"' : line
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 for role 'stading' was not found. Please, add /tmp/example/env_files/stading.env 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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Droid Labs