Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ed44a11e21 | ||
|
|
5719f4fc72 |
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
PATH
|
PATH
|
||||||
remote: .
|
remote: .
|
||||||
specs:
|
specs:
|
||||||
foreman (0.22.0)
|
foreman (0.23.0)
|
||||||
term-ansicolor (~> 1.0.5)
|
term-ansicolor (~> 1.0.5)
|
||||||
thor (>= 0.13.6)
|
thor (>= 0.13.6)
|
||||||
|
|
||||||
|
|||||||
+17
-10
@@ -22,7 +22,7 @@ class Foreman::Engine
|
|||||||
@procfile = read_procfile(procfile)
|
@procfile = read_procfile(procfile)
|
||||||
@directory = File.expand_path(File.dirname(procfile))
|
@directory = File.expand_path(File.dirname(procfile))
|
||||||
@options = options
|
@options = options
|
||||||
@environment = read_environment(options[:env])
|
@environment = read_environment_files(options[:env])
|
||||||
end
|
end
|
||||||
|
|
||||||
def processes
|
def processes
|
||||||
@@ -202,22 +202,29 @@ private ######################################################################
|
|||||||
puts "!!! e.g. web: thin start"
|
puts "!!! e.g. web: thin start"
|
||||||
end
|
end
|
||||||
|
|
||||||
def read_environment(filename)
|
def read_environment_files(filenames)
|
||||||
error "No such file: #{filename}" if filename && !File.exists?(filename)
|
|
||||||
filename ||= ".env"
|
|
||||||
environment = {}
|
environment = {}
|
||||||
|
|
||||||
if File.exists?(filename)
|
(filenames || "").split(",").map(&:strip).each do |filename|
|
||||||
File.read(filename).split("\n").each do |line|
|
error "No such file: #{filename}" unless File.exists?(filename)
|
||||||
if line =~ /\A([A-Za-z_]+)=(.*)\z/
|
environment.merge!(read_environment(filename))
|
||||||
environment[$1] = $2
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
environment.merge!(read_environment(".env")) unless filenames
|
||||||
environment
|
environment
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def read_environment(filename)
|
||||||
|
return {} unless File.exists?(filename)
|
||||||
|
|
||||||
|
File.read(filename).split("\n").inject({}) do |hash, line|
|
||||||
|
if line =~ /\A([A-Za-z_]+)=(.*)\z/
|
||||||
|
hash[$1] = $2
|
||||||
|
end
|
||||||
|
hash
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def runner
|
def runner
|
||||||
File.expand_path("../../../bin/foreman-runner", __FILE__)
|
File.expand_path("../../../bin/foreman-runner", __FILE__)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
module Foreman
|
module Foreman
|
||||||
|
|
||||||
VERSION = "0.22.0"
|
VERSION = "0.23.0"
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -79,6 +79,16 @@ describe "Foreman::Engine" do
|
|||||||
engine.execute("alpha")
|
engine.execute("alpha")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should read more than one if specified" do
|
||||||
|
File.open("/tmp/env1", "w") { |f| f.puts("FOO=bar") }
|
||||||
|
File.open("/tmp/env2", "w") { |f| f.puts("BAZ=qux") }
|
||||||
|
engine = Foreman::Engine.new("Procfile", :env => "/tmp/env1,/tmp/env2")
|
||||||
|
stub(engine).info
|
||||||
|
mock(engine).watch_for_termination
|
||||||
|
engine.environment.should == { "FOO"=>"bar", "BAZ"=>"qux" }
|
||||||
|
engine.execute("alpha")
|
||||||
|
end
|
||||||
|
|
||||||
it "should fail if specified and doesnt exist" do
|
it "should fail if specified and doesnt exist" do
|
||||||
mock.instance_of(Foreman::Engine).error("No such file: /tmp/env")
|
mock.instance_of(Foreman::Engine).error("No such file: /tmp/env")
|
||||||
engine = Foreman::Engine.new("Procfile", :env => "/tmp/env")
|
engine = Foreman::Engine.new("Procfile", :env => "/tmp/env")
|
||||||
|
|||||||
Reference in New Issue
Block a user