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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c1823e5322b73aef1707629d1de248d157cd8620
4
- data.tar.gz: a724ae00fb4140bb00d173d7464ba9a3842d7fd8
3
+ metadata.gz: 8859ae778f1e88395c55b8d31281ccb50f315ea9
4
+ data.tar.gz: 32712b243c9970b79f692a105bd9119119a6ddfd
5
5
  SHA512:
6
- metadata.gz: a96d1e6c8d2259c76a81f21042fa1bf4b08b91ca3423c41a76992f74f47f88f963b282ea822e41371db5d74c70daf2aeecd62cd3e50426c3ad79dd494897b1ce
7
- data.tar.gz: e55fca4756984d06bb0519bec5c54fdabac9e39854175e6afee747d6765667a73d2ece519603cf8bc7d731be50b6f0f857f2d6bd90520562423af0b27bee115c
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) gem and automatically loads environment variables from `.env` files if they are used in the project.
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
@@ -1,5 +1,5 @@
1
1
  module Capistrano3
2
2
  module Postgres
3
- VERSION = "0.2.1"
3
+ VERSION = "0.2.2"
4
4
  end
5
5
  end
@@ -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
- File.expand_path('.env.production'),
196
- File.expand_path('.env')
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.1
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-07-19 00:00:00.000000000 Z
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.4.5.1
64
+ rubygems_version: 2.5.1
65
65
  signing_key:
66
66
  specification_version: 4
67
67
  summary: Create, download and restore postgres database.