Replace Foreman::Env with dotenv
This commit is contained in:
@@ -2,6 +2,8 @@ source "http://rubygems.org"
|
|||||||
|
|
||||||
gemspec
|
gemspec
|
||||||
|
|
||||||
|
gem 'dotenv', :github => 'bkeepers/dotenv', :branch => '0.7'
|
||||||
|
|
||||||
platform :mingw do
|
platform :mingw do
|
||||||
gem "win32console", "~> 1.3.0"
|
gem "win32console", "~> 1.3.0"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,7 +1,15 @@
|
|||||||
|
GIT
|
||||||
|
remote: git://github.com/bkeepers/dotenv.git
|
||||||
|
revision: bd139d3c2e627c4f5958542de50a1ae7038f0f8d
|
||||||
|
branch: 0.7
|
||||||
|
specs:
|
||||||
|
dotenv (0.7.0)
|
||||||
|
|
||||||
PATH
|
PATH
|
||||||
remote: .
|
remote: .
|
||||||
specs:
|
specs:
|
||||||
foreman (0.62.0)
|
foreman (0.62.0)
|
||||||
|
dotenv (>= 0.7)
|
||||||
thor (>= 0.13.6)
|
thor (>= 0.13.6)
|
||||||
|
|
||||||
GEM
|
GEM
|
||||||
@@ -52,6 +60,7 @@ PLATFORMS
|
|||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
aws-s3
|
aws-s3
|
||||||
|
dotenv!
|
||||||
fakefs (~> 0.3.2)
|
fakefs (~> 0.3.2)
|
||||||
foreman!
|
foreman!
|
||||||
posix-spawn (~> 0.3.6)
|
posix-spawn (~> 0.3.6)
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ Gem::Specification.new do |gem|
|
|||||||
gem.files << "man/foreman.1"
|
gem.files << "man/foreman.1"
|
||||||
|
|
||||||
gem.add_dependency 'thor', '>= 0.13.6'
|
gem.add_dependency 'thor', '>= 0.13.6'
|
||||||
|
gem.add_dependency 'dotenv', '>= 0.7'
|
||||||
|
|
||||||
if ENV["PLATFORM"] == "java"
|
if ENV["PLATFORM"] == "java"
|
||||||
gem.add_dependency "posix-spawn", "~> 0.3.6"
|
gem.add_dependency "posix-spawn", "~> 0.3.6"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
require "foreman"
|
require "foreman"
|
||||||
require "foreman/env"
|
|
||||||
require "foreman/process"
|
require "foreman/process"
|
||||||
require "foreman/procfile"
|
require "foreman/procfile"
|
||||||
|
require "dotenv"
|
||||||
require "tempfile"
|
require "tempfile"
|
||||||
require "timeout"
|
require "timeout"
|
||||||
require "fileutils"
|
require "fileutils"
|
||||||
@@ -172,9 +172,7 @@ class Foreman::Engine
|
|||||||
# @param [String] filename A .env file to load into the environment
|
# @param [String] filename A .env file to load into the environment
|
||||||
#
|
#
|
||||||
def load_env(filename)
|
def load_env(filename)
|
||||||
Foreman::Env.new(filename).entries do |name, value|
|
@env.update Dotenv::Environment.new(filename)
|
||||||
@env[name] = value
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Send a signal to all processes started by this +Engine+
|
# Send a signal to all processes started by this +Engine+
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
require "foreman"
|
|
||||||
|
|
||||||
class Foreman::Env
|
|
||||||
|
|
||||||
attr_reader :entries
|
|
||||||
|
|
||||||
def initialize(filename)
|
|
||||||
@entries = File.read(filename).gsub("\r\n","\n").split("\n").inject({}) do |ax, line|
|
|
||||||
if line =~ /\A([A-Za-z_0-9]+)=(.*)\z/
|
|
||||||
key = $1
|
|
||||||
case val = $2
|
|
||||||
# Remove single quotes
|
|
||||||
when /\A'(.*)'\z/ then ax[key] = $1
|
|
||||||
# Remove double quotes and unescape string preserving newline characters
|
|
||||||
when /\A"(.*)"\z/ then ax[key] = $1.gsub('\n', "\n").gsub(/\\(.)/, '\1')
|
|
||||||
else ax[key] = val
|
|
||||||
end
|
|
||||||
end
|
|
||||||
ax
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def entries
|
|
||||||
@entries.each do |key, value|
|
|
||||||
yield key, value
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
Reference in New Issue
Block a user