capistrano3-postgres 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/capistrano3/postgres/version.rb +1 -1
- data/lib/capistrano3/tasks/postgres.rb +22 -7
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8859ae778f1e88395c55b8d31281ccb50f315ea9
|
4
|
+
data.tar.gz: 32712b243c9970b79f692a105bd9119119a6ddfd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01c3262ae551f2b7276e8def589ae642a7c50032dd2602ccd1475d632737fddc5dbf5db645dfc199bddf772707178dd1c687514b71c5041ab66461760e9c328f
|
7
|
+
data.tar.gz: e170faa00dad23c3ba9cce1d301169b4d5a45c907e7e97162a294bc2576a3f3d1fb8aff62c7af32ad95bf726d9e019f6cb3433fc655be7db620bc5402ecb1b87
|
data/README.md
CHANGED
@@ -20,7 +20,7 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
Capistrano3::Postgres supports [Dotenv](https://github.com/bkeepers/dotenv)
|
23
|
+
Capistrano3::Postgres supports [Dotenv](https://github.com/bkeepers/dotenv) and [Figaro](https://github.com/laserlemon/figaro) gems and automatically loads environment variables from `.env`/`application.yml` files if they are used in the project.
|
24
24
|
|
25
25
|
```ruby
|
26
26
|
# Capfile
|
@@ -141,7 +141,7 @@ namespace :postgres do
|
|
141
141
|
env = fetch(:postgres_env).to_s.downcase
|
142
142
|
filename = "#{deploy_to}/current/config/database.yml"
|
143
143
|
eval_yaml_with_erb = <<-RUBY.strip
|
144
|
-
#{env_variables_loader_code}
|
144
|
+
#{env_variables_loader_code(env)}
|
145
145
|
require 'erb'
|
146
146
|
puts ERB.new(File.read('#{filename}')).result
|
147
147
|
RUBY
|
@@ -160,10 +160,12 @@ namespace :postgres do
|
|
160
160
|
# Load environment variables for configurations.
|
161
161
|
# Useful for such gems as Dotenv, Figaro, etc.
|
162
162
|
def preload_env_variables(env)
|
163
|
-
safely_require_gems('dotenv')
|
163
|
+
safely_require_gems('dotenv', 'figaro')
|
164
164
|
|
165
165
|
if defined?(Dotenv)
|
166
166
|
load_env_variables_with_dotenv(env)
|
167
|
+
elsif defined?(Figaro)
|
168
|
+
load_env_variables_with_figaro(env)
|
167
169
|
end
|
168
170
|
end
|
169
171
|
|
@@ -175,6 +177,13 @@ namespace :postgres do
|
|
175
177
|
)
|
176
178
|
end
|
177
179
|
|
180
|
+
def load_env_variables_with_figaro(env)
|
181
|
+
config = 'config/application.yml'
|
182
|
+
|
183
|
+
Figaro.application = Figaro::Application.new(environment: env, path: config)
|
184
|
+
Figaro.load
|
185
|
+
end
|
186
|
+
|
178
187
|
def safely_require_gems(*gem_names)
|
179
188
|
gem_names.each do |name|
|
180
189
|
begin
|
@@ -187,14 +196,20 @@ namespace :postgres do
|
|
187
196
|
|
188
197
|
# Requires necessary gems (Dotenv, Figaro, ...) if present
|
189
198
|
# and loads environment variables for configurations
|
190
|
-
def env_variables_loader_code
|
199
|
+
def env_variables_loader_code(env)
|
191
200
|
<<-RUBY.strip
|
192
201
|
begin
|
193
202
|
require 'dotenv'
|
194
|
-
Dotenv.load(
|
195
|
-
|
196
|
-
|
197
|
-
|
203
|
+
Dotenv.load(File.expand_path('.env.#{env}'), File.expand_path('.env'))
|
204
|
+
rescue LoadError
|
205
|
+
end
|
206
|
+
|
207
|
+
begin
|
208
|
+
require 'figaro'
|
209
|
+
config = File.expand_path('../config/application.yml', __FILE__)
|
210
|
+
|
211
|
+
Figaro.application = Figaro::Application.new(environment: env, path: config)
|
212
|
+
Figaro.load
|
198
213
|
rescue LoadError
|
199
214
|
end
|
200
215
|
RUBY
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano3-postgres
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Krasynskyi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|
@@ -61,7 +61,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
61
61
|
version: '0'
|
62
62
|
requirements: []
|
63
63
|
rubyforge_project:
|
64
|
-
rubygems_version: 2.
|
64
|
+
rubygems_version: 2.5.1
|
65
65
|
signing_key:
|
66
66
|
specification_version: 4
|
67
67
|
summary: Create, download and restore postgres database.
|